Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

User Authorization to a specific transaction

Former Member
0 Kudos
238

Hi All,

I want to check programmatically whether a specific user has authorization to a specific transaction. The statement AUTHORITY-CHECK OBJECT 'S_TCODE' works only for the current user.

Is there any function module where i can pass the User name and transaction and check whether the user have access to the transaction ?

Thanks in advance

Kasi

1 ACCEPTED SOLUTION

Former Member
0 Kudos
104

The program checks whether an authorization object is assigned to the transaction code. If this is the case, the program checks whether the user has an authorization for this authorization object. The transaction code/authorization object assignment is stored in table TSTCA.

The system performs authorization checks in the ABAP program using the ABAP statement AUTHORITY-CHECK.

Call 'AUTHORITY_CHECK'

EXPORTING

USER = <USER>

OBJECT = 'S_TCODE'

FIELD1 = 'TCD'

VALUE1 = <TRANSACTION CODE>

IMPORTING

SY-SUBRC = <VAL>.

6 REPLIES 6

Former Member
0 Kudos
104

Hi,

you can use the additional

... FOR USER user

option with

AUTHORITY-CHECK OBJECT

Former Member
0 Kudos
104

hi,

UST04 table can used to get the list of users for specific authorization.

Former Member
0 Kudos
105

The program checks whether an authorization object is assigned to the transaction code. If this is the case, the program checks whether the user has an authorization for this authorization object. The transaction code/authorization object assignment is stored in table TSTCA.

The system performs authorization checks in the ABAP program using the ABAP statement AUTHORITY-CHECK.

Call 'AUTHORITY_CHECK'

EXPORTING

USER = <USER>

OBJECT = 'S_TCODE'

FIELD1 = 'TCD'

VALUE1 = <TRANSACTION CODE>

IMPORTING

SY-SUBRC = <VAL>.

Former Member
0 Kudos
104

check this thread

Former Member
0 Kudos
104

Hi,

try this short report:


SELECT * FROM USR01.
*
  CALL FUNCTION 'AUTHORITY_CHECK'
    EXPORTING
      USER                = USR01-BNAME
      OBJECT              = 'S_TCODE'
      FIELD1              = 'TCD'
      VALUE1              = 'FB01'
    EXCEPTIONS
      USER_DONT_EXIST     = 1
      USER_IS_AUTHORIZED  = 2
      USER_NOT_AUTHORIZED = 3
      USER_IS_LOCKED      = 4
      OTHERS              = 5.
*
  WRITE: / USR01-BNAME.
*
  CASE SY-SUBRC.
    WHEN 2.      WRITE: 'USER_IS_AUTHORIZED'.
    WHEN 3.      WRITE: 'USER_NOT_AUTHORIZED'.
    WHEN OTHERS. WRITE: 'ERROR', SY-SUBRC.
  ENDCASE.
*
ENDSELECT.

regards, Dieter

Former Member
0 Kudos
104

Thanks a lot guys

Cheers,

Kasi