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

Authorization object

Former Member
0 Likes
1,102

Hi

i have an authorization object that i need to implement in a specific reporting program

on the selection screen there is a select option on company code.

the authorization object to implement is to allow user to execute the programes for a specific country company code only.

Please advise...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
884

check below code

FORM authority_check.

  • Check Authority

AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'

ID 'VKORG' FIELD p_vkorg

ID 'VTWEG' FIELD p_vtweg

ID 'SPART' FIELD p_spart

ID 'ACTVT' FIELD '03'.

IF sy-subrc <> 0.

MESSAGE e000(zs) WITH 'No Authorization'(021).

ENDIF.

ENDFORM. " authority_check

4 REPLIES 4
Read only

Former Member
0 Likes
885

check below code

FORM authority_check.

  • Check Authority

AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'

ID 'VKORG' FIELD p_vkorg

ID 'VTWEG' FIELD p_vtweg

ID 'SPART' FIELD p_spart

ID 'ACTVT' FIELD '03'.

IF sy-subrc <> 0.

MESSAGE e000(zs) WITH 'No Authorization'(021).

ENDIF.

ENDFORM. " authority_check

Read only

RaymondGiuseppi
Active Contributor
0 Likes
884

You may try something like

AT SELECTION-SCREEN ON so-bukrs.
  SELECT * INTO TABLE it_t001
    FROM t001
    WHERE bukrs IN so-bukrs.
  IF it_t001[] IS INITIAL.
    " Message no data exists
  ENDIF.
  LOOP AT it_t001 INTO t001.
    AUTHORITY-CHECK OBJECT 'S_IWB'
      ID 'COUNTRY' FIELD t001-land1
      ID 'ACTVT' FIELD '03'.
    IF sy-subrc NE 0.
      DELETE it_t001.
    ENDIF.
  ENDLOOP.
  IF it_t001[] IS INITIAL.
    " Message no data allowed
  ENDIF.

Regards

Read only

0 Likes
884

in your example can we instead of doing a loop in the t001 table can we just put

in the authorization ID 'BUKRS' FIELD SO_BUKRS

Read only

0 Likes
884

I don't think this may work well, the check will use the value of the work area (1st record) of the select-option. e.g. society XXX, the value looks like IEQXXX.... wont work. (imagine with Exclusion records...)

So i prefer to "solve" the select-option, by executing the selection and then filter the results.

For performance (many societies ?) you may perform the check after checking that user has requested an execution and not pressed ENTER

CHECK sscrfields-ucomm EQ 'ONLI' OR sscrfields-ucomm EQ 'PRIN'.

Regards