记录几个BAPI

1 BAPI_ALM_ORDER_MAINTAIN 更改生产订单信息,比如组件

使用注意点:因为这个BAPI不支持所有类型生产订单,需要改造标准代码,改造点为:跳过IBAPI_H_EXEC_BU2_INTERN这个函数中的消息号: message e505(i0)

附带一段修改组件的代码范例。

 * 修改组件  BAPI 参数
  DATA:is_methods LIKE bapi_alm_order_method,
     it_methods      LIKE STANDARD TABLE OF  bapi_alm_order_method,
     is_component    LIKE    bapi_alm_order_component,      "组件信息
     it_component    LIKE STANDARD TABLE OF  bapi_alm_order_component,      "组件信息
     is_component_up LIKE    bapi_alm_order_component_up,
     it_component_up LIKE STANDARD TABLE OF  bapi_alm_order_component_up,
     it_return       LIKE TABLE OF  bapiret2,                      "返回消息
     is_return       LIKE bapiret2,                      "返回消息
     et_numbers      LIKE    bapi_alm_numbers.              "返回订单编码信息 
"修改组件
          CLEAR : it_methods[],it_component[],it_component_up[],it_return[].
          CLEAR : is_methods ,is_component ,is_component_up ,is_return .
          CLEAR : l_erro .

          CALL FUNCTION 'BAPI_ALM_ORDER_GET_DETAIL'  "读取组件、工序信息
            EXPORTING
              number        = order_number
            TABLES
              et_components = it_component_old
              et_operations = it_operation_old
              return        = it_return.

          SORT it_component_old BY res_item .
          SORT  it_operation_old BY activity DESCENDING."最后一道工序

          is_methods-refnumber  = 1.
          is_methods-method = 'SAVE'.
          is_methods-objectkey = order_number.
          APPEND is_methods TO it_methods.

          CLEAR l_rspos .
          LOOP AT it_component_old INTO is_component_old.
            CLEAR : is_methods ,is_component ,is_component_up ,is_return .

            IF is_component_old-delete_ind = ''.        "跳过被删除的项目
              is_methods-refnumber = is_component_old-res_item.                "参照组件编号
              is_methods-objecttype = 'COMPONENT'.
              is_methods-method = 'DELETE'.
              is_methods-objectkey = order_number..          "订单号
              APPEND is_methods TO it_methods.
            ENDIF.

            l_rspos = is_component_old-res_item ."最大的行号

            MOVE-CORRESPONDING is_component_old TO is_component .
            APPEND is_component  TO it_component .
          ENDLOOP.

          LOOP AT  pt_table2 WHERE zuuid = pt_table-zuuid.

            CLEAR : is_methods ,is_component ,is_component_up ,is_return .

            l_rspos = l_rspos + 1 .                         "行号加1


            PERFORM frm_add_zero(zldsr002) USING  pt_table2-idnrk. "补足前导0
            PERFORM frm_unit_input(zldsr002) USING pt_table2-gmein ."单位转换.

            is_component-res_item = l_rspos.                 "预留项目
            is_component-activity = '0040' ."工序
            is_component-material = pt_table2-idnrk.    "物料编码
            is_component-item_cat = 'L'.                  "项目类别
            is_component-requirement_quantity = pt_table2-bdmng ."数量
            is_component-requirement_quantity_unit = pt_table2-gmein ."单位
            APPEND is_component  TO it_component .

            is_component_up-activity = 'X' ."工序
            is_component_up-material = 'X'.                  "物料编码
            is_component_up-item_cat = 'X'.                  "项目类别
            is_component_up-requirement_quantity = 'X'.
            is_component_up-requirement_quantity_unit = 'X'.
            APPEND is_component_up TO it_component_up.

            is_methods-refnumber = l_rspos.                "参照组件编号
            is_methods-objecttype = 'COMPONENT'.
            is_methods-method = 'CREATE'.
            is_methods-objectkey = order_number.          "订单号
            APPEND is_methods TO it_methods.

          ENDLOOP.



          FREE : it_return[].
          CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
            TABLES
              it_methods      = it_methods
              it_component    = it_component
              it_component_up = it_component_up
              return          = it_return.

          LOOP AT it_return INTO is_return  WHERE type CA 'XEA'.
            pt_table-message = pt_table-message && ' ' && is_return-message .
            l_erro  = 'X'.
          ENDLOOP.

          IF l_erro  = 'X'.
            CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
            pt_table-type    = 'E'.

          ELSE.
            CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
              EXPORTING
                wait = 'X'.
            pt_table-type    = 'S'.
          ENDIF.

2 CO_SE_PRODORD_CHANGE 修改生产订单工序

修改生产订单工序其实1中的BAPI应该也能实现,不过没去验证,因此使用这个验证过的BAPI。

3 K_ORDER_SRULE_ADD 新增订单结算规则

新增订单结算规则其实1中的BAPI应该也能实现,不过没去验证,因此使用这个验证过的BAPI。(修改结算规则的时候,也可以直接强改表:COBRB,慎用)

4 BAPI_COSTCENTER_CHANGEMULTIPLE 修改成本中心

这个BAPI注意点是一点(.)代表空,比如冻结标志位

未完待续...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值