Application Development and Automation 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: 
Read only

Auhority-Check

Former Member
0 Likes
865

Hi

All

I have following code

start-of-selection.

authority-check object 'V_VBAK_VKO'

  • ID 'VKORG' FIELD P_VKORG

  • ID 'VTWEG' FIELD P_VTWEG

  • ID 'SPART' FIELD P_SPART

id 'VKORG' field s_vkorg

id 'VTWEG' field s_vtweg

id 'SPART' field s_spart

if sy-subrc ne c_0.

Message e999 with "No Authorization"

Endif

previously iwas using a single value(P_VKORG,P_VTWEG,P_SPART) in fields

but now my req has been changed to multiple values.

so plz tell whether my code will work correctly or not.

What i have to do,whether i should use loop and passes single value or there is any other way to check the Authorization.

Thanks

Saurabh

Hi

All

I have following code

start-of-selection.

authority-check object 'V_VBAK_VKO'

  • ID 'VKORG' FIELD P_VKORG

  • ID 'VTWEG' FIELD P_VTWEG

  • ID 'SPART' FIELD P_SPART

id 'VKORG' field s_vkorg

id 'VTWEG' field s_vtweg

id 'SPART' field s_spart

if sy-subrc ne c_0.

Message e999 with "No Authorization"

Endif

previously iwas using a single value(P_VKORG,P_VTWEG,P_SPART) in fields

but now my req has been changed to multiple values.

so plz tell whether my code will work correctly or not.

What i have to do,whether i should use loop and passes single value or there is any other way to check the Authorization.

Thanks

Saurabh

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
826

I don't think that select options will work here. You need to have single values when doing authority check.

You can loop at the select-options, but only if single values are allowed, no ranges, no exclusions. Make sense?

Regards,

Rich Heilman

Read only

Former Member
0 Likes
826

Hi ,

first u have to get the list of Sales Org based on the Input , after that u have to loop like this.

  • SELECT VKGRP

  • INTO TABLE I_AUTH_VKGRP

  • FROM TVKGR

  • WHERE VKGRP IN S_VKGRP.

*

  • LOOP AT I_AUTH_VKGRP.

  • AUTHORITY-CHECK OBJECT ''V_VBAK_VKO'

  • ID 'ACTVT' FIELD '03'

  • ID 'VKGRP' FIELD I_AUTH_VKGRP-VKGRP.

*

  • IF SY-SUBRC NE 0 .

  • MESSAGE E398(00) WITH

  • 'User'SY-UNAME'not authorised for Sales Group : ' I_AUTH_VKGRP-VKGRP.

ENDIF.

ENDLOOP.

*

Regards

Prabhu

Read only

Former Member
0 Likes
826

HI,

Your code works fine if ur select-options are with no extensions no -intervals.

AUTHORITY-CHECK OBJECT object

ID name1 FIELD f1

ID name2 FIELD f2

...

ID name10 FIELD f10.

REGARDS,

sAILAJA.

Read only

Former Member
0 Likes
826

Hi,

Usually in this case WE query the Check table of each field and make an internal table of it and then pass it to authority-check.

For ex: VKORG check table TVKO, similary for VTWEG and SPART it is TVTW and TSPA.

Hence do a select on these tables.

Select VKORG from TVTW

where VKORG in S_VKORG

into table t_vkorg.

Similarly store others in T_VTWEG and T_SPART.

Loop at T_VKORG.

Loop at T_VTWEG.

Loop at T_SPART.

Authority Check----

Store only the valid ones in another internal table.

endloop.

endloop.

endloop.

Read only

Former Member
0 Likes
826

Hi Saurabh,

You can code something similar to this


 SELECT * FROM MARA INTO ITAB_MARA
          WHERE MATNR IN S_MATNR
            AND ERDAT IN S_ERDAT.

  AUTHORITY-CHECK 'M_MATNR'
    ID 'MATNR' FIELD ITAB_MARA-MATNR
    ID 'ERDAT' FIELD ITAB_MARA-ERDAT.

  IF SY-SUBRC NE 0.
     MESSAGE e000 WITH 'BLAH BLAH'.
  ELSE.
   APPEND ITAB_MARA.
  ENDIF.
 
 ENDSELECT. 
 

This way the system will check all the values in the loop and you can also reterive the data in the same pass of the loop.

Cheers

VJ

Some points would be nice if it helped