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

AUTHORITY-CHECK OBJECT not working

Former Member
0 Likes
2,811

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

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,307

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

3 REPLIES 3
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,308

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

Read only

Former Member
0 Likes
1,307
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

Read only

Former Member
0 Likes
1,307

answered