[ABAP] Berechtigungsprüfung im Code

Variante 1 (FuBa AUTHORITY_CHECK_TCODE)

* Berechtigung für Ausführung der Transaktion SOST prüfen
CALL FUNCTION 'AUTHORITY_CHECK_TCODE'
  EXPORTING
    tcode  = 'SOST'
  EXCEPTIONS
    ok     = 1
    not_ok = 2
    OTHERS = 3.

CASE sy-subrc.
  WHEN 1.
    WRITE: / 'Ja'.
  WHEN 2.
    WRITE: / 'Nein'.
  WHEN OTHERS.
    WRITE: / 'Unbekannt'.
ENDCASE.

Variante 2 (AUTHORITY-CHECK OBJECT)

* Berechtigung für Ausführung der Transaktion SOST prüfen
AUTHORITY-CHECK OBJECT 'S_TCODE' ID 'TCD' FIELD 'SOST'.
IF sy-subrc = 0.
  WRITE: / 'Ja'.
ELSE.
  WRITE: / 'Nein'.
ENDIF.

Variante 3 (FuBa AUTHORITY_CHECK_DATASET)

* Dateizugriffsberechtigungen auf dem Applikationsserver prüfen
DATA: lv_filename TYPE authb-filename VALUE '/tmp/readme.txt'.

...

* activity
*   SABC_ACT_READ              -> 'READ'
*   SABC_ACT_WRITE             -> 'WRITE'
*   SABC_ACT_READ_WITH_FILTER  -> 'READ_WITH_FILTER'
*   SABC_ACT_WRITE_WITH_FILTER -> 'WRITE_WITH_FILTER'
*   SABC_ACT_DELETE            -> 'DELETE'
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
  EXPORTING
    activity         = sabc_act_read
    filename         = lv_filename
  EXCEPTIONS
    no_authority     = 1
    activity_unknown = 2
    OTHERS           = 3.

CASE sy-subrc.
  WHEN 0.
    WRITE: / 'Ok'.
  WHEN 1.
    WRITE: / 'no_authority'.
  WHEN 2.
    WRITE: / 'activity_unknown'.
  WHEN OTHERS.
    WRITE: / 'others'.
ENDCASE.

Weiterführende Infos: Link und Link