06-05-2009 10:16 AM
Hi All,
I have a table with table maintenance. A transaction code is attached to it. I want to have an Authority-Check for a Company Code for the said table maintenance. So I created EVENT 25 for my custom table, and added the authority check. However, during debug mode, the authority check is giving a return code of 0, which mean my authority check is successful. The test ID that I am using is not assigned for the company code, which means that the authority check should fail, but this is not the case.
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'ACTVT' FIELD '03'.
IF sy-subrc NE 0.
MESSAGE e000 WITH text-001.
ENDIF.
There is no field for BUKRS in the table. Is my code correct? How should authority check proceed when there is no field Company Code for it?
Thanks,
Louisse
06-05-2009 10:22 AM
Hi,
You need to pass the BUKRS value to the AUTHORITY-CHECK OBJECT
AUTHORITY-CHECK OBJECT 'Z_SD_CCODE'
ID 'ACTVT' DUMMY
ID 'BUKRS' FIELD p_pbukrs " value
ID 'TCD' FIELD v_tcode.
06-05-2009 10:26 AM
But there is no field p_bukrs in my table. This will result to an error.
06-05-2009 11:08 AM
Hi,
P_BUKRS is just an indicator to put the company code field.
Put your tablename and fieldname over there.
Regards,
Ankur Parab
06-05-2009 11:28 AM
06-05-2009 12:16 PM
Your request to check authorization for a society code, so you have a code in your table or you did not correctly explain your requirement.
You may perform the check before save at event 01
LOOP AT total.
IF <action> = neuer_eintrag
OR <action> = aendern.
wa = total.
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'ACTVT' FIELD '3'
ID 'BUKRS' FIELD wa-bukrs.
IF sy-subrc NE 0. " sy-subrc NE 0 > no update
" message not allowed to society wa-bukrs
vim_abort_saving = 'X'.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
Regards,
Raymond