09-28-2017 12:54 PM
Hi,
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
EXPORTING
new_code = 'DUMMY'.
CALL METHOD cl_gui_cfw=>flush.
like https://wiki.scn.sap.com/wiki/display/Snippets/Triggering+PAI+manually told me, but PAI is not triggered after this peace of code.
Please help,
Hubert
09-28-2017 4:08 PM
Set a new ok_code with
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'BOOK_PAI'.
and move your processing code
WHEN 'BOOK_PAI'.
PERFORM book_purchase_order.
PERFORM display_purchase_order_info.
to the 'normal'
PROCESS AFTER INPUT.
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.
09-28-2017 1:52 PM
CL_GUI_CFW=>SET_NEW_OK_CODE works well for me (no need of flush):
REPORT.
DATA int_fleet TYPE TABLE OF sflight.
DATA alv_1 TYPE REF TO cl_gui_alv_grid.
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
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.
AT SELECTION-SCREEN OUTPUT.
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
EXPORTING
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
EXPORTING
is_layout = it_layout
it_toolbar_excluding = lt_exclude
is_variant = gs_variant
CHANGING
it_outtab = int_fleet
it_fieldcatalog = it_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
ENDIF.
AT SELECTION-SCREEN.
MESSAGE 'PAI' TYPE 'I'.
*---------------------------------------------------------------------------
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
IMPORTING
r_salv_table = lo_table
CHANGING
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 ).
ENDFORM.
09-28-2017 2:47 PM
Yep,
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
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
EXPORTING
new_code = 'DUMMY'.
CALL METHOD cl_gui_cfw=>flush.
PERFORM book_purchase_order.
PERFORM display_purchase_order_info.
WHEN OTHERS.
ENDCASE.
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.
09-28-2017 4:08 PM
Set a new ok_code with
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'BOOK_PAI'.
and move your processing code
WHEN 'BOOK_PAI'.
PERFORM book_purchase_order.
PERFORM display_purchase_order_info.
to the 'normal'
PROCESS AFTER INPUT.
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.
09-29-2017 7:26 AM
Thanks Tibor,
your suggestion is somthing like we call:
from behind through the chest into the eye
in Germany, but it works fine.
09-28-2017 6: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.