FORM frm_good_cancle USING mblnr
TYPE mblnr
new_mblnr TYPE mblnr
u_date
TYPE sy-datum.
DATA: li_goodsmvt_headret
TYPE bapi2017_gm_head_ret,
li_goodsmvt_matdocitem TYPE TABLE OF bapi2017_gm_item_04 WITH HEADER LINE.
DATA: i_return
TYPE TABLE OF bapiret2 WITH HEADER LINE.
CALL FUNCTION 'BAPI_GOODSMVT_CANCEL'
EXPORTING
materialdocument
= mblnr
"物料凭证
matdocumentyear
= u_date(4)
"年
goodsmvt_pstng_date = u_date
goodsmvt_pr_uname
= sy-uname
IMPORTING
goodsmvt_headret
= li_goodsmvt_headret
TABLES
return
= i_return
goodsmvt_matdocitem = li_goodsmvt_matdocitem.
new_mblnr = li_goodsmvt_headret-mat_doc. "新生成的凭证
LOOP AT i_return WHERE type = ‘E'.
ENDLOOP.
IF sy-subrc = 0.
ENDIF.
endform.