matinal:SAP ABAP CO02生产工单重读主数据BAPI

2023-10-14 15:30:59 浏览数 (1)

代码语言:javascript复制
DATA:ls_orderdata TYPE bapi_pp_order_change,
     ls_orderdatax TYPE bapi_pp_order_changex,
     ls_return TYPE bapiret2,
     ls_read TYPE bapiflag-bapiflag.

LOOP AT gt_data ASSIGNING FIELD-SYMBOL(<fs_add>) WHERE checkbox = 'X' .

  CLEAR ls_orderdata .
  CLEAR ls_orderdatax .
  CLEAR ls_return .
  CLEAR ls_read .

  "afpo~verid
  ls_orderdata-prod_version = <fs_add>-verid1 . "生产版本
  ls_orderdata-explosion_date = sy-datum .
  ls_orderdata-explode_new = 'X' .

  ls_orderdatax-prod_version = 'X' .
  ls_orderdatax-explosion_date = 'X' .
  ls_orderdatax-routing = 'X' .

  CALL FUNCTION 'BAPI_PRODORD_CHANGE'
    EXPORTING
      "aufk~aufnr
      number = <fs_add>-aufnr "生产订单号
      orderdata = ls_orderdata
      orderdatax = ls_orderdatax
    IMPORTING
      return = ls_return
*       ORDER_TYPE =
*       ORDER_STATUS =
      "重读主数据成功就会返回X,否则为空
      master_data_read = ls_read
*     TABLES
*       FSH_BUNDLES =
    .
  IF ls_return-type = 'E' AND ls_read = '' .

    <fs_add>-type = icon_red_light .
    <fs_add>-message = '读取主数据失败,请检查订单状态及投料报工入库记录。' && ls_return-message .
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

  ELSE .

    <fs_add>-verid = <fs_add>-verid1 .
    <fs_add>-type = icon_green_light .
    <fs_add>-message = '读取主数据成功' .
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.

  ENDIF .

ENDLOOP .

0 人点赞