07-10-2012 9:17 AM
Hello Experts,
I put validations while posting invoice in MIRO tcode through badi "INVOICE_UPDATE",
I implemented method "CHANGE_AT_SAVE" .Now while posting invoice the following error is coming
Express document "Update was terminated" received from author "Administrator Admin.
When i deactivate the BADI ,the error is not coming .Where is the problem,
Please help me in this.
07-10-2012 9:25 AM
07-10-2012 9:41 AM
Look for hints in ST22 short dumps and SM13 canceled update requests, consult your system administrator, post relevant info here if you cannot solve it this way.
Thomas
07-10-2012 10:16 AM
Hi Shambu / Thomas,
thank u for giving immediate response.
This is the code,Please help me where i did a mistake.
method IF_EX_INVOICE_UPDATE~CHANGE_AT_SAVE.
DATA : WA_MSEG TYPE MSEG,
WA_RSEG TYPE mrmrseg ,
WA_MCHB TYPE MCHB.
DATA : TI_MRMRSEG TYPE TABLE OF MRMRSEG.
LOOP AT TI_RSEG_NEW INTO WA_RSEG.
IF ( WA_RSEG-MATNR GE '000000000000100000' AND WA_RSEG-MATNR LE '000000000000299999' ).
SELECT SINGLE * FROM MSEG INTO WA_MSEG
WHERE MBLNR = WA_RSEG-LFBNR AND MJAHR = WA_RSEG-LFGJA AND ZEILE = WA_RSEG-LFPOS.
IF SY-SUBRC EQ 0.
SELECT SINGLE * FROM MCHB INTO WA_MCHB
WHERE MATNR = WA_RSEG-MATNR AND WERKS EQ WA_MSEG-WERKS AND LGORT EQ WA_MSEG-LGORT AND CHARG EQ WA_MSEG-CHARG.
IF SY-SUBRC EQ 0.
IF ( WA_MCHB-CINSM > '0.0' OR WA_MCHB-CSPEM > '0.0' OR WA_MCHB-CVMSP > '0.0' ).
* IF WA_MSEG-INSMK NE ' '.
MESSAGE 'NOT ALLOWED TO POST INVOICE ' TYPE 'E'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
endmethod.
07-10-2012 10:28 AM
The badi document says - Note that no Commit work statement can be entered in this method.
Your message statement of type E triggers an Implicit Db commit when it interrupts the process.
The below part of the documentation will solve your problem:
ERROR_WITH_MESSAGE should be triggered if you want to prohibit creation of a logistics invoice document or changing of or deleting a parked document.
Note that this exception should only be triggered in conjunction with a system message (message xxx raising ERROR_WITH_MESSAGE).
07-10-2012 10:40 AM
Just checked some existing implementations in my system.
The messages were also captured in this manner:
INCLUDE mm_messages_mac.
IF SY-SUBRC EQ 0.
mmpur_message_forced 'E' 'M8' '462' '' '' '' ''.
ENDIF.
Please check it.
07-13-2012 11:22 AM
Hi Kesavadas,
Thank u for giving help ,
Can u give more details ?
Please help me in this.
07-13-2012 11:32 AM
All the details are already provided clearly. Please mention the point you did not understand.
07-13-2012 12:41 PM
Hi,
check this thread:
http://scn.sap.com/message/2679137#2679137
try to do something like:
MESSAGE e208(00) WITH 'NOT ALLOWED TO POST INVOICE'
RAISING error_with_message.
Best regards.
07-14-2012 10:58 AM
Hi Casamayor,
I applied what u told but the same error is coming , 'Update was terminated'
please help me in this.
07-15-2012 5:24 PM
Hi,
please go to SM13 and show us the content of ST22.
Otherwise it would be very difficult to help.
Best regards.
07-16-2012 6:35 AM
Hello,
What has been suggested by Kesav is correct and I think he has given explanation from the documentation as well. Would just add that the include mm_messages_mac contains the definition of macro mmpur_message_forced. We just call that macro from the method. We have to add the statement INCLUDE mm_messages_mac to call the macro. I assume you understand the term macro!
Regards,
Kumud
07-16-2012 10:00 AM