TCODE
MR8M
DEMO
REPORT zlm_mr8m.
PARAMETERS p_inv LIKE bapi_incinv_fld-inv_doc_no.
DATA lv_invoicedocnumber_reversal LIKE bapi_incinv_fld-inv_doc_no.
DATA lt_return LIKE TABLE OF bapiret2.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CANCEL'
EXPORTING
invoicedocnumber = p_inv
fiscalyear = '2018'
reasonreversal = '01'
* POSTINGDATE =
IMPORTING
invoicedocnumber_reversal = lv_invoicedocnumber_reversal
* FISCALYEAR_REVERSAL =
TABLES
return = lt_return.
.
READ TABLE lt_return TRANSPORTING NO FIELDS
WITH KEY type = 'E'.
IF sy-subrc = 0.
WRITE 'Error'.
ELSE.
WRITE lv_invoicedocnumber_reversal.
COMMIT WORK AND WAIT .
ENDIF.