08-10-2010 10:08 AM
Hi,
Can we use COMMIT WORK statement in BADI? Hope its not advisable to use it.
I am using MB_MIGO_BADI~POST_DOCUMENT to update the GR Number in a custom table.
Sometimes the GR number is not getting updated in the custom table.
The modify statement given below does not updates the table sometime.
IF WA_ZMM_GATE_ENTRY-GR_NUMBER IS INITIAL.
WA_ZMM_GATE_ENTRY-REFERENCE = GS_EXDATA_HEADER-REFERENCE.
WA_ZMM_GATE_ENTRY-REFWERKS = GS_EXDATA_HEADER-WERKS.
WA_ZMM_GATE_ENTRY-GR_NUMBER = IS_MKPF-MBLNR.
WA_ZMM_GATE_ENTRY-GR_YEAR = IS_MKPF-MJAHR.
MODIFY ZMM_GATE_ENTRY FROM WA_ZMM_GATE_ENTRY .u201Dupdating the Z-table
ELSE.
MESSAGE E901(ZMM) WITH GS_EXDATA_HEADER-GATEENTRYNO WA_ZMM_GATE_ENTRY-GR_NUMBER.
ENDIF.
Is there any other option to replace the commit work in BADI?
Plz suggest...
Regards,
P.S.Chitra
Edited by: Chitra Karthik on Aug 10, 2010 11:19 AM
08-10-2010 10:42 AM
Hi,
I don't think even you do commit work it makes much difference and also Commit work also we can eliminate in the code.one more option is selecting the data from table to check whether it is updated or not.
IF WA_ZMM_GATE_ENTRY-GR_NUMBER IS INITIAL.
WA_ZMM_GATE_ENTRY-REFERENCE = GS_EXDATA_HEADER-REFERENCE.
WA_ZMM_GATE_ENTRY-REFWERKS = GS_EXDATA_HEADER-WERKS.
WA_ZMM_GATE_ENTRY-GR_NUMBER = IS_MKPF-MBLNR.
WA_ZMM_GATE_ENTRY-GR_YEAR = IS_MKPF-MJAHR.
MODIFY ZMM_GATE_ENTRY FROM WA_ZMM_GATE_ENTRY .u201Dupdating the Z-table
IF sy-subrc eq 0.
do.
select gr_number from ZMM_GATE_ENTRY where reference = GS_EXDATA_HEADER-REFERENCE.
if sy-subrc eq 0 and if gr_number is not initial. (record Found)-> means updated.
exit.
else.
MODIFY ZMM_GATE_ENTRY FROM WA_ZMM_GATE_ENTRY.
endif.
enddo.
endif.
ELSE.
MESSAGE E901(ZMM) WITH GS_EXDATA_HEADER-GATEENTRYNO WA_ZMM_GATE_ENTRY-GR_NUMBER.
ENDIF.
Regards,
Nagaraj
08-10-2010 11:27 AM
COMMIT WORK is strict NO in BAdI. It might abruptly terminate the current LUW which is definitely no desirable.
Check the method POST_DOCUMENT of the example implementation class CL_EXM_IM_MB_MIGO_BADI. In the example they're updating the tables MIGO_BADI_EXAMPL & MIGO_BADI_EXAMP2 in UPDATE TASK.
Hope this helps.
BR,
Suhas
08-10-2010 1:06 PM
Hi,
Try using Update and Insert statements instead of Modify Statement.
select gr_number from ZMM_GATE_ENTRY where reference = GS_EXDATA_HEADER-REFERENCE.
if sy-subrc = 0.
Update
else.
Insert
endif.
Thanks,
Venkat
08-10-2010 1:12 PM
Hi,
NO NEED OF COMMIT IN BADI.
The standard transaction will take care of the commit work.
Thanks
Sabu