on 04-28-2009 8:29 AM
Hi,
I want to give authorization as per the item category of Sales document.
I did the following steps
SU21 created the object with the following field
pstyv item category
vkorg sales organisayion
and the obejct in a role with PFCG transaction.
What else i need to do ?
Regards,
SATYA
Hi Satya,
Write a small code as mentioned below:
AUTHORITY-CHECK OBJECT 'ZSD_PSTYV'
ID 'PSTYV' FIELD XVBAP-PSTYV
at MV45AFZZ, form UserExit_Save_Document_Prepare : In case you want to check authorization at the time of save, this would allow users to manually change item category if required and will stop saving sales order.
Or
you can write at USEREXIT_CHECK_VBAP in MV45AFZB.
One of this should work.
Regards,
Naveen Aggarwal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
AUTHORIZATION CHECK ON ITEM CATEGORY
SD Functional Analyst Adi Mogilevsky
DATA: lv_PSTYY TYPE VBAP-PSTYY.
IF SVBAP-TABIX GT 0 AND
*VBAP-PSTYY NE VBAP-PSTYY.
AUTHORITY-CHECK OBJECT 'Z_SO_IC_AUT'
ID 'ZPSTYY' FIELD VBAP-PSTYY
ID 'ACTVT' FIELD '02'.
IF sy-subrc NE 4.
*VBAP-PSTYY = LF_PSTYY.
ELSE.
MESSAGE 'You do not have authorization to change Item Category' .' TYPE 'I'.
VBAP-PSTYY = *VBAP-PSTYY.
ENDIF.
ENDIF.
>
> * AUTHORIZATION CHECK ON ITEM CATEGORY
> * SD Functional Analyst Adi Mogilevsky
> * www.sapist.com
> DATA: lv_PSTYY TYPE VBAP-PSTYY.
>
> IF SVBAP-TABIX GT 0 AND
> *VBAP-PSTYY NE VBAP-PSTYY.
>
> AUTHORITY-CHECK OBJECT 'Z_SO_IC_AUT'
> ID 'ZPSTYY' FIELD VBAP-PSTYY
> ID 'ACTVT' FIELD '02'.
> IF sy-subrc NE 4.
> * *VBAP-PSTYY = LF_PSTYY.
> ELSE.
> MESSAGE 'You do not have authorization to change Item Category' .' TYPE 'I'.
> VBAP-PSTYY = *VBAP-PSTYY.
> ENDIF.
> ENDIF.
That is wrong. An authority check is satisfied if sy-subrc = 0. All other return codes need to be reacted to.
Very bad habit and programming technique! (in addition to the fact that it makes little sense...)
Cheers,
Julius
@ SATYA: You need to find where you want this AUTHORITY-CHECK (and how to react to it).
Little tip: An object without coding using it is a mime in a forest.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
14 | |
10 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.