Check Authorization for SAP Transaction Code using ABAP Function Module
SAP programmers can use ABAP function module AUTHORITY_CHECK_TCODE to check authorization for specific transaction code for the executing user. This ABAP tutorial shows how AUTHORITY_CHECK_TCODE function module can be used with sample code.
For example, if ABAP developer want to check if the user has authorization to execute specific tcode like SAP Screen Personas 3.0 administration transaction code /PERSONAS/ADMIN, following sample code can be used.
Please note that transaction code should be provided in upper case.
If the returned sy-subrc value is 1 then the user is authorized to launch and execute controlled SAP tcode. In fact the ABAP function module authority_check_tcode has more desciptive exceptions within its code. ABAP programmers can debug and see the check results in detail.
To be safe in case the transaction code for authorization check is provided by means of user input, etc. following code line can be used to convert input transaction code to upper case.
I hope this sample ABAP function module will be useful for ABAP developers to check user permissions or roles to execute a given SAP transaction code.