SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.




CRM Companies List
Web Based CRM Software


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.

DATA lv_tcode LIKE tstc-tcode.
  lv_tcode = '/PERSONAS/ADMIN'.

CALL FUNCTION 'AUTHORITY_CHECK_TCODE'
 EXPORTING
  tcode = lv_tcode
 EXCEPTIONS
  ok = 1
  not_ok = 2
  OTHERS = 3.
IF sy-subrc = 1. CLEAR sy-subrc. ENDIF.
* IF sy-subrc > 1.
** User is not authorized for transaction code
* ELSE.
** User is authorized
*ENDIF.

Please note that transaction code should be provided in upper case.

ABAP function module to check authorization for SAP transaction code

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.

Translate lv_tcode 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.






SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table








Copyright © 2004 - 2017 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems