ABAP 计划订单转生产订单

需求:计划订单转生产订单程序,允许修改计划订单数量/时间

    " Create BAPI_PLANNEDORDER_CHANGE
    CALL FUNCTION 'BAPI_PLANNEDORDER_CHANGE'
      EXPORTING
        plannedorder = <fs_alv>-plnum
        headerdata   = VALUE bapiplaf_i2(
        total_plord_qty  = <fs_alv>-gsmng
        version          = <fs_alv>-verid
        order_start_date = <fs_alv>-psttr
        order_fin_date   = <fs_alv>-pedtr
        firming_ind      = 'X'          " 标识必打,不然转单bapi报错
        conversion_ind   = 'X' )    " 标识必打,不然转单bapi报错
        headerdatax  = VALUE bapiplaf_i2x(
        total_plord_qty  = 'X'
        version          = 'X'
        order_start_date = 'X'
        order_fin_date   = 'X'
        firming_ind      = 'X'
        conversion_ind   = 'X' )
      IMPORTING
        return       = ls_ret.

    IF ls_ret-type CA 'AEX'.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      <fs_alv>-icon  = gc_red.
      <fs_alv>-msg   = |计划订单修改报错:{ ls_ret-message }|.
      CONTINUE.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
    ENDIF.

    " Create BAPI_PRODORD_CREATE 
    CLEAR:ls_return,lv_order_number.
    CALL FUNCTION 'BAPI_PRODORD_CREATE_FROM_PLORD'
      EXPORTING
        planned_order    = <fs_alv>-plnum
        order_type       = <fs_alv>-auart
      IMPORTING
        production_order = lv_order_number
        return           = ls_return.

    IF ls_return-type CA 'AEX'.

      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      <fs_alv>-icon  = gc_red.
      <fs_alv>-msg   = |创建生产订单报错:{ ls_return-message }|.

    ELSE.

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
      <fs_alv>-icon  = gc_green.
      <fs_alv>-msg   = |生产订单创建成功,订单号:{ lv_order_number }|.
      <fs_alv>-aufnr = lv_order_number.
 
    ENDIF.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值