CALL TRANSACTION use and pass parameters and authority check (authority-check)

Common methods of use:

Method 1 :

CALL TRANSACTION T-CODE [AND SKIP FIRST SCREEN].

Among them, AND SKIP FIRST SCREEN means to jump directly to the relevant operation page according to the input parameters.

Method 2 :

CALL TRANSACTION T-CODE WITH|WITHOUT AUTHORITY-CHECK 

                        USING bdc_tab [OPTIONS FROM opt].

Commonly used parameter transmission methods:

Passing 1:

SET PARAMETER ID 参数ID FIELD 传入参数值.

According to the "parameter ID" of the called T-CODE parameter field, the value is passed in. VA03 as an example

SET PARAMETER ID 'AUN' FIELD 'Order number'.

 

Parameter 2: Pass the parameter value through the method 2 BDC

The method of use refers to the system standard DEMO program: DEMO_CALL_TRANSACTION_BDC

REPORT demo_call_transaction_bdc.

CLASS demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS main.
ENDCLASS.

CLASS demo IMPLEMENTATION.
  METHOD main.

    DATA class_name TYPE c LENGTH 30 VALUE 'CL_ABAP_BROWSER'.

    DATA bdcdata_tab TYPE TABLE OF bdcdata.

    DATA opt TYPE ctu_params.

    bdcdata_tab = VALUE #(
      ( program  = 'SAPLSEOD' dynpro   = '1000' dynbegin = 'X' )
      ( fnam = 'BDC_CURSOR'       fval = 'SEOCLASS-CLSNAME' )
      ( fnam = 'SEOCLASS-CLSNAME' fval = class_name )
      ( fnam = 'BDC_OKCODE'       fval = '=WB_DISPLAY' ) ).

    opt-dismode = 'E'.
    opt-defsize = 'X'.

    TRY.
        CALL TRANSACTION 'SE24' WITH AUTHORITY-CHECK
                                USING bdcdata_tab OPTIONS FROM opt.
      CATCH cx_sy_authorization_error ##NO_HANDLER.
    ENDTRY.

  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  demo=>main( ).

Note: If you only need to adjust to the parameter input page that calls T-CODE, you do not need to enter BDC_OKCODE when recording BDC.

Actual development case

T-CODE: ZPSR018A Corresponding program: ZPSR018_CONFIRM.

Responsible person number Need to pass in value, stay on the selection page

  DATA: lt_bdcdata_tab TYPE TABLE OF bdcdata,
        ls_opt         TYPE ctu_params.

  DATA(lra_vernr) = gra_vernr[].

  READ TABLE lra_vernr INTO DATA(ls_vernr) INDEX 1.
  IF sy-subrc = 0.
    DATA(lv_vernr_low) = ls_vernr-low.
  ENDIF.

  SORT lra_vernr BY low DESCENDING.
  READ TABLE lra_vernr INTO ls_vernr INDEX 1.
  IF sy-subrc = 0.
    DATA(lv_vernr_high) = ls_vernr-low.
  ENDIF.

  lt_bdcdata_tab = VALUE #(
    ( program  = 'ZPSR018_CONFIRM' dynpro   = '1000' dynbegin = 'X' )
    ( fnam = 'BDC_CURSOR'       fval = 'S_PSPID-LOW' )
    ( fnam = 'S_VERNR-LOW'      fval = lv_vernr_low )
    ( fnam = 'S_VERNR-HIGH'     fval = lv_vernr_high ) ).

  ls_opt = VALUE #( dismode = 'E'
                    defsize = 'X' ).

  TRY.
      CALL TRANSACTION 'ZPSR018A' WITH AUTHORITY-CHECK
                                 USING lt_bdcdata_tab OPTIONS FROM ls_opt.
    CATCH cx_sy_authorization_error ##NO_HANDLER.
  ENDTRY.

The effect is as follows:

 

Access control

According to the help document as follows

  TRY.
      CALL TRANSACTION 'F-02' WITH AUTHORITY-CHECK.
    CATCH cx_sy_authorization_error.
      MESSAGE s001(00) WITH '无此事务代码操作权限,请检查' DISPLAY LIKE 'E'.
      RETURN.
  ENDTRY.

If the program does not have the above permission exception control, when the permission is insufficient, it may cause the current program to dump

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Published 190 original articles · praised 133 · 970,000 views

Guess you like

Origin blog.csdn.net/wanglei880526/article/details/102929935