2007 Mar 19 6:27 PM
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,
2007 Mar 19 7:13 PM
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,
2007 Mar 19 7:13 PM
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.
2007 Mar 20 3:48 AM
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.