ITPub博客

首页 > 应用开发 > IT综合 > 物料異動函數BAPI_GOODSMVT_CREATE的使用

物料異動函數BAPI_GOODSMVT_CREATE的使用

原创 IT综合 作者:tolyhuang 时间:2007-11-22 08:51:28 0 删除 编辑
收貨、發貨可使用BAPI_GOODSMVT_CREATE函數進行操作,具體操作代碼如下:[@more@]

data: gdsmt_header like bapi2017_gm_head_01.
data: gdsmt_code like bapi2017_gm_code.
data: gdsmt_item like bapi2017_gm_item_create occurs 0 with header line.
data: return like bapiret2 occurs 0.

clear: gdsmt_header, gdsmt_code, gdsmt_item, gdsmt_item[], return.

* Setup BAPI header data.
gdsmt_header-pstng_date = sy-datum.
gdsmt_header-doc_date = sy-datum.
gdsmt_code-gm_code = '01'. "01 - MB01 - Goods Receipts for Purchase Order

* Write 101 movement to table.
loop at it_tab_edit into itab.
move '101' to gdsmt_item-move_type.
move itab-matnr to gdsmt_item-material.
move itab-erfmg to gdsmt_item-entry_qnt.
move itab-meins to gdsmt_item-entry_uom.
move itab-werks to gdsmt_item-plant.
move itab-lgort to gdsmt_item-stge_loc.
move itab-ebeln to gdsmt_item-po_number.
move itab-ebelp to gdsmt_item-po_item.
move 'B' to gdsmt_item-mvt_ind.
* move 'X' to gdsmt_item-no_more_gr. "是否標識完成收貨

append gdsmt_item.
endloop.

if not gdsmt_item[] is initial.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gdsmt_header
goodsmvt_code = gdsmt_code
tables
goodsmvt_item = gdsmt_item
return = return.

call function 'BAPI_TRANSACTION_COMMIT' .
endif.

其中 gm_code 與 Tcode對應如下:

01 -- MB01
02 -- MB31
03 -- MB1A
04 -- MB1B
05 -- MB1C
06 -- MB11
07 -- MB04

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9437124/viewspace-983217/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 动名词
请登录后发表评论 登录
全部评论

注册时间:2010-07-22

  • 博文量
    268
  • 访问量
    1411193