Authorization check to enable/ disable a selection screen parameter of a ABAP report.
We have a parameter in the program which we would like to enable/ disable based on the authorization object assigned to the user profile. Authorization object is created by your BASIS person in TA SU21. In this example the Authorizatio object is "Z_AUTH".
The following code snippet can be used:
SELECTION-SCREEN BEGIN OF BLOCK BLOCK1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_INPUT TYPE FLAG DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK BLOCK1.
AT SELECTION-SCREEN OUTPUT.
AUTHORITY-CHECK OBJECT 'Z_AUTH'
ID 'ACTVT' FIELD '01'.
* Authority check failed, disable the paramter
IF SY-SUBRC = 12.
LOOP AT SCREEN.
IF SCREEN-NAME = 'P_INPUT'.
SCREEN-INPUT = 0.