Application Development and Automation 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: 
Read only

Authority check question

Former Member
0 Likes
568

Hello everyone,

We need to write a code for authorization check.

Program selection screen have company code, plant and sales organization.

When user runs the program using a transaction, SAP program has to do the authority check.

In my req I have multiple 'ACTVT', 'WERKS', 'Plant', values for user profile. below code doesnt work.

Code I wrote is as below:

AUTHORITY-CHECK OBJECT 'XXXXXX'

ID 'ACTVT' FIELD '02'

ID 'WERKS' FIELD VBAK-WERKS.

IF SY-SUBRC <> 0.

MESSAGE E...

ENDIF.

All the time SY-SUBRC value showing is 0.

Please Suggest a solution for this ASAP.

Thanks,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
516

Hi,

Pl like the following code , it may work for u .

SELECT SINGLE bukrs

FROM t001

INTO t001-bukrs

WHERE bukrs = p_bukrs.

IF sy-subrc <> 0.

MESSAGE e059 WITH p_bukrs.

" invalid company code

ELSE.

AUTHORITY-CHECK OBJECT 'ZZZZZZZZ'

ID 'BUKRS' FIELD t001-bukrs.

IF sy-subrc NE 0.

MESSAGE e188 WITH text-037 t001-bukrs.

ENDIF.

ENDIF.

Cheers.

Hello everyone,

We need to write a code for authorization check.

Program selection screen have company code, plant and sales organization.

When user runs the program using a transaction, SAP program has to do the authority check.

In my req I have multiple 'ACTVT', 'WERKS', 'Plant', values for user profile. below code doesnt work.

Code I wrote is as below:

AUTHORITY-CHECK OBJECT 'XXXXXX'

ID 'ACTVT' FIELD '02'

ID 'WERKS' FIELD VBAK-WERKS.

IF SY-SUBRC <> 0.

MESSAGE E...

ENDIF.

All the time SY-SUBRC value showing is 0.

Please Suggest a solution for this ASAP.

Thanks,

2 REPLIES 2
Read only

Former Member
0 Likes
517

Hi,

Pl like the following code , it may work for u .

SELECT SINGLE bukrs

FROM t001

INTO t001-bukrs

WHERE bukrs = p_bukrs.

IF sy-subrc <> 0.

MESSAGE e059 WITH p_bukrs.

" invalid company code

ELSE.

AUTHORITY-CHECK OBJECT 'ZZZZZZZZ'

ID 'BUKRS' FIELD t001-bukrs.

IF sy-subrc NE 0.

MESSAGE e188 WITH text-037 t001-bukrs.

ENDIF.

ENDIF.

Cheers.

Read only

0 Likes
516

First check the condition in the authorization object you created for this purpose..

In the values column you might have added '*' for values....This means the authorization object will accept all values....

Hence sy-subrc returns 0....Once that is rectified there, then you will be able to perform a check correctly....The code written by you is perfectly fine.

Hope this solution was helpful

PS : Please award points if helpful.