12-25-2013 12:51 PM
Hi All,
i have to apply user exit on VA02, if user changes reason for rejection field.
Can you tell me please , on which userexit i have to use.
12-25-2013 12:53 PM
Hi Shweta,
you have to put your code in
FORM USEREXIT_SAVE_DOCUMENT
alternately you can hard cord BREAK your user id, in each exit, and run VA02
you have to do what you wants, upon saving it will stops on a particular code
that is your required USEREXIT..
12-25-2013 12:53 PM
Hi Shweta,
you have to put your code in
FORM USEREXIT_SAVE_DOCUMENT
alternately you can hard cord BREAK your user id, in each exit, and run VA02
you have to do what you wants, upon saving it will stops on a particular code
that is your required USEREXIT..
12-30-2013 12:46 PM
Hi Sanjeev , Venkateswaran,
i have to provide some restrictions in VA01 and VA02 ,
which will be based on some order type, if a material has been created
and against of that material if a sales order already exists, then it will
gives a error message, and restricts to create another sales order for that
material.
Please provide some code help, because i am not getting how to do that.
12-30-2013 1:01 PM
Hi Shweta,
please write your code logic as shown below, please change it as per as your requirements.
TYPES: BEGIN OF ITAB,
VBELN TYPE VBAP-VBELN,
MATNR TYPE VBAP-MATNR,
END OF ITAB.
DATA: ITAB1 TYPE STANDARD TABLE OF ITAB,
ITAB2 TYPE STANDARD TABLE OF ITAB,
WA_ITAB TYPE ITAB.
IF SY-TCODE = 'VA01' OR SY-TCODE = 'VA02'.
IF VBAK-AUART EQ 'your order type' OR VBAK-AUART EQ 'your order type'
SELECT VBELN MATNR FROM VBAP INTO TABLE ITAB1
WHERE VBELN = VBAP-VBELN.
(Please provide all the details for which, means conditions for which you wants
to restricts creation of new sales order if any sales order already exists for a material).
Please change this code as per your needs.
IF SY-SUBRC EQ 0.
LOOP AT ITAB1 INTO WA_ITAB .
SELECT VBELN MATNR FROM VBAP INTO TABLE ITAB2
WHERE MATNR EQ WA_ITAB-MATNR
AND VBELN NE WA_ITAB-VBELN.
IF SY-SUBRC EQ 0.
MESSAGE 'This material is already used' TYPE 'E'.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
12-30-2013 1:54 PM
Hi Shweta -
Instead of checking on transaction code like VA01, VA02 its better to check on the transaction type. For that you need to check the value T180-TRTYP.
If you are using form FORM USEREXIT_SAVE_DOCUMENT in MV45AFZZ then put your first check on this.
1. IF T180-TRTYP = 'H' OR T180-TRTYP = V'.
* Your code
ENDIF.
2. If you have a check on order type, please check the field VBAK-AUART with the order type you have.
This is your second check.
3. Now if you want to check the sales order which all are created for the material, take the index table
VAPMA (this will be faster) based on the material in XVBAP internal table
Now retrieve MATNR, VBELN from table VAPMA and strore in an internal table IT_VAPMA.
4. Loop over the internal table XVBAP and check if there is an entry in the corresponding internal tale IT_VAPMA. If yes, you handle error.
Let us know, in case any further help.
Regards,
Atul Mohanty
12-31-2013 7:33 AM
Hi Sanjeev,
thanks a lot for helping me, but i am facing problems.
I have Sales document type, ZSTP, ZSTD, ZSTN and ZSPL
and also if item category is of type ZPLM, (from vbap table)
because of this condition i am not able to fetch data, please help me
how could i fetch data from vbap (item level) based on these conditions.
12-31-2013 7:54 AM
Hi Shweta,
just change previous code as shown below, you have to provide the additional code
shown in dark.
TYPES: BEGIN OF ITAB,
VBELN TYPE VBAP-VBELN,
MATNR TYPE VBAP-MATNR,
PSTYV TYPE VBAP-PSTYV,
END OF ITAB.
IF SY-TCODE = 'VA01' OR SY-YCODE = 'VA02'.
IF VBAK-AUART EQ 'ZSTP' OR VBAK-AUART EQ 'ZSTD' OR VBAK-AUART EQ 'ZSTN' OR VBAK-AUART EQ 'ZSPL'.
SELECT VBELN MATNR FROM VBAP INTO TABLE ITAB1
WHERE VBELN = VBAP-VBELN
and pstyv = 'ZPLM'.
IF SY-SUBRC EQ 0.
LOOP AT ITAB1 INTO WA_ITAB .
SELECT VBELN MATNR FROM VBAP INTO TABLE ITAB2
WHERE MATNR EQ WA_ITAB-MATNR
AND VBELN NE WA_ITAB-VBELN
and pstyv = 'ZPLM'.
IF SY-SUBRC EQ 0.
MESSAGE 'This material is already used' TYPE 'E'.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
12-31-2013 8:04 AM
Just a small corrections
TYPES: BEGIN OF ITAB,
VBELN TYPE VBAP-VBELN,
MATNR TYPE VBAP-MATNR,
PSTYV TYPE VBAP-PSTYV,
END OF ITAB.
IF SY-TCODE = 'VA01' OR SY-YCODE = 'VA02'.
loop at XVBAK whereAUART EQ 'ZSTP' OR VBAK-AUART EQ 'ZSTD' OR VBAK-AUART EQ 'ZSTN' OR VBAK-AUART EQ 'ZSPL'.
loop at xvbap where vbeln eq xvbak-vbeln and pstyv eq ZPLM.
select *
up to 1 rows from vbap where matnr eq xvbap-matnr.
if sy-subrc eq 0 "Means sales order for this material exist
display error
endif
endloop.
endloop.
12-31-2013 8:46 AM
Hi Nabheet,
thanks a lot if you have corrected my code. but
its not my issue, problem was raised by Shweta chouhan.
12-31-2013 9:10 AM
Hi Sanjeev,
with some changes i have got my issue resolved.
Thanks a lot
12-25-2013 12:56 PM
Hi Shweta,
Use the Exit - MV45AFZZ
Inside it, you will find a form - FORM USEREXIT_SAVE_DOCUMENT
You can use this exit.
Regards,
Venkat
12-31-2013 5:41 AM
Hi Shwetha,
These are some one.
MV45AFZZ , Form is USEREXIT_MOVE_FIELD_TO_VBAK .
This Form will be triggered when we change the value.
MV45AFZZ , Form is USEREXIT_SAVE_DOCUMENT_PREPARE.
This Form will be triggered when we Save the Document.
Regards,
Kishore Kumar G.