码迷,mamicode.com
首页 > 其他好文 > 详细

传入采购订单项目建交货单

时间:2019-06-15 11:52:01      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:mit   point   bapi   ems   成功   doc   type   else   class   

技术图片

技术图片

 

*"----------------------------------------------------------------------
*"*"本地接口:
*"  EXPORTING
*"     REFERENCE(O_RETURN) TYPE  ZMMS0021
*"  TABLES
*"      IT_ITEM STRUCTURE  ZMMS0106
*"----------------------------------------------------------------------
  DATA:lt_stock_items TYPE TABLE OF bapidlvreftosto.
  DATA:ls_stock_items TYPE bapidlvreftosto.
  DATA:lt_created_items TYPE TABLE OF bapidlvitemcreated.
  DATA:ls_created_items TYPE bapidlvitemcreated.
  DATA:lv_delivery TYPE bapishpdelivnumb-deliv_numb.
  DATA:lv_vstel TYPE vstel.
  DATA:lv_ledat TYPE ledat.
  DATA:lt_return TYPE TABLE OF bapiret2.


  LOOP AT it_item INTO DATA(ls_item).
    ls_stock_items-ref_doc = ls_item-ebeln."参考凭证
    ls_stock_items-ref_item = ls_item-ebelp."参考项
*    ls_stock_items-dlv_qty = ls_item-menge."数量
    APPEND ls_stock_items TO lt_stock_items.

    ls_created_items-ref_doc = ls_item-ebeln."参考凭证
    ls_created_items-ref_item = ls_item-ebelp."参考项
    ls_created_items-material = ls_item-matnr."物料编号
    ls_created_items-material_long = ls_item-matnr."物料编号
*    ls_created_items-dlv_qty = ls_item-menge."数量
    APPEND ls_created_items TO lt_created_items.
  ENDLOOP.

  CALL FUNCTION BAPI_OUTB_DELIVERY_CREATE_STO
    EXPORTING
      ship_point        = lv_vstel
      due_date          = lv_ledat
    IMPORTING
      delivery          = lv_delivery
    TABLES
      stock_trans_items = lt_stock_items
      created_items     = lt_created_items
      return            = lt_return.

  FREE MEMORY ID ZPOS_LGORT_FLAG.

  DELETE lt_return WHERE type = E AND id = BAPI AND number = 001.

  LOOP AT lt_return INTO DATA(ls_return) WHERE type = E.
    CONCATENATE o_return-message ls_return-message INTO o_return-message SEPARATED BY /.
  ENDLOOP.

  IF sy-subrc = 0.

    "创建失败
    CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.

    o_return-type = E.
    CONCATENATE 交货单创建失败: o_return-message INTO o_return-message.

  ELSE.
    "创建成功
    CALL FUNCTION BAPI_TRANSACTION_COMMIT
      EXPORTING
        wait = X.

    o_return-zdjh = lv_delivery."交货单
    o_return-type = S.
    o_return-message = 交货单创建成功.

  ENDIF.

 

传入采购订单项目建交货单

标签:mit   point   bapi   ems   成功   doc   type   else   class   

原文地址:https://www.cnblogs.com/rainysblog/p/11026958.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!