*&---------------------------------------------------------------------*
*& Report ZLM_TEST_023
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zlm_test_023.
TABLES: mkpf, imkpf, emkpf, likp.
DATA: BEGIN OF imseg OCCURS 0.
INCLUDE STRUCTURE imseg.
DATA: END OF imseg.
DATA: BEGIN OF emseg OCCURS 0.
INCLUDE STRUCTURE emseg.
DATA: END OF emseg.
PARAMETERS: lf_budat LIKE sy-datlo
DEFAULT sy-datlo OBLIGATORY,
lf_mjahr
LIKE mkpf-mjahr DEFAULT sy-datlo(4)
OBLIGATORY,
lf_mblnr
LIKE mkpf-mblnr OBLIGATORY,
lf_vbeln
LIKE likp-vbeln OBLIGATORY,
lf_test
TYPE c DEFAULT 'X'.
DATA: mblpo LIKE mseg-zeile.
SELECT SINGLE * FROM mkpf WHERE mblnr = lf_mblnr
AND mjahr = lf_mjahr
AND xblnr = lf_vbeln.
IF sy-subrc IS INITIAL.
CALL FUNCTION
'MB_CANCEL_GOODS_MOVEMENT'
EXPORTING
budat
= lf_budat
mblnr
= lf_mblnr
mblpo
= mblpo
mjahr
= lf_mjahr
tcode
= 'VL09'
called_by = 'VL09'
IMPORTING
emkpf
= emkpf
TABLES
emseg
= emseg
imseg
= imseg
EXCEPTIONS
OTHERS = 1.
*... No error found, then it will be posted
IF emkpf-subrc EQ 1.
IF lf_test IS
INITIAL.
CALL
FUNCTION 'MB_POST_GOODS_MOVEMENT'
EXPORTING
xblnr_sd = lf_vbeln
IMPORTING
emkpf
= emkpf
EXCEPTIONS
OTHERS =
0.
COMMIT WORK.
WRITE: / 'Goods movement was cancelled successfully with
document:',
emkpf-mblnr.
ELSE.
WRITE: / 'Testmode: Goods movement could be cancelled !'.
ENDIF.
ELSE.
*... otherwise write an error-log
LOOP AT emseg.
WRITE: /
emseg-msgid,
emseg-msgno,
emseg-msgty,
emseg-msgv1,
emseg-msgv2,
emseg-msgv3,
emseg-msgv4.
ENDLOOP.
WRITE: /
emkpf-msgid,
emkpf-msgno,
emkpf-msgty,
emkpf-msgv1,
emkpf-msgv2,
emkpf-msgv3,
emkpf-msgv4.
ENDIF.
ELSE.
WRITE: / 'Material document to reverse does
not exsist'.
ENDIF.