matinal:SAP ABAP 如何用bapi实现QA11批量使用检验决策

2023-10-14 15:28:40 浏览数 (1)

代码语言:javascript复制
TYPES:BEGIN OF ty_data ,
        checkbox(1),
        prueflos    TYPE qals-prueflos,
        werk        TYPE qals-werk,
        matnr       TYPE qals-matnr,
        ktextmat    TYPE qals-ktextmat,
        vcodegrp    TYPE rqeva-vcodegrp,
        vcode       TYPE rqeva-vcode,
      END OF ty_data .

DATA:gt_data TYPE TABLE OF ty_data .

DATA:ls_data   TYPE bapi2045ud,
     ls_return TYPE bapireturn1,
     ls_stock  TYPE bapi2045d_il2,
     ls_ud_re  TYPE bapi2045ud_return.

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

  CLEAR ls_data .
  CLEAR ls_return .
  CLEAR ls_stock .
  CLEAR ls_ud_re .

  ls_data-insplot = <fs_add>-prueflos .
  ls_data-ud_selected_set = <fs_add>-vcodegrp .
  ls_data-ud_plant = <fs_add>-werk .
  ls_data-ud_code_group = <fs_add>-vcodegrp .
  ls_data-ud_code = <fs_add>-vcode .
  "要过账的把下面的字段赋值X
  "ls_data-ud_stock_posting = 'X'.  "是否进行过帐

  CALL FUNCTION 'BAPI_INSPLOT_SETUSAGEDECISION'
    EXPORTING
      number         = <fs_add>-prueflos
      ud_data        = ls_data
*     LANGUAGE       =
*     UD_MULTSPEC    =
*     UD_MODE        = 'D'
    IMPORTING
      ud_return_data = ls_ud_re
      stock_data     = ls_stock
      return         = ls_return
*     /CWM/STOCK_DATA       =
*     TABLES
*     SYSTEM_STATUS  =
*     USER_STATUS    =
    .

  IF ls_return-type = 'E' .

    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

  ELSE .

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.

  ENDIF .

ENDLOOP .

0 人点赞