101 采购收货(无物料验收) migo过账 demo
goodsmvt_header-pstng_date = ls_item_req_header-budat.
goodsmvt_header-doc_date = ls_item_req_header-doc_date.
goodsmvt_header-pr_uname = sy-uname.
goodsmvt_header-header_txt = ls_item_req_header-zoaid.
goodsmvt_code = '01'.
CLEAR:ls_goodsmvt_item.
ls_goodsmvt_item-move_type = '101'. "移动类型
ls_goodsmvt_item-po_number = |{ ls_item_req_item-ebeln ALPHA = IN }|. "采购凭证号
ls_goodsmvt_item-po_item = |{ ls_item_req_item-ebelp ALPHA = IN }| . "采购凭证的项目编号
ls_goodsmvt_item-mvt_ind = 'B'. "移动标识 ’B‘为采购收货 ’F ' 生产收货
ls_goodsmvt_item-entry_qnt = ls_item_req_item-menge.
CLEAR lw_txz01. "20230315-yuchengyi-add
SELECT SINGLE txz01 INTO lw_txz01 FROM ekpo WHERE ebeln = ls_goodsmvt_item-po_number AND ebelp = ls_goodsmvt_item-po_item.
ls_goodsmvt_item-item_text = ls_item_req_header-zoaid && '//' && lw_txz01.
APPEND ls_goodsmvt_item TO goodsmvt_item.
IF goodsmvt_item[] IS NOT INITIAL.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = goodsmvt_header
goodsmvt_code = goodsmvt_code
IMPORTING
materialdocument = materialdocument
matdocumentyear = matdocumentyear
TABLES
goodsmvt_item = goodsmvt_item[]
return = return[].
LOOP AT return INTO ls_return WHERE type = 'E'.
lv_error = 'E'.
ENDLOOP.
IF lv_error = 'E'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
ENDIF.