2010 Apr 23 10:52 AM
Hi,
I have to provide authorization check for Sale Order program. The User enters Saleorder no on the Selection Screen. If the Saleorder no and the User belongs to different Sales Org and Division then it should generate an error 'No Authorization for this SaleOrder'.I used Authority Object statement but its not working. Please help in resolving the issue.
PARAMETERS : P_ORDER TYPE VBAK-VBELN.
AT SELECTION-SCREEN.
PERFORM S_AUTHORITY_CHECK.
FORM S_AUTHORITY_CHECK .
SELECT SINGLE VKORG
SPART FROM VBAK INTO (VKORG,SPART)
WHERE VBELN = P_ORDER.
AUTHORITY-CHECK OBJECT 'V_VBAK_VKO' FOR USER SY-UNAME
ID 'VKORG' FIELD VKORG
ID 'SPART' FIELD SPART.
IF SY-SUBRC <> 0.
MESSAGE 'NO AUTHORISATION' TYPE 'E'.
ENDIF.
ENDFORM. " S_AUTHORITY_CHECK
The User belongs to SalesOrg '4000' and SalesOrder belongs to '3000' but giving SY-SUBRC = 0.
Regards
K Srinivas
2010 Apr 23 11:07 AM
From the code snippet you have posted, you are not checking the activity field (ACTVT).
>
> The User belongs to SalesOrg '4000' and SalesOrder belongs to '3000' but giving SY-SUBRC = 0.
I am not sure what you mean by "belongs", but ideally the user should/should not be authorised to perform certain activity for the sales org.
Hope i am making some sense.
BR,
Suhas
Hi,
I have to provide authorization check for Sale Order program. The User enters Saleorder no on the Selection Screen. If the Saleorder no and the User belongs to different Sales Org and Division then it should generate an error 'No Authorization for this SaleOrder'.I used Authority Object statement but its not working. Please help in resolving the issue.
PARAMETERS : P_ORDER TYPE VBAK-VBELN.
AT SELECTION-SCREEN.
PERFORM S_AUTHORITY_CHECK.
FORM S_AUTHORITY_CHECK .
SELECT SINGLE VKORG
SPART FROM VBAK INTO (VKORG,SPART)
WHERE VBELN = P_ORDER.
AUTHORITY-CHECK OBJECT 'V_VBAK_VKO' FOR USER SY-UNAME
ID 'VKORG' FIELD VKORG
ID 'SPART' FIELD SPART.
IF SY-SUBRC <> 0.
MESSAGE 'NO AUTHORISATION' TYPE 'E'.
ENDIF.
ENDFORM. " S_AUTHORITY_CHECK
The User belongs to SalesOrg '4000' and SalesOrder belongs to '3000' but giving SY-SUBRC = 0.
Regards
K Srinivas
2010 Apr 23 11:07 AM
From the code snippet you have posted, you are not checking the activity field (ACTVT).
>
> The User belongs to SalesOrg '4000' and SalesOrder belongs to '3000' but giving SY-SUBRC = 0.
I am not sure what you mean by "belongs", but ideally the user should/should not be authorised to perform certain activity for the sales org.
Hope i am making some sense.
BR,
Suhas
2010 Apr 23 11:29 AM
PARAMETERS : P_ORDER TYPE VBAK-VBELN.
AT SELECTION-SCREEN.
PERFORM S_AUTHORITY_CHECK.
FORM S_AUTHORITY_CHECK .
SELECT SINGLE VKORG
SPART FROM VBAK INTO (VKORG,SPART)
WHERE VBELN = P_ORDER.
AUTHORITY-CHECK OBJECT 'V_VBAK_VKO' FOR USER SY-UNAME
ID 'VKORG' FIELD VKORG
ID 'SPART' FIELD SPART.
ID 'ACTVT' FIELD '03'. <--------- "display only
IF sy-subrc NE 0.
MESSAGE zzz 'No authorization for sales order'.
LEAVE LIST-PROCESSING.
endif.
ENDFORM. " S_AUTHORITY_CHECK
2010 Apr 23 12:20 PM