simulationabapbuttonclickdynpro

SUBMIT report and simulate button click?


I need to call a report inside a RFC function module in ABAP passing some parameters. This can be done using the SUBMIT statement. When running the report, a selection screen is shown initially, which also offers three buttons that can be clicked. The selection screen and buttons are build using dynpros.

I would like to submit the report and also simulate the click of one of the three buttons. I know that I can simulate F8, for instance. Herefore I just need to remove the VIA SELECTION-SCREEN part of the SUBMIT call. But in my case I want to simulate a custom button click.

Any suggestions? Thanks


Solution

  • If you want to start another program and perform a series of actions in it, then you need to call it via a transaction code using CALL TRANSACTION.

    The CALL TRANSACTION instruction allows you to pass a table of batch-input instructions. Which allow you to put input into dynpro fields, simulate button events, and even switch to other dynpros and repeat the process there. An example can be found in this article. I added some more comments to that code snippet to explain what it is actually doing:

    DATA bdcdata_tab TYPE TABLE OF bdcdata WITH EMPTY KEY.
    bdcdata_tab = VALUE #(
      " Declare the first dynpro of the transaction we are going to proceed
      ( program  = 'SAPLSEOD' dynpro   = '1000' dynbegin = 'X' )
      " Set the cursor into the DYNPRO field SEOCLASS-CLSNAME
      ( fnam = 'BDC_CURSOR'       fval = 'SEOCLASS-CLSNAME' )
      " Put a string into the Dynpro field SEOCLASS_CLSNAME
      ( fnam = 'SEOCLASS-CLSNAME' fval = class_name )
      " Simulate a click on a button that triggers the function code =WB_DISPLAY
      ( fnam = 'BDC_OKCODE'       fval = '=WB_DISPLAY' ) ).
    
    CALL TRANSACTION 'SE24' 
        WITH AUTHORITY-CHECK
        USING bdcdata_tab.