前台可以通过MB1B实现物料移动,下面是特殊库存移动(需要输入‘E'),
回车后,输入销售订单,行项目,对应的物料,数量,然后保存实现物料转移。
此过程,可调用BAPI ‘BAPI_GOODSMVT_CREATE’实现。
完整代码:
注意:如果不是特殊库存物料移动,则不用输入’E'和对应的销售订单和行项目。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
REPORT z_goods_mov. DATA:lit_return LIKE STANDARD TABLE OF bapiret2, "bapi return lwa_return TYPE bapiret2, "bapi return lit_movs LIKE STANDARD TABLE OF bapi2017_gm_item_create, "mat doc item lwa_movs TYPE bapi2017_gm_item_create, "mat doc item lwa_header LIKE bapi2017_gm_head_01, "mat doc hdr lwa_code LIKE bapi2017_gm_code, "mmim code lwa_header_ret TYPE bapi2017_gm_head_ret. "mat hdr return lwa_code = '04'. "MB1B lwa_header-pr_uname = sy-uname. lwa_header-pstng_date = sy-datum. lwa_header-doc_date = sy-datum. REFRESH:lit_movs. CLEAR:lwa_movs. * MATERIAL lwa_movs-material = '000000000050580071'. * PLANT lwa_movs-plant = '8800'. * Storage loc lwa_movs-stge_loc = '8813'. * MOVE_TYPE lwa_movs-move_type = '311'. * STCK_TYPE lwa_movs-stck_type = ''. * MOVE_STOCK lwa_movs-move_stloc = '8814'. * spec procecument lwa_movs-spec_stock = 'E'. * sales order lwa_movs-val_sales_ord = '0640003056' . * sales item lwa_movs-val_s_ord_item = '000200'. * Qty Open lwa_movs-entry_qnt = 1. * ENTRY_UOM CLEAR:lwa_movs-entry_uom. APPEND lwa_movs TO lit_movs. CALL FUNCTION 'BAPI_GOODSMVT_CREATE' EXPORTING goodsmvt_header = lwa_header goodsmvt_code = lwa_code * TESTRUN = ' ' * GOODSMVT_REF_EWM = * IMPORTING * GOODSMVT_HEADRET = * MATERIALDOCUMENT = * MATDOCUMENTYEAR = TABLES goodsmvt_item = lit_movs[] * GOODSMVT_SERIALNUMBER = return = lit_return[] * GOODSMVT_SERV_PART_DATA = * EXTENSIONIN = . LOOP AT lit_return INTO lwa_return WHERE type = 'E' OR type = 'A' OR type = 'X'. EXIT. ENDLOOP. IF sy-subrc = 0. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ENDIF. |
以上。
发表评论