Skip to Content

DYNPRO: Triggering PAI manually


my DYNPRO consits of 3 sections like shown below.

The CUSTOM CONTROL section is displaying an CL_GUI_ALV_GRID-object with a customized toolbar (by handling the event TOOLBAR of CL_GUI_ALV_GRID).

When a button of the customized toolbar is pressed, the handler for this action has to use data from the upper right section of the DYNPRO (named: "WE: Allgemeine Buchungsdaten" in the image above).

As there is no PAI executed after pressing the button, no data-transfer from DYNPRO to programm happens. So my handler works with data transferred before last PAI, which may be old.

Is there a way to trigger PAI manually in my handler?

I tried

  CALL METHOD cl_gui_cfw=>set_new_ok_code
      new_code = 'DUMMY'.
   CALL METHOD cl_gui_cfw=>flush.

like told me, but PAI is not triggered after this peace of code.

Please help,


dynpro.jpg (207.7 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 28, 2017 at 03:08 PM

    Set a new ok_code with

            CALL METHOD cl_gui_cfw=>set_new_ok_code
                new_code = 'BOOK_PAI'.

    and move your processing code

         WHEN 'BOOK_PAI'.
            PERFORM book_purchase_order.
            PERFORM display_purchase_order_info.

    to the 'normal'

    MODULE user_command.

    cl_gui_cfw=>set_new_ok_code is a 'simple' forward to leave the ALV events and go back to the standard flow logic.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 28, 2017 at 05:55 PM

    By default, all ALV Grid control events don't trigger the PAI (system events). This may be changed for all events, via the parameter I_APPL_EVENTS = 'X' of the constructor (application events).

    You may also transport explicitly the screen fields you want, via the function module DYNP_VALUES_READ.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 28, 2017 at 12:52 PM

    CL_GUI_CFW=>SET_NEW_OK_CODE works well for me (no need of flush):

    DATA int_fleet TYPE TABLE OF sflight.
    DATA alv_1 TYPE REF TO cl_gui_alv_grid.
    CLASS lcl_event_receiver DEFINITION.
        METHODS on_user_command FOR EVENT user_command OF cl_gui_alv_grid.
        METHODS handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
              IMPORTING e_object e_interactive.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    DATA event_receiver TYPE REF TO lcl_event_receiver.
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_toolbar.
        DATA ls_toolbar TYPE stb_button.
        DELETE e_object->mt_toolbar WHERE function = '&DETAIL'.
        CLEAR ls_toolbar.
        ls_toolbar-butn_type = cntb_btype_sep.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        ls_toolbar-function  = 'AIRCRAFT LIST'.
        ls_toolbar-icon      = icon_bw_ref_structure_sap.
        ls_toolbar-quickinfo = 'Show Tail No. and Equipment'(111).
        ls_toolbar-text      = 'Structure'(112).
        ls_toolbar-disabled  = ''.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar
      METHOD on_user_command.
        MESSAGE 'on_user_command' TYPE 'I'.
        cl_gui_cfw=>set_new_ok_code( 'DUMMY' ).
      ENDMETHOD.                    "handle_toolbar
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    PARAMETERS dummy.
      IF alv_1 IS INITIAL.
        SELECT * FROM sflight INTO TABLE int_fleet.
        DATA: it_layout TYPE lvc_s_layo,
              it_fcat TYPE lvc_t_fcat,
              ls_exclude TYPE ui_func,
              gs_variant TYPE disvariant,
              lt_exclude TYPE ui_functions.
        ls_exclude = cl_gui_alv_grid=>mc_fc_excl_all.
        APPEND ls_exclude TO lt_exclude.
        PERFORM get_fcat CHANGING int_fleet it_fcat.
        CREATE OBJECT alv_1
            i_parent = cl_gui_container=>screen0.
        CREATE OBJECT event_receiver.
    * set the toolbar handler before SET_TABLE_FOR_FIRST_DISPLAY so that to
    * make it raised automatically (thus no need to call SET_TOOLBAR_INTERACTIVE)
        SET HANDLER event_receiver->handle_toolbar FOR alv_1.
        SET HANDLER event_receiver->on_user_command FOR alv_1.
        CALL METHOD alv_1->set_table_for_first_display
            is_layout                     = it_layout
            it_toolbar_excluding          = lt_exclude
            is_variant                    = gs_variant
            it_outtab                     = int_fleet
            it_fieldcatalog               = it_fcat
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
    FORM get_fcat CHANGING it_std TYPE STANDARD TABLE et_fcat TYPE lvc_t_fcat.
      DATA lo_table TYPE REF TO cl_salv_table.
      DATA lo_columns TYPE REF TO cl_salv_columns_list.
      DATA lo_agg TYPE REF TO cl_salv_aggregations.
      REFRESH et_fcat.
      CALL METHOD cl_salv_table=>factory
          r_salv_table = lo_table
          t_table      = it_std[].
      lo_columns = lo_table->get_columns( ).
      lo_agg = lo_table->get_aggregations( ).
      et_fcat = cl_salv_controller_metadata=>get_lvc_fieldcatalog( r_columns = lo_columns r_aggregations = lo_agg ).
    Add comment
    10|10000 characters needed characters exceeded

    • Yep,

        CALL METHOD cl_gui_cfw=>set_new_ok_code
            new_code = 'DUMMY'.
         CALL METHOD cl_gui_cfw=>flush.

      works in a way that does not help me :(

      My handler (short version):

        METHOD alv_user_command.
          CASE e_ucomm. " importing parameter
            WHEN 'BOOK'.
              CALL METHOD cl_gui_cfw=>set_new_ok_code
                  new_code = 'DUMMY'.
              CALL METHOD cl_gui_cfw=>flush.
              PERFORM book_purchase_order.
              PERFORM display_purchase_order_info.
            WHEN OTHERS.
        ENDMETHOD.                    "ALV_USER_COMMAND

      PAI has to take place before calling of FORM book_puchase_order, but it happens after METHOD alv_user_command is finished.