We can help. Together we learn....

MIRO -

by Voice | Friday, January 14, 2011 in | comments (0)

If you want to mimic the quantity shown in MIRO (transaction) while posting incoming invoice, you need to use the following function module


CALL FUNCTION 'MRM_ASSIGNMENT'
EXPORTING
i_display = v_display
ti_drseg_old = i_drseg
TABLES
t_drseg = ti_drseg
t_rbselbest = ti_rbselbest
t_rbsellifs = ti_rbsellifs
t_rbselfrbr = ti_rbselfrbr
t_rbselwerk = ti_rbselwerk
t_rbselerfb = ti_rbselerfb
t_errprot = ti_errprot
t_ebelntab = ti_ebelntab
CHANGING
c_rbkpv = w_rbkpv
t_limit = w_limit.
IF sy-subrc = 0.
IF ti_errprot[] IS INITIAL AND ti_drseg[] IS NOT INITIAL.

LOOP AT ti_drseg ASSIGNING w_drseg WHERE koart = c_koart_initial.
w_drseg-tbtkz = w_rbkpv-tbtkz.
CALL FUNCTION 'MRM_AMOUNT_QUANTITY_PROPOSE_N'
EXPORTING
i_rbkpv = w_rbkpv
CHANGING
c_drseg = w_drseg .
ENDLOOP. "
ENDIF. "
ENDIF. "

Suppose we have a standard SAP function module issuing an error message because of invalid input data. Now if we are calling this function module from any custom conversion program and such an error message is issued by the function module, the entire processing would stop and program would terminate displaying this error message. In case of a background job, it would also show an error and abruptly stop.

In order to handle such scenarios, we can provide an additional parameter in the function module exception called 'ERROR_MESSAGE' and give a sy-subrc value to it. This should be before the normal OTHERS parameter.

Now when the error is issued in the function module, the program doesn't terminate immediately. But the SAP function module returns with the SY-SUBRC value corresponding to the ERROR_MESSAGE exception.

Also the error message details can be found in the standard system message fields (SYST structure) and can be used by the custom program to populate any processing log / report.

Categories