‎2008 Mar 05 5:20 AM
hello everyone,
plz tell me how i can use this code in my report.
AUTHORITY-CHECK OBJECT 'S_USER_GRP'
ID 'ClASS' FIELD 'AUDIT'
ID 'ACTVT' FIELD '01'.
IF SY-SUBRC NE 0.
041 Keine Berechtigung zum Anlegen von Benutzergruppe &
MESSAGE E041(01) WITH ' '.
endif.
i have written this code in my report but it's not working.
‎2008 Mar 05 5:28 AM
Hi,
Authority check is just for checking that if any user wants to access the report then does he has that authority, if yes then report will be displayed otherwise the Error message will be displayed.
For more information Write
AUTHORITY-CHECK and press F1 on it.
HTH,
Regards,
Dhruv Shah
‎2008 Mar 05 5:34 AM
You are checking whether the user has the authorization for the CLASS ( User group in user master maintenance) which he is using.
So the CLASS parameter you got from direct input from selection screen from your program or from a database select in your code. Now two senerio possible :
1. CLASS have a single value in your program
2. CLASS have a list values in your program
1. When CLASS have a single value
Suppose the value is P_CLASS. Now you check the authorization of user by the following code:
AUTHORITY-CHECK OBJECT 'S_USER_GRP'
ID 'ClASS' FIELD P_CLASS
ID 'ACTVT' FIELD '01'.
IF SY-SUBRC NE 0.
ENDIF.
SY-SUBRC EQ 0 means user has the authorization. In that case carryout the normal prossaing. If authorization fails (sy-subrc NE 0). Then you need to carryout operation according your logic. That may be stoping your program execution and display a error message. But it can varry according to your senerio.
CLASS have a list values
Suppose values are in LT_CLASS table. Then you need to loop LT_CLASS and check the authorization of each CLASS and if authorization fails you have to delete it from LT_CLASS table. Rest of your program will only consider the CLASS for which user has authorization.
LOOP AT LT_CLASS INTO LW_CLASS.
AUTHORITY-CHECK OBJECT 'S_USER_GRP'
ID 'ClASS' FIELD LW_CLASS-CLASS
ID 'ACTVT' FIELD '01'.
IF SY-SUBRC NE 0.
DELETE LT_CLASS.
ENDIF.
CLEAR: LW_CLASS.
ENDLOOP.