BAPI_DELIVERYPROCESSING_EXEC - 创建内向交货单

Note: BAPI_DELIVERYPROCESSING_EXEC 未发布

  • 根据内向采购订单创建内向交货单:
FORM CREATE_INBOUND_DELIVIRY.
 DATA: _RET          TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE,
       _CREATED_ITMES TYPE STANDARD TABLE OF BAPIDELICIOUSCREATEDITEMS WITH HEADER LINE,
       _REQUEST      TYPE STANDARD TABLE OF BAPIDELICIOUSREQUEST WITH HEADER LINE.

  LOOP AT GT_DO_ITEMS ASSIGNING FIELD-SYMBOL(<lfs_do>).

    CLEAR: _REQUEST.

    _REQUEST-ID  = sy-tabix.

    _REQUEST-DOCUMENT_NUMB = <lfs_do>-VGBEL."我这儿参考的单据为内部采购订单

    _REQUEST-DOCUMENT_ITEM = <lfs_do>-VGPOS."参考行项目确认控制为0001

    _REQUEST-DOCUMENT_TYPE = 'B'. "B: 处理采购订单 See domain : LESHP_DOCUMENT_TYPE

    _REQUEST-PLANT = <lfs_do>-WERKS.

    _REQUEST-STGE_LOC = <lfs_do>-LGORT.

    _REQUEST-QUANTITY_BASE__UOM = <lfs_do>-LFIMG.

    _REQUEST-DELIVERY_DATE = SY-DATUM.

    _REQUEST-DELIVERY_TIME = ''.

    APPEND _REQUEST.

  ENDLOOP.

  CALL FUNCTION 'BAPI_DELIVERYPROCESSING_EXEC'
    TABLES
      REQUEST      = _REQUEST
      CREATEDITEMS = _CREATED_ITMES
      RETURN       = _RET.

  PERFORM DEAL_BAPI_RET TABLES _RET CHANGING G_ERR_FLAG.

  DATA(LV_VBELN) = VALUE #( _CREATED_ITEM[ 1 ] OPTIONAL ).

  IF G_ERR_FLAG = ABAP_TRUE OR LV_VBELN IS INITIAL.
    RETURN.
  ENDIF.

  MESSAGE S001(00) WITH |内向交货单{ LV_VBELN }创建成功.|. 
ENDFORM.


FORM DEAL_BAPI_RET TABLES RET_ERRMSG USING STEP CHANGING ERR_FLAG.
  FIELD-SYMBOLS: <FS_RET> TYPE BAPIRET2.
  DATA: ERRMSG TYPE SMESG.

  CLEAR  ERR_FLAG.
  REFRESH GT_SMESG.

  DATA(LV_ZEILE) = LINES( GT_SMESG_ALL[] ).

  LOOP AT RET_ERRMSG ASSIGNING <FS_RET>.

    IF ERR_FLAG = ABAP_FALSE AND ( <FS_RET>-TYPE = 'E'
       OR <FS_RET>-TYPE = 'A' OR <FS_RET>-TYPE = 'X' ).
      ERR_FLAG = ABAP_TRUE.  "失败
    ENDIF.

    CLEAR ERRMSG.
    ERRMSG-ZEILE = LV_ZEILE + SY-TABIX.
    ERRMSG-MSGTY = <FS_RET>-TYPE.
    ERRMSG-ARBGB = <FS_RET>-ID.
    ERRMSG-TXTNR = <FS_RET>-NUMBER.
    ERRMSG-MSGV1 = <FS_RET>-MESSAGE_V1.
    ERRMSG-MSGV2 = <FS_RET>-MESSAGE_V2.
    ERRMSG-MSGV3 = <FS_RET>-MESSAGE_V3.
    ERRMSG-MSGV4 = <FS_RET>-MESSAGE_V4.
    APPEND ERRMSG TO GT_SMESG.
  ENDLOOP.

  APPEND LINES OF GT_SMESG TO GT_SMESG_ALL.

  IF ERR_FLAG = ABAP_TRUE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

    CALL FUNCTION 'FB_MESSAGES_DISPLAY_POPUP'
      EXPORTING
        IT_SMESG        = GT_SMESG[]
      EXCEPTIONS
        NO_MESSAGES     = 1
        POPUP_CANCELLED = 2
        OTHERS          = 3.
    RETURN.
  ENDIF.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT = 'X'.
ENDFORM.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值