06-09-2011 1:45 PM
Hi,
I am using user exit USEREXIT_SAVE_DOCUMENT_PREPARE(MV45AFZZ) to check the return order quantity with respect to billing quantity. If the return order is more than invoiced quantity ( Item Level ) ,I am raising an error message. But after the error message the screen becomes totally inactive so that we cannot correct anything in the screen. Please advice.
I have already tried the exits USEREXIT_MOVE_FIELD_TO_VBAP(MV45AFZZ) & USEREXIT_CHECK_VBAP(MV45AFZB),but the problem of these exit are we cann't take multtiple order for the same Invoice.
Regards
Aromal R
06-09-2011 4:23 PM
Hi,
For the error handling, try to use the following piece of code format.
* Raise a message and stay where you are
MESSAGE s899(v1) WITH 'Error Message'.
PERFORM folge_gleichsetzen(saplv00f).
fcode = 'ENT1'.
SET SCREEN syst-dynnr.
LEAVE SCREEN.
Regards,
Harish
06-09-2011 4:23 PM
Hi,
For the error handling, try to use the following piece of code format.
* Raise a message and stay where you are
MESSAGE s899(v1) WITH 'Error Message'.
PERFORM folge_gleichsetzen(saplv00f).
fcode = 'ENT1'.
SET SCREEN syst-dynnr.
LEAVE SCREEN.
Regards,
Harish
06-10-2011 5:07 AM
Dear harish,
I changed the error message to Information message with your code. Its working. Thank you.
Regards
Aromal R
Edited by: aromalr on Jun 10, 2011 6:10 AM
04-12-2012 1:10 PM
Hi Raveendran,
I am having the same requirement , to check the return order quantity in va01 .
I am using USEREXIT_SAVE_DOCUMENT_PREPARE but my code was not working , Kindly help on this issue .
Regards,
k.rajesh
04-12-2012 3:57 PM
Dear Rajesh,
Here is the code.
IF vbak-auart = 'ZREC' .
DATA: lv_menge TYPE kwmeng.
DATA: lv_fkimg TYPE fkimg.
DATA: lv_kwmenge TYPE kwmeng.
DATA: lv_tmpqty TYPE kwmeng.
DATA: lt_vbap TYPE TABLE OF vbap.
DATA: lt_vbrp TYPE TABLE OF vbrp.
DATA: ls_vbrp TYPE TABLE OF vbrp.
DATA: lt_vbap1 TYPE TABLE OF vbap,
lt_vgbel TYPE TABLE OF vbap,
ls_vgbel TYPE vbap,
ls_vbap TYPE vbap,
ls_vbap1 TYPE vbap.
lt_vbap[] = xvbap[].
lt_vgbel[] = lt_vbap[] .
SORT lt_vgbel BY vgbel vgpos.
DELETE ADJACENT DUPLICATES FROM lt_vgbel COMPARING vgbel vgpos .
LOOP AT lt_vgbel INTO ls_vgbel.
CLEAR: lv_fkimg,lv_menge,lv_kwmenge,lv_tmpqty.
SELECT SINGLE fkimg INTO lv_fkimg
FROM vbrp " Item Total Qty
WHERE vbeln = ls_vgbel-vgbel
AND posnr = ls_vgbel-vgpos.
CLEAR: lt_vbap1,ls_vbap1.
IF sy-tcode = 'VA01'.
select * into table lt_vbap1 from vbap
where VGBEL = ls_vgbel-vgbel
and vgpos = ls_vgbel-vgpos.
ELSE.
select * into table lt_vbap1 from vbap
where VGBEL = ls_vgbel-vgbel
and vgpos = ls_vgbel-vgpos
AND VBELN NE ls_vgbel-vbeln.
ENDIF.
LOOP AT lt_vbap1 INTO ls_vbap1.
lv_menge = lv_menge + ls_vbap1-kwmeng .
ENDLOOP.
LOOP AT lt_vbap INTO ls_vbap WHERE vgbel = ls_vgbel-vgbel
AND vgpos = ls_vgbel-vgpos .
lv_kwmenge = lv_kwmenge + ls_vbap-kwmeng.
CLEAR lv_tmpqty.
lv_tmpqty = lv_kwmenge + lv_menge.
IF lv_tmpqty > lv_fkimg.
MESSAGE i398(00) WITH 'Return Qty exceeding Billed Qty ->Item:' ls_vbap-posnr.
PERFORM folge_gleichsetzen(saplv00f).
fcode = 'ENT1'.
SET SCREEN syst-dynnr.
LEAVE SCREEN.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.
04-14-2012 5:24 AM
Dear Raveendran,
Thanks for your immediate response.
Regards,
K.rajesh