如何使用BAPISDORDER_GETDETAILEDLIST创建S/4HANA的OutboundDelivery
这篇文章将为大家详细讲解有关如何使用BAPISDORDER_GETDETAILEDLIST创建S/4HANA的Outbound Delivery,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
创新互联公司提供高防物理服务器租用、云服务器、香港服务器、四川雅安服务器托管等
要在S/4HANA里创建Outbound Delivery,首先要具有一个销售订单,ID为376,通过事务码VA03查看。
只用61行代码就能实现基于这个Sales Order去创建对应的outbound delivery:
REPORT zcreate_dn. DATA:lv_ship_point TYPE bapidlvcreateheader-ship_point VALUE '0001', lv_due_date TYPE datum VALUE '20181205', lv_delivery TYPE bapishpdelivnumb-deliv_numb, lt_so_items LIKE TABLE OF bapidlvreftosalesorder, ls_so_items LIKE LINE OF lt_so_items, lt_return TYPE TABLE OF bapiret2, ls_read TYPE order_view, lt_item TYPE TABLE OF bapisdit, lt_order_headers_out TYPE TABLE OF bapisdhd, lt_header TYPE TABLE OF sales_key, lt_bapisdtehd TYPE TABLE OF bapisdtehd, lt_bapitextli TYPE TABLE OF bapitextli, lt_bapiret2 LIKE bapiret2 OCCURS 0 WITH HEADER LINE. APPEND INITIAL LINE TO lt_header ASSIGNING FIELD-SYMBOL(). ls_read-item = 'X'. -vbeln = '0000000376'. CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST' EXPORTING i_bapi_view = ls_read TABLES sales_documents = lt_header order_items_out = lt_item. LOOP AT lt_item ASSIGNING FIELD-SYMBOL( - ). APPEND INITIAL LINE TO lt_so_items ASSIGNING FIELD-SYMBOL(
). -ref_doc = - -doc_number.
-ref_item = - -itm_number.
-dlv_qty = - -req_qty.
-sales_unit = 'EA'. ENDLOOP. CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_SLS' EXPORTING ship_point = lv_ship_point due_date = lv_due_date IMPORTING delivery = lv_delivery TABLES sales_order_items = lt_so_items return = lt_return. LOOP AT lt_return ASSIGNING FIELD-SYMBOL( ). WRITE:/ | Type: { -type }: { -message } | COLOR COL_NEGATIVE. ENDLOOP. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = lt_bapiret2. LOOP AT lt_bapiret2 ASSIGNING . WRITE:/ 'Message:', -message COLOR COL_POSITIVE. ENDLOOP.
思路就是首先用函数BAPISDORDER_GETDETAILEDLIST把销售订单的行项目明细读取出来,然后用BAPI_OUTB_DELIVERY_CREATE_SLS进行outbound delivery的创建。
执行report,显示Outbound Delivery 80000205成功创建:
使用事务码VL03N查看:
关于“如何使用BAPISDORDER_GETDETAILEDLIST创建S/4HANA的Outbound Delivery”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
标题名称:如何使用BAPISDORDER_GETDETAILEDLIST创建S/4HANA的OutboundDelivery
文章地址:http://pwwzsj.com/article/gdppoh.html