How to CALL TRANSACTION in ABAP

How to CALL TRANSACTION in ABAP

The goal is to call Transaction with parameters and skip first screen.

Simple way

Example to call the Prod Order display transaction :


  SET PARAMETER ID 'ANR' FIELD w_of_number.
  CALL TRANSACTION 'CO03' AND SKIP FIRST SCREEN.

 

Advanced way

The example below show how to call a transaction and skip first screen when it in not possible to SET parameters ID.

In case of CS03, the last field (BoM alternative) has no Parameter ID. In that case we use bdcdata to call transaction and provide parameters.


*&---------------------------------------------------------------------*
*&      Form  call_transaction_cs03
*&---------------------------------------------------------------------*
FORM call_transaction_cs03  USING pw_bom_header TYPE matnr
                                  pw_werks      TYPE werks_d
                                  pw_stlan      TYPE stlan
                                  pw_stlal      TYPE stalt.

  DATA: li_bdcdata  TYPE STANDARD TABLE OF bdcdata,
        ls_options  TYPE ctu_params,
        li_messages TYPE STANDARD TABLE OF bdcmsgcoll.

  CLEAR : li_bdcdata.

  ls_options-dismode = 'E'.
  ls_options-updmode = 'S'.
  ls_options-defsize = ''.
  ls_options-nobinpt = 'X'.
  ls_options-racommit = 'X'.

  PERFORM bdc_dynpro USING 'SAPLCSDI' '0100'
                     CHANGING li_bdcdata.

  PERFORM bdc_fields USING 'RC29N-MATNR' pw_bom_header
                     CHANGING li_bdcdata.

  PERFORM bdc_fields USING 'RC29N-WERKS' pw_werks
                     CHANGING li_bdcdata.

  PERFORM bdc_fields USING 'RC29N-STLAN' pw_stlan
                     CHANGING li_bdcdata.

  PERFORM bdc_fields USING 'RC29N-STLAL' pw_stlal
                     CHANGING li_bdcdata.


  PERFORM bdc_fields USING 'BDC_OKCODE' '/00'
  CHANGING li_bdcdata.

  CALL FUNCTION 'AUTHORITY_CHECK_TCODE'
    EXPORTING
      tcode  = 'CS03'
    EXCEPTIONS
      ok     = 1
      not_ok = 2
      OTHERS = 3.

  IF sy-subrc = 1.

    CALL TRANSACTION 'CS03' USING         li_bdcdata
                            OPTIONS FROM  ls_options
                            MESSAGES INTO li_messages.
  ELSEIF sy-subrc = 2.

    MESSAGE s062(zpp) WITH 'CS03' DISPLAY LIKE 'E'.
    " Vous n'êtes pas autorisé à lancer la transaction &.
  ENDIF.

ENDFORM.                    " CALL_TRANSACTION_CS03


*&---------------------------------------------------------------------*
*&      Form  bdc_dynpro
*&---------------------------------------------------------------------*
FORM bdc_dynpro USING pw_program TYPE bdcdata-program
                      pw_dynpro  TYPE bdcdata-dynpro
             CHANGING pi_bdcdata TYPE tab_bdcdata.

* Local data declaration
  DATA: ls_bdcdata TYPE bdcdata.

* Process
  CLEAR ls_bdcdata.
  ls_bdcdata-program  = pw_program.
  ls_bdcdata-dynpro   = pw_dynpro.
  ls_bdcdata-dynbegin = 'X'.
  APPEND ls_bdcdata TO pi_bdcdata.

ENDFORM.                    "bdc_dynpro


*&---------------------------------------------------------------------*
*&      Form  bdc_fields
*&---------------------------------------------------------------------*
FORM bdc_fields USING    pw_fnam    TYPE bdcdata-fnam
                         pw_fval    "TYPE bdcdata-fval
                CHANGING pi_bdcdata TYPE tab_bdcdata.

* Local data declaration
  DATA: ls_bdcdata TYPE bdcdata.

* Process
  CLEAR ls_bdcdata.
  ls_bdcdata-fnam = pw_fnam.
  ls_bdcdata-fval = pw_fval.
  APPEND ls_bdcdata TO pi_bdcdata.

ENDFORM.                    "bdc_fields 

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

4 Comments so far

Y V GOWDPosted on3:11 pm - Sep 10, 2020

Thanks a lot for your blog….

i was struck wit one issue this syntax is helped me alot SET PARAMETER ID ‘ANR’ FIELD w_of_number.

PatryPosted on8:32 pm - May 25, 2021

Hi, Florian

Thanks a lot for your blog….

Can you help me? I have the next code

DATA:
gs_options TYPE ctu_params,
gs_bdcdata TYPE bdcdata,
gt_bdcdata TYPE bdcdata_tab.

START-OF-SELECTION.

gs_bdcdata-dynbegin = ‘T’.
gs_bdcdata-fnam = ‘SE16’.
APPEND gs_bdcdata TO gt_bdcdata.
*
CLEAR: gs_bdcdata.
gs_bdcdata-program = ‘SAPLSETB’.
gs_bdcdata-dynpro = ‘0230’.
gs_bdcdata-dynbegin = ‘X’.
APPEND gs_bdcdata TO gt_bdcdata.
*
CLEAR: gs_bdcdata.
gs_bdcdata-fnam = ‘DATABROWSE-TABLENAME’.
gs_bdcdata-fval = ‘Zx’.
APPEND gs_bdcdata TO gt_bdcdata.

CLEAR: gs_bdcdata.
gs_bdcdata-fnam = ‘BDC_OKCODE’.
gs_bdcdata-fval = ‘=ANZE’.
APPEND gs_bdcdata TO gt_bdcdata.

CLEAR: gs_bdcdata.
gs_bdcdata-program = ‘/1BCDWB/DBZx’.
gs_bdcdata-dynpro = ‘1000’.
gs_bdcdata-dynbegin = ‘X’.
APPEND gs_bdcdata TO gt_bdcdata.

CLEAR: gs_bdcdata.
gs_bdcdata-fnam = ‘MAX_SEL’.
gs_bdcdata-fval = ”.
APPEND gs_bdcdata TO gt_bdcdata.

CLEAR: gs_bdcdata.
gs_bdcdata-fnam = ‘BDC_OKCODE’.
gs_bdcdata-fval = ‘=ONLI’.
APPEND gs_bdcdata TO gt_bdcdata.

gs_options-dismode = ‘E’.
gs_options-updmode = ‘S’.
gs_options-defsize = ”.
gs_options-nobinpt = ‘X’.
gs_options-racommit = ‘X’.

CALL TRANSACTION ‘SE16’ USING gt_bdcdata
OPTIONS FROM gs_options.

But don’t work exactly like I want.
1.- We need that the columns have the description of the name and not the name of the field
2.- When we exit the view, we want that come back to the menu, and no screen of the fields.

thanks

UJPosted on3:37 pm - Jun 12, 2023

Thanks for this post

Leave a Reply