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: 

Authority Check in Table Maintenance

Former Member
0 Kudos

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

5 REPLIES 5

Former Member
0 Kudos

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.

0 Kudos

But there is no field p_bukrs in my table. This will result to an error.

0 Kudos

Hi,

P_BUKRS is just an indicator to put the company code field.

Put your tablename and fieldname over there.

Regards,

Ankur Parab

0 Kudos

My custom table has no field for BUKRS, which is the issue.

raymond_giuseppi
Active Contributor
0 Kudos

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