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: 

authorization control

Former Member
0 Kudos
233

Hi! Expert,


below is the code to get data for the authorized sales organization. I only put s110 as not authorized, but, why when i execute the program, all sales org. are not authorized?

Kindly need ur help to solve it.



FORM get_data.

           SELECT  KNA1~KUNNR

                   KNA1~NAME1

                   KNA1~STRAS

                   KNVV~ZTERM

                   KNVV~VKORG

                   KNVV~VTWEG

                   KNVV~SPART

                   TVTWT~VTEXT

                   TVZBT~VTEXT

                   TVKOT~VTEXT

           INTO TABLE it_output

           FROM KNA1

           INNER JOIN KNVV

           ON KNVV~KUNNR = KNA1~KUNNR

           INNER JOIN TVTWT

           ON TVTWT~VTWEG = KNVV~VTWEG

           INNER JOIN TVZBT

           ON TVZBT~ZTERM = KNVV~ZTERM

           INNER JOIN TVKOT

           ON TVKOT~VKORG = KNVV~VKORG

           WHERE KNA1~KUNNR IN s_kunnr.

IF sy-subrc EQ 0.

   CLEAR S_VKORG.    REFRESH S_VKORG.

LOOP AT IT_OUTPUT.

   AUTHORITY-CHECK OBJECT 'Z_VKORG'

   ID 'VKORG' FIELD S_VKORG

   ID 'ACTVT' FIELD '03'.


   IF sy-subrc = 0.

     S_VKORG-sign = 'I'.

     S_VKORG-option = 'EQ'.

     S_VKORG-low = ITAB.

     S_VKORG-high = space.


     APPEND S_VKORG.

     ELSE.

         MESSAGE e014(zmsg) WITH 'not authorize'.

 

    ENDIF.

ENDLOOP.

ENDIF.

ENDFORM.


Thanks and Regards

Liyana

2 REPLIES 2

Former Member
0 Kudos
135

Change your code to below

LOOP AT IT_OUTPUT.

   AUTHORITY-CHECK OBJECT 'Z_VKORG'

   ID 'VKORG' FIELD IT_OUTPUT-VKORG

   ID 'ACTVT' FIELD '03'.

archanapawar
Contributor
0 Kudos
135

Hi Liyana,

You are passing wrong parameter to your authorization object. You are passing S_VKORG.

You have fetched the data from KNA1 and KNVV based on S_VKORG, so you can use this table to check authorization for VKORG.

Modify your code as below, it will work.

LOOP AT IT_OUTPUT into WA_OUTPUT.

   AUTHORITY-CHECK OBJECT 'Z_VKORG'

   ID 'VKORG' FIELD WA_OUTPUT-VKORG

   ID 'ACTVT' FIELD '03'.


   IF sy-subrc = 0.

     S_VKORG-sign = 'I'.

     S_VKORG-option = 'EQ'.

     S_VKORG-low = ITAB.

     S_VKORG-high = space.


     APPEND S_VKORG.

     ELSE.

         MESSAGE e014(zmsg) WITH 'not authorize'.

    ENDIF.

ENDLOOP.