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 for a particular company code

former_member201364
Participant
0 Kudos

Hi,

I need to check authorization for a particular company code.In my bdc call transaction program i'm fetching mass data from excel file and for every record i've to check the company code field.If the company code is not the required one then that record should not be processed.

So before filling the bdc data i wrote like

LOOP AT gt_inrec INTO gs_inrec.

AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'

ID 'ACTVT' field '02'

ID 'BUKRS' field '2800'.

IF NOT sy-subrc = 0.

MESSAGE e058(zz) WITH gs_inrec-bukrs.

EXIT.

ENDIF.

PERFORM fill_bdc.

ENDLOOP.

but it is not exiting for different company codes and is allowing records with all company codes.

can anybody pls tell me how to rectify this?

thanks in advance,

poornima

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello

If I understand you correctly then you have two requirements:

1.) Process records only for a specific company code

2.) Process records for this specific company code only if authority-check is OK

Then you solution should look like this:


LOOP AT gt_inrec INTO gs_inrec
                           WHERE ( bukrs = '2800' ).
  AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
  ID 'ACTVT' field '02'
  ID 'BUKRS' field gs_inrec-bukrs.
  IF NOT sy-subrc = 0.
    MESSAGE e058(zz) WITH gs_inrec-bukrs.
    EXIT.
  ENDIF.
  PERFORM fill_bdc.
ENDLOOP.

Regards

Uwe

10 REPLIES 10

Former Member
0 Kudos

Try this modified code:

LOOP AT gt_inrec INTO gs_inrec.

AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'

ID 'ACTVT' field '02'

ID 'BUKRS' field gs_inrec-bukrs.

IF NOT sy-subrc = 0.

MESSAGE e058(zz) WITH gs_inrec-bukrs.

EXIT.

ENDIF.

PERFORM fill_bdc.

ENDLOOP.

If still u r facing the same problem then ask basis to remove ur name for changing some comp. code.

Regards,

JOy.

0 Kudos

Hi Joyjit,

But if i write like

ID 'BUKRS' field gs_inrec-bukrs

i doubt whether it will allow only records with company code 2800.

poornima

0 Kudos

that means u need to check the authorization only for company code 2800..right? and for other company code u r not going check it, in fact u r going to ignore them..right? If my assumptions are correct then try this...

LOOP AT gt_inrec INTO gs_inrec.

if gs_inrec-bukrs = '2800'.

AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'

ID 'ACTVT' field '02'

ID 'BUKRS' field gs_inrec-bukrs.

IF NOT sy-subrc = 0.

MESSAGE e058(zz) WITH gs_inrec-bukrs.

EXIT.

ENDIF.

PERFORM fill_bdc.

endif.

ENDLOOP.

Edited by: Joyjit Ghosh on Jul 13, 2008 1:55 PM

uwe_schieferstein
Active Contributor
0 Kudos

Hello

If I understand you correctly then you have two requirements:

1.) Process records only for a specific company code

2.) Process records for this specific company code only if authority-check is OK

Then you solution should look like this:


LOOP AT gt_inrec INTO gs_inrec
                           WHERE ( bukrs = '2800' ).
  AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
  ID 'ACTVT' field '02'
  ID 'BUKRS' field gs_inrec-bukrs.
  IF NOT sy-subrc = 0.
    MESSAGE e058(zz) WITH gs_inrec-bukrs.
    EXIT.
  ENDIF.
  PERFORM fill_bdc.
ENDLOOP.

Regards

Uwe

Former Member
0 Kudos

Moved to security forum... (unless anyone objects)...

0 Kudos

I need to perform authority check on the field NAME1 present in the standard screen - customer master ( T.Code-XD02). Only certain users should be allowed to edit the field and others should be restricted.

I have created a field exit FIELD_EXIT_AD_NAME1 for the ADRC-NAME1 field.

Now inside this field exit i need to write the authority-check code.

I have created the authorisation object Z_KNA1_NAM for the field NAME1 using the SU20 and SU21.

For this scenario how do i write the authority-check code in my field exit?

Below is my field exit code,is that correct?

FUNCTION FIELD_EXIT_AD_NAME1.

*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(INPUT)

*" EXPORTING

*" REFERENCE(OUTPUT)

*"----


AUTHORITY-CHECK OBJECT 'Z_KNA1_NAM'

ID 'NAME1' FIELD SY-UNAME

ID 'ACTVT' FIELD '03'.

IF SY-SUBRC = 0.

MESSAGE 'Not Allowed to Edit the Name 1 Field' TYPE 'E'.

ENDIF.

ENDFUNCTION.

In the above code i have given SY-UNAME in the code line 2 - ID 'NAME1' FIELD SY-UNAME ,is that correct? what should i give there?

Please help me on this issue.

Cheers,

P.S.Chitra

0 Kudos

> FUNCTION FIELD_EXIT_AD_NAME1.

> *"----


> ""Local Interface:

> *" IMPORTING

> *" REFERENCE(INPUT)

> *" EXPORTING

> *" REFERENCE(OUTPUT)

> *"----


>

> AUTHORITY-CHECK OBJECT 'Z_KNA1_NAM'

> ID 'NAME1' FIELD SY-UNAME

> ID 'ACTVT' FIELD '03'.

> IF SY-SUBRC = 0.

> MESSAGE 'Not Allowed to Edit the Name 1 Field' TYPE 'E'.

> ENDIF.

>

> ENDFUNCTION.

>

> In the above code i have given SY-UNAME in the code line 2 - ID 'NAME1' FIELD SY-UNAME ,is that correct? what should i give there?

An authority-check is against the authorizations of the user under who's context the program runs. That is system field SY-UNAME.

So SY-UNAME = SY-UNAME does not make any sense...

It would appear that you are attempting to retrieve the "name" (e.g. the person who last made a change, or created the record?) from the record itself, and you are wanting to check whether the person is authorized to display records created by another...?

Also, ACTVT '03' is typically "display", yet you are raising a message with "EDIT"...

Edited by: Julius Bussche on Aug 18, 2008 7:35 AM

0 Kudos

Hi,

Thanks for ur immediate response.

Can u plz tell me how to proceed and how this authorization check can be performed insid the field exit?

-


Below is the Scenario:

To Create an Authorization object for Name field of XD01.

Then to create a Field exit for the Name1 field and Use the Authorization object to restrict the users by throwing an error msg and also assign the Authorization Object to the Specified Users

-


I need to perform authority check on the field NAME1 present in the standard screen - customer master ( T.Code-XD02). Only certain users should be allowed to edit the field and others should be restricted.

I have created a field exit FIELD_EXIT_AD_NAME1 for the ADRC-NAME1 field.

Now inside this field exit i need to write the authority-check code.

I have created the authorisation object Z_KNA1_NAM for the field NAME1 using the SU20 and SU21.

For this scenario how do i write the authority-check code in my field exit?

Please help me on this issue asap.

0 Kudos

I see that you have started your own thread in ABAP General...

Please do not "hijack" other people's threads and cross-post unnecessarily...

The [forum rules|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement] can be read here.

0 Kudos

Sorry , i did not know where to post new queries as i am new to this... Now i got it...