‎2008 Aug 19 1:53 PM
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...
‎2008 Aug 19 1:59 PM
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
‎2008 Aug 19 1:59 PM
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
‎2008 Aug 19 2:07 PM
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
‎2008 Aug 21 12:34 PM
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
‎2008 Aug 21 12:53 PM
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