SD--根据订单创建出库单(相关的函数列表的介绍系列篇(2))

来源:互联网 发布:windows自动更新好吗 编辑:程序博客网 时间:2024/04/28 19:45

创建订单样例代码参见:http://blog.csdn.net/CompassButton/archive/2007/05/09/1601712.aspx 

可以根据一个订单或者部分订单项来创建出库单,代码如下:
* Populating the item data
lx_sales_item-ref_doc = l_vbeln.
lx_sales_item-ref_item = c_000010.
lx_sales_item-dlv_qty = fp_l_quantity.
lx_sales_item-sales_unit = fp_afpo-meins.

APPEND lx_sales_item TO li_sales_item.

* Function Module to create delivery
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_SLS'
EXPORTING
ship_point = l_vstel
IMPORTING
delivery = fp_l_delivery
TABLES
sales_order_items = li_sales_item
return = li_return1.

IF fp_l_delivery IS INITIAL.
* Error message Delivery not created
MESSAGE e049
ENDIF.

lx_vbkok-vbeln_vl = fp_l_delivery.
lx_vbkok-vbtyp_vl = c_vbtype_j .
lx_vbkok-vbeln = fp_l_delivery.
lx_vbkok-wabuc = c_wabuc_x.

lx_vbpok-vbeln_vl = fp_l_delivery.
lx_vbpok-posnr_vl = c_posnr.
lx_vbpok-vbeln = fp_l_delivery.
lx_vbpok-posnn = c_posnr.
lx_vbpok-matnr = fp_afpo-matnr.
lx_vbpok-charg = fp_afpo-charg.
lx_vbpok-werks = fp_afpo-dwerk.
lx_vbpok-taqui = c_wabuc_x.
lx_vbpok-pikmg = fp_l_quantity.
APPEND lx_vbpok TO li_vbpok.

* Clearing the implicit lock that mb_create_goods_mvt has. That
* prevents it from bieng called more then once within same LUW.
PERFORM clear_xcommit IN PROGRAM saplmbwl.

* FM to perform picking,confirmation W-M status and PGI.
CALL FUNCTION 'WS_DELIVERY_UPDATE'
EXPORTING
vbkok_wa = lx_vbkok
synchron = c_xfeld_x
delivery = fp_l_delivery
update_picking = c_xfeld_x
nicht_sperren = c_no_sp_x
if_database_update = c_data_1
if_error_messages_send_0 = c_xfeld_x
TABLES
vbpok_tab = li_vbpok
prot = li_prott.
* Checking if any error in PGI
READ TABLE li_prott WITH KEY MSGTY = c_e TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
MESSAGE e046 WITH fp_l_delivery.
ENDIF.
READ TABLE li_prott WITH KEY MSGTY = c_a TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
MESSAGE e046 WITH fp_l_delivery.
ENDIF.

原创粉丝点击