本文主要是介绍MB1A bapi测试,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
* BAPI_TEST FOR MB1A
*& T158G 有具体的代码与事物码对应关系
* GMCODE 01 - MB01 - Goods Receipts for Purchase Order
* 02 - MB31 - Goods Receipts for Prod Order
* 03 - MB1A - Goods Issue
* 04 - MB1B - Transfer Posting
* 05 - MB1C - Enter Other Goods Receipt
* 06 - MB11
* B - Goods movement for purchase order
* F - Goods movement for production order
* L - Goods movement for delivery note
* K - Goods movement for kanban requirement (WM - internal only)
* O - Subsequent adjustment of "material-provided" consumption
* W - Subsequent adjustment of proportion/product unit material
*
REPORT zbapi_mb1a_test.
DATA: BEGIN OF gmhead.
INCLUDE STRUCTURE bapi2017_gm_head_01.
DATA: END OF gmhead.
DATA: BEGIN OF gmcode.
INCLUDE STRUCTURE bapi2017_gm_code.
DATA: END OF gmcode.
DATA: BEGIN OF mthead.
INCLUDE STRUCTURE bapi2017_gm_head_ret.
DATA: END OF mthead.
DATA: BEGIN OF itab OCCURS 100.
INCLUDE STRUCTURE bapi2017_gm_item_create.
DATA: END OF itab.
DATA: BEGIN OF errmsg OCCURS 10.
INCLUDE STRUCTURE bapiret2.
DATA: END OF errmsg.
DATA: wmenge LIKE iseg-menge,
documnet_num LIKE mseg-mblnr.
START-OF-SELECTION.
gmhead-pstng_date = sy-datum.
gmcode-gm_code = '03'.
itab-move_type = '261'.
itab-plant = '1000'.
itab-material = '5010-04577'.
itab-entry_qnt = 1.
itab-reserv_no = '0035677912'.
itab-res_item = '1515'.
itab-stge_loc = 'K100'.
APPEND itab.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = gmhead
goodsmvt_code = gmcode
goodsmvt_headret = mthead
IMPORTING
materialdocument = documnet_num
TABLES
goodsmvt_item = itab
return = errmsg.
LOOP AT errmsg WHERE type = 'E' OR
type = 'A'.
WRITE:/ errmsg-message.
ENDLOOP.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
WRITE: documnet_num.
ENDIF.
这篇关于MB1A bapi测试的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!