ABAP-给工单打删除标识 BAPI:BAPI_PRODORD_SET_DELETION_FLAG

BAPI:BAPI_PRODORD_SET_DELETION_FLAG

FORM frm_post .

  DATA:lt_rows   TYPE lvc_t_row,
       ls_return TYPE bapiret2,
       lt_aufnr  TYPE TABLE OF bapi_order_key WITH HEADER LINE,
       lt_detail TYPE TABLE OF bapi_order_return WITH HEADER LINE.
  DATA:lv_msg TYPE string.

  "获取选中行
  CALL METHOD go_grid->get_selected_rows
    IMPORTING
      et_index_rows = lt_rows.

  LOOP AT lt_rows INTO DATA(ls_rows).

    CLEAR:lt_aufnr,lt_aufnr[],lt_detail,ls_return,lv_msg.
    READ TABLE gt_data INTO gs_data INDEX ls_rows-index.
    IF sy-subrc EQ 0.
      "需要执行删除的工单存内表
      lt_aufnr-order_number = gs_data-aufnr.
      APPEND lt_aufnr.
      CLEAR:lt_aufnr.

      CALL FUNCTION 'BAPI_PRODORD_SET_DELETION_FLAG'
        IMPORTING
          return        = ls_return
        TABLES
          orders        = lt_aufnr
          detail_return = lt_detail.

      LOOP AT lt_detail WHERE type = 'E' OR type EQ 'A' OR type EQ 'X'.
        CONCATENATE lv_msg lt_detail-message INTO lv_msg SEPARATED BY '/'.
      ENDLOOP.

      IF sy-subrc NE 0.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait = 'X'.

        gs_data-status = icon_green_light.
        gs_data-mesg = '删除成功'.
      ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
        gs_data-status = icon_red_light.
        gs_data-mesg = lv_msg.
      ENDIF.
      MODIFY gt_data FROM gs_data INDEX ls_rows-index TRANSPORTING status mesg.
      CLEAR:gs_data.
    ENDIF.
    CLEAR:ls_rows.
  ENDLOOP.
ENDFORM.

 

posted @ 2023-04-26 16:23  阿胖的阿多  阅读(229)  评论(0编辑  收藏  举报