ALV Reports
ABAP Developmentadvanced

ALV Reports Part 10: Authorization and Sensitive Data in ALV Reports

Key takeaway

Secure ALV reports: authorization checks on the selection screen and per row (AUTHORITY-CHECK with organizational levels), hiding or masking sensitive columns, restricting export and layout saving, and protecting drill-down navigation.

Explanation

📌 KEY POINTS
✅ An ALV shows everything in its output table — authorization must be checked before rows go into it.

✅ Check at two levels: transaction/report start (S_TCODE / custom object) and per organizational unit (company code, sales org, plant).

✅ Hide or mask sensitive columns (salary, bank data, personal data) for users without a display authorization.

⚠️ Hiding a column with no_out is NOT security — users can show it via the layout. Remove or mask the data itself.

━━━━━━━━━━━━━━━━━━━━
▶ WHERE WE ARE

Parts 1–9 built functional ALVs. A report that shows payroll, vendor bank data or customer personal data must also be safe — this is a common audit finding.

━━━━━━━━━━━━━━━━━━━━
▶ 1. WHERE CHECKS BELONG

  • Transaction start: S_TCODE is checked automatically for the transaction; reports run via SA38 need their own check (authorization group in report attributes or AUTHORITY-CHECK in INITIALIZATION / AT SELECTION-SCREEN).
  • Selection screen: check the entered organizational values (e.g. all company codes in s_bukrs) at AT SELECTION-SCREEN.
  • Rows: after selecting data, remove rows the user may not see (check each distinct org value once, not each row).

━━━━━━━━━━━━━━━━━━━━
▶ 2. AUTHORITY-CHECK

AUTHORITY-CHECK OBJECT 'F_BKPF_BUK' ID 'BUKRS' FIELD lv_bukrs ID 'ACTVT' FIELD '03'.

sy-subrc = 0 means allowed. Use standard objects where they exist; create custom objects (SU21) for custom data. Use SU53 / ST01 (STAUTHTRACE) to analyse failures.

━━━━━━━━━━━━━━━━━━━━
▶ 3. SENSITIVE COLUMNS

  • If the user lacks the "sensitive display" authorization: clear or mask the values (e.g. IBAN → DE893000) in the output table and mark the column tech = 'X'.
  • Never rely on no_out: the layout dialog can show it again.
  • Consider a separate output structure without sensitive fields.

━━━━━━━━━━━━━━━━━━━━
▶ 4. EXPORT AND LAYOUTS

  • Export to Excel/local file bypasses screen masking only if data is in the table — masking in data solves both.
  • Exclude functions (e.g. &XXL, &PC export) for reports with very sensitive data: it_excluding (REUSE_ALV) or it_toolbar_excluding (CL_GUI_ALV_GRID).
  • Global layouts (i_save 'X'/'A') should be allowed only for key users if layouts expose extra columns.

━━━━━━━━━━━━━━━━━━━━
▶ 5. DRILL-DOWN

Check authorization before CALL TRANSACTION (Part 6) — the called transaction may check it too, but a clear message is better than an error screen.

━━━━━━━━━━━━━━━━━━━━
▶ 6. PERFORMANCE

Check each distinct company code once (collect distinct values, check, then delete rows) rather than AUTHORITY-CHECK in a loop over 100,000 rows.

━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP

  1. Run the code example with a user who has access to only one company code.
  2. Observe removed rows and the masked bank account column.
  3. Trace the checks with STAUTHTRACE.

✅ CHECKPOINT: your ALV shows only what the user is allowed to see, even after layout changes or export.

Code example

ABAP Code
REPORT zalv_secure_vendors. TYPES: BEGIN OF ty_out,         bukrs TYPE bukrs,         lifnr TYPE lifnr,         name1 TYPE name1_gp,         bankn TYPE bankn,            " sensitive       END OF ty_out. DATA: gt_out    TYPE STANDARD TABLE OF ty_out,      gt_bukrs  TYPE STANDARD TABLE OF bukrs,      gv_bukrs  TYPE bukrs,      gv_bank_ok TYPE abap_bool,      gt_exclude TYPE slis_t_extab,      gs_exclude TYPE slis_extab,      gt_fcat   TYPE slis_t_fieldcat_alv,      gs_fcat   TYPE slis_fieldcat_alv.FIELD-SYMBOLS <ls_out> TYPE ty_out. SELECT-OPTIONS s_bukrs FOR gv_bukrs OBLIGATORY. * ===== Level 1: check the entered company codes on the selection screen =====AT SELECTION-SCREEN.  SELECT bukrs FROM t001 INTO TABLE gt_bukrs WHERE bukrs IN s_bukrs.  LOOP AT gt_bukrs INTO gv_bukrs.    AUTHORITY-CHECK OBJECT 'F_LFA1_BUK'      ID 'BUKRS' FIELD gv_bukrs      ID 'ACTVT' FIELD '03'.    IF sy-subrc <> 0.      MESSAGE e000(0k) WITH 'No display authorization for company code' gv_bukrs.    ENDIF.  ENDLOOP. START-OF-SELECTION.  SELECT b~bukrs a~lifnr a~name1 k~bankn    FROM lfb1 AS b    INNER JOIN lfa1 AS a ON a~lifnr = b~lifnr    LEFT OUTER JOIN lfbk AS k ON k~lifnr = a~lifnr    INTO TABLE gt_out    WHERE b~bukrs IN s_bukrs. * ===== Level 2: sensitive column only with extra authorization =====  AUTHORITY-CHECK OBJECT 'Z_VEND_BNK'           " custom object (SU21) for bank data display    ID 'ACTVT' FIELD '03'.  gv_bank_ok = boolc( sy-subrc = 0 ).   IF gv_bank_ok = abap_false.    LOOP AT gt_out ASSIGNING <ls_out> WHERE bankn IS NOT INITIAL.      <ls_out>-bankn = '**********'.            " mask the DATA, not just the column    ENDLOOP.  ENDIF. * ===== Field catalog (manual, DDIC references for texts) =====  PERFORM add_field USING 'BUKRS' 'LFB1' 'BUKRS'.  PERFORM add_field USING 'LIFNR' 'LFA1' 'LIFNR'.  PERFORM add_field USING 'NAME1' 'LFA1' 'NAME1'.  PERFORM add_field USING 'BANKN' 'LFBK' 'BANKN'. * ===== Level 3: no local export for users without bank authorization =====  IF gv_bank_ok = abap_false.    gs_exclude-fcode = '&XXL'. APPEND gs_exclude TO gt_exclude.   " spreadsheet    gs_exclude-fcode = '&PC'.  APPEND gs_exclude TO gt_exclude.   " local file  ENDIF.   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'    EXPORTING      i_callback_program = sy-repid      it_fieldcat        = gt_fcat      it_excluding       = gt_exclude      i_save             = 'U'                  " user layouts only    TABLES      t_outtab           = gt_out. *----------------------------------------------------------------------*FORM add_field USING iv_field TYPE slis_fieldname                     iv_table TYPE c                     iv_ref   TYPE c.  CLEAR gs_fcat.  gs_fcat-fieldname     = iv_field.  gs_fcat-ref_tabname   = iv_table.  gs_fcat-ref_fieldname = iv_ref.  APPEND gs_fcat TO gt_fcat.ENDFORM.

Real project scenario

An internal audit found that a custom vendor ALV showed bank account numbers to all AP clerks. The developer had set no_out on the BANKN column, but any user could add it back through "Change layout" and export it.
The fix masked the bank account in the output table unless the user had a new custom authorization object for bank data, removed local export for others, and added a company-code check at the selection screen. The audit finding was closed after a test with restricted users and STAUTHTRACE evidence.

Common mistakes

  • Hiding sensitive columns with no_out and calling it secure.
  • No company-code/org-level checks in custom reports.
  • AUTHORITY-CHECK inside a loop for every row.
  • Forgetting that export and layouts expose all columns in the table.
  • Not testing with a restricted user.

Best practices

  • Check org-level authorization at selection and filter data before display.
  • Mask or omit sensitive data in the table itself.
  • Use standard authorization objects; create custom ones for custom data.
  • Restrict export functions where required.
  • Test with restricted users and document checks for audits.

Interview angle

Questions: "How do you secure an ALV report?", "Is no_out enough to hide salary data?", "How do you check authorizations efficiently?"
Strong answer: AUTHORITY-CHECK at selection (org levels like BUKRS/VKORG/WERKS) and remove unauthorized rows by distinct values; sensitive fields masked or removed from the output table (no_out is not security — layouts/export show it); exclude export functions if needed; check before drill-down; analyse with SU53/STAUTHTRACE; test with restricted users.

Practice this lesson

Quick check

1. A column with salary data is set to no_out for users without authorization. Is the data protected?

2. What is the most efficient way to check company code authorization for 100,000 ALV rows?

3. Which measure prevents restricted users from downloading sensitive ALV data to Excel?

Interview questions

1. A custom aging ALV hides credit limit fields for some users using no_out, but still selects all customers and all fields. Is this secure? How do you fix it?

Answer it in your own words first, then compare.

2. ALV export to Excel loses leading zeros. Why?

Answer it in your own words first, then compare.

Practice more with Interview AI →

Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.

More lessons in this topic

Interview questions on this topic

Related SAP topics