修改生产订单组件——CO_XT_COMPONENT_CHANGE

修改组件仓库的范例

DATA: lv_po        TYPE coxt_ord_key,
      ls_component TYPE coxt_s_ord_comp_key,
      ls_requ      TYPE coxt_s_quantity,
      ls_requx     TYPE coxt_s_quantityx,
      ls_conf      TYPE coxt_s_quantity,
      ls_confx     TYPE coxt_s_quantityx,
      lv_matnr     TYPE coxt_material,
      lv_matnrx    TYPE coxt_materialx,
      ls_oper      TYPE coxt_s_ord_opr_key,
      ls_operx     TYPE coxt_s_ord_opr_keyx,
      ls_storage   TYPE coxt_s_storage_location,
      ls_storagex  TYPE coxt_s_storage_locationx,
      lv_charg     TYPE coxt_batch,
      lv_chargx    TYPE coxt_batchx,
      lv_cuobj     TYPE coxt_config_object,
      lv_cuobjx    TYPE coxt_config_objectx,
      ls_return    TYPE coxt_bapireturn.

"生产订单
lv_po = '000022016565'.

"预留单项次
ls_component-rsnum = '0001065926'.
ls_component-rspos = '0001'.

"组件
lv_matnr = 'CTCN0009-XQ'.
lv_matnrx = 'X'.

"组件领料仓库
ls_storage-werks = '2000'.
ls_storage-lgort = '2173'.

ls_storagex-werks = 'X'.
ls_storagex-lgort = 'X'.

CALL FUNCTION 'CO_XT_COMPONENT_CHANGE'
  EXPORTING
    is_order_key               = lv_po          "生产订单
    is_order_component_key     = ls_component   "组件
    is_requirement_quantity    = ls_requ        "组件需求数量
    is_requirement_quantityx   = ls_requx
    is_confirmed_quantity      = ls_conf        "生产数量
    is_confirmed_quantityx     = ls_confx
    i_material                 = lv_matnr       "组件物料
    i_materialx                = lv_matnrx
    is_order_operation_key     = ls_oper        "组件指派工序
    is_order_operation_keyx    = ls_operx
    is_storage_location        = ls_storage     "组件领料仓库
    is_storage_locationx       = ls_storagex
    i_batch                    = lv_charg       "批次
    i_batchx                   = lv_chargx
    i_mi_configuration_object  = lv_cuobj       "内置对象号码
    i_mi_configuration_objectx = lv_cuobjx
  IMPORTING
    es_bapireturn              = ls_return.

IF ls_return-type NE 'E'.
  CALL FUNCTION 'CO_XT_ORDER_PREPARE_COMMIT'
    IMPORTING
      es_bapireturn = ls_return.
  IF ls_return NE 'E'.
    COMMIT WORK AND WAIT.
    WRITE '修改成功'.
  ELSE.
    ROLLBACK WORK.
    WRITE '修改失败'.
  ENDIF.
ELSE.
  ROLLBACK WORK.
  WRITE '修改失败'.
ENDIF.

修改组件的工序范例

DATA: lv_po        TYPE coxt_ord_key,
      ls_component TYPE coxt_s_ord_comp_key,
      ls_requ      TYPE coxt_s_quantity,
      ls_requx     TYPE coxt_s_quantityx,
      ls_conf      TYPE coxt_s_quantity,
      ls_confx     TYPE coxt_s_quantityx,
      lv_matnr     TYPE coxt_material,
      lv_matnrx    TYPE coxt_materialx,
      ls_oper      TYPE coxt_s_ord_opr_key,
      ls_operx     TYPE coxt_s_ord_opr_keyx,
      ls_storage   TYPE coxt_s_storage_location,
      ls_storagex  TYPE coxt_s_storage_locationx,
      lv_charg     TYPE coxt_batch,
      lv_chargx    TYPE coxt_batchx,
      lv_cuobj     TYPE coxt_config_object,
      lv_cuobjx    TYPE coxt_config_objectx,
      ls_return    TYPE coxt_bapireturn.

DATA: lt_resb_get TYPE TABLE OF resbdget,
      ls_resb_get TYPE resbdget.

"生产订单
lv_po = '000022016565'.

"预留单项次
ls_component-rsnum = '0001065926'.
ls_component-rspos = '0001'.

"组件
lv_matnr = 'CTCN0009-XQ'.
lv_matnrx = 'X'.

"工厂
ls_storage-werks = '2000'.

CALL FUNCTION 'CO_XT_COMPONENT_CHANGE'
  EXPORTING
    is_order_key               = lv_po          "生产订单
    is_order_component_key     = ls_component   "组件
    is_requirement_quantity    = ls_requ        "组件需求数量
    is_requirement_quantityx   = ls_requx
    is_confirmed_quantity      = ls_conf        "生产数量
    is_confirmed_quantityx     = ls_confx
    i_material                 = lv_matnr       "组件物料
    i_materialx                = lv_matnrx
    is_order_operation_key     = ls_oper        "组件指派工序
    is_order_operation_keyx    = ls_operx
    is_storage_location        = ls_storage     "组件领料仓库
    is_storage_locationx       = ls_storagex
    i_batch                    = lv_charg       "批次
    i_batchx                   = lv_chargx
    i_mi_configuration_object  = lv_cuobj       "内置对象号码
    i_mi_configuration_objectx = lv_cuobjx
  IMPORTING
    es_bapireturn              = ls_return.

IF ls_return-type NE 'E'.
  CALL FUNCTION 'CO_XT_ORDER_PREPARE_COMMIT'
    IMPORTING
      es_bapireturn = ls_return.
  IF ls_return NE 'E'.

    "获取生产订单
    CALL FUNCTION 'CO_BC_RESBD_OF_ORDER_GET'
      EXPORTING
        aufnr_act = lv_po "生产订单
      TABLES
        resbd_get = lt_resb_get.

    LOOP AT lt_resb_get INTO ls_resb_get
      WHERE rsnum = '0001065926' AND rspos = '0001'.
      "修改组件的工序
      ls_resb_get-vornr = '0040'.
      MODIFY lt_resb_get FROM ls_resb_get.
    ENDLOOP.

    CALL FUNCTION 'CO_BC_UPDATE_CMP_OF_ORDERS'
      TABLES
        resbd_get = lt_resb_get.

    COMMIT WORK AND WAIT.

    CALL FUNCTION 'CO_XT_ORDER_INITIALIZE'.

    WRITE '修改成功'.
  ELSE.
    ROLLBACK WORK.
    WRITE '修改失败'.
  ENDIF.
ELSE.
  ROLLBACK WORK.
  WRITE '修改失败'.
ENDIF.

 

posted @ 2022-09-29 17:26  鲸与海  阅读(1007)  评论(0编辑  收藏  举报