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: 

Authorization-check P_PCR fails...

Former Member
0 Kudos

Hey Guys,

I have a little authorization problem...

I created a role with authorizationobject P_PCR.

 Payroll Area                   B8     
 Activity                       Change

In my program i have following code to check authorization :

GET pernr.
  AUTHORITY-CHECK OBJECT 'P_PCR'
    ID 'ABKRS' FIELD pernr-abkrs
    ID 'ACTVT' FIELD '02'.

  IF sy-subrc NE 0.
    REJECT.
  ENDIF.
  
* further processing..

Everytime i execute this code, sy-subrc eq 4... :(.

When i look into SU53 :

The authorization check failed
  Authorization obj. <i>P_PCR</i>  HR: Payroll Control Record
    Object Class <i>HR</i>  Human Resources
                                    B8
      Activity                      02

My user is added to the role, so i don't see anymore why i can't execute this report ... Does anyone has an idea for me ?

Thanks,

Kind Regards,

Tom

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Tom,

It seems that - under the GET PERNR, it is fetching multiple records, you have the change authority for Payroll Accounting Areas = B8.

But during the execution of this block of code if the value of PERNR-ABKRS is anything other than B8, you will end up with sy-subrc 4.Just make sure that your program is designed to fetch the records related to Payroll Area B8 only.

3 REPLIES 3

Former Member
0 Kudos

Hi Tom,

It seems that - under the GET PERNR, it is fetching multiple records, you have the change authority for Payroll Accounting Areas = B8.

But during the execution of this block of code if the value of PERNR-ABKRS is anything other than B8, you will end up with sy-subrc 4.Just make sure that your program is designed to fetch the records related to Payroll Area B8 only.

0 Kudos

Hi SKC,

Thanks for your reply. That's idd a good point, but in my selection screen i enter that i only wanne treat records with ABKRS eq 'B8'.

But also, records with ABKRS eq 'B8', will result in an sy-subrc = 4 ...

Tom

0 Kudos

Bon... Found the error...

  AUTHORITY-CHECK OBJECT 'P_PCR'
    ID 'ABKRS' FIELD pernr-abkrs
    ID 'ACTVT' FIELD '02'.

  IF sy-subrc NE 0.
    REJECT.
  ENDIF.

In object P_PCR the field is not AB<b>KR</b>S, but the field is AB<b>RK</b>S.

So, problem solved...

Greetz,

Tom