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

Selection option authorization

Former Member
0 Likes
4,129

Hi,

in my program i have provided below selection option.

SELECT-OPTIONS: s_vkorg FOR zcrm_r3-vkorg NO INTERVALS OBLIGATORY .

now i want to populate values in s_vkorg on the basis of authorization. e.g. if particular user is not having authorization to company code '2000' then in s_vkorg company code '2000' should not appear at all.

Can you please help me in how to add authorization based population of selection options?

Regards,

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,063

Build the range, from a

SELECT * FROM TVKO.

Execute an authority check like (find an adequate object to check via transactions SU20, search VKORG or BUKRS) and SU21 on object that use those fields.)

AUTHORITY-CHECK OBJECT 'V_KNA1_VKO'
         ID 'VKORG' FIELD tvko-vkorg
         ID 'VTWEG' DUMMY
         ID 'SPART' DUMMY
         ID 'ACTVT' DUMMY.
" or/and
AUTHORITY-CHECK OBJECT 'V_AKKP_ART'
         ID 'AKKTP' DUMMY
         ID 'AKKRT' DUMMY
         ID 'BUKRS' FIELD tvko-bukrs
         ID 'ACTVT' DUMMY.

and then on authorized values build the range

s_vkorg-sign = 'I'.
s_vkorg-option = 'EQ'.
s_vkorg-low = tvko-vkorg.
APPEND s_vkorg.

Regards,

Raymond

3 REPLIES 3
Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,064

Build the range, from a

SELECT * FROM TVKO.

Execute an authority check like (find an adequate object to check via transactions SU20, search VKORG or BUKRS) and SU21 on object that use those fields.)

AUTHORITY-CHECK OBJECT 'V_KNA1_VKO'
         ID 'VKORG' FIELD tvko-vkorg
         ID 'VTWEG' DUMMY
         ID 'SPART' DUMMY
         ID 'ACTVT' DUMMY.
" or/and
AUTHORITY-CHECK OBJECT 'V_AKKP_ART'
         ID 'AKKTP' DUMMY
         ID 'AKKRT' DUMMY
         ID 'BUKRS' FIELD tvko-bukrs
         ID 'ACTVT' DUMMY.

and then on authorized values build the range

s_vkorg-sign = 'I'.
s_vkorg-option = 'EQ'.
s_vkorg-low = tvko-vkorg.
APPEND s_vkorg.

Regards,

Raymond

Read only

Former Member
0 Likes
3,063

i have added below code in INITIALIZATION. it is not working.

DATA : it_tvko TYPE table of tvko with header line.

SELECT * FROM tvko INTO TABLE it_tvko.

AUTHORITY-CHECK OBJECT 'ZDISBURSAL' ID 'VKORG' FIELD it_tvko-vkorg.

IF sy-subrc = 0.

s_vkorg-sign = 'I'.

s_vkorg-option = 'EQ'.

s_vkorg-low = it_tvko-vkorg.

APPEND s_vkorg.

ENDIF.

ENDSELECT.

Read only

0 Likes
3,063

It is even not syntaxically correct, try :

DATA : it_tvko TYPE TABLE OF tvko.
FIELD-SYMBOLS <tvko> TYPE LINE OF it_tvko.
* read whole table
SELECT * FROM tvko INTO TABLE it_tvko.
* Initialize 
REFRESH s_vkorg.
* loop at extracted records
LOOP AT it_tvko ASSIGNING <tvko>.
* - check authorization
  AUTHORITY-CHECK OBJECT 'ZDISBURSAL' " this one i cannot test
           ID 'VKORG' FIELD <tvko>-vkorg.
  CHECK sy-subrc EQ 0.
* - if passed, append to range
  CLEAR s_vkorg.
  s_vkorg-sign = 'I'.
  s_vkorg-option = 'EQ'.
  s_vkorg-low = <tvko>-vkorg.
  APPEND s_vkorg.
ENDLOOP.

Regards,

Raymond