2

I have two screens (screen A and screen B) in my module pool program. Screen A displays ALV grid and has 1 button on the toolbar and Screen B also displays ALV grid and 1 button on the toolbar.

When I press the button "Show orders" on screen A, I am directed to the screen B. Then I do some edit operations on screen B, click 'Save' button on the toolbar and then 'Back' button.

When I press the button "Show orders" on screen A for a different row, I am directed to the screen B again, but ALV grid still shows data from the first material, i.e. it doesn't display new data, but displays old data.

Does it have to do with cl_gui_cfw=>flush method somehow? If yes, then where exactly in the code should I call it in order to display correct data?

PBO module of Screen B.

CREATE OBJECT zclmz_pp_md_create=>go_container_charg
  EXPORTING
    parent    = cl_gui_container=>screen0
    side      = cl_gui_docking_container=>dock_at_top
    extension = 800.

CREATE OBJECT zclmz_pp_md_create=>go_alv_charg
  EXPORTING
    i_parent = zclmz_pp_md_create=>go_container_charg.

zclmz_pp_md_create=>go_alv_charg->set_table_for_first_display( EXPORTING 
is_layout  = ls_layout CHANGING  it_outtab  =  zclmz_pp_md_create=>gs_plz- 
charg  it_fieldcatalog  = lt_fieldcat ).

PAI module of Screen B.

zclmz_pp_md_create=>go_alv_charg->refresh_table_display( EXPORTING is_stable = ls_stable ).

CALL METHOD cl_gui_cfw=>flush.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
user9695260
  • 347
  • 3
  • 17

2 Answers2

3

Method refresh_table_display should be called in the PBO of screen B, not in the PAI.

IF zclmz_pp_md_create=>go_alv_charg is NOT BOUND.
    CREATE OBJECT zclmz_pp_md_create=>go_container_charg
    EXPORTING
        parent    = cl_gui_container=>screen0
        side      = cl_gui_docking_container=>dock_at_top
        extension = 800.

    CREATE OBJECT zclmz_pp_md_create=>go_alv_charg
    EXPORTING
        i_parent = zclmz_pp_md_create=>go_container_charg.

    zclmz_pp_md_create=>go_alv_charg->set_table_for_first_display( EXPORTING 
    is_layout  = ls_layout CHANGING  it_outtab  =  zclmz_pp_md_create=>gs_plz- 
    charg  it_fieldcatalog  = lt_fieldcat ).
ELSE.
 zclmz_pp_md_create=>go_alv_charg->refresh_table_display( ).
ENDIF.
Laurens Deprost
  • 1,653
  • 5
  • 16
1

That's a well-known issue with controls. If you instantiate a control (your ALV) inside a container in which there was already a control which has not been freed up, then the old control still shows up.

Two solutions :

  • Either you keep instantiating the control, but then you must free the previous control. For this, you must use the method FREE, which is available for all kinds of controls (even the container itself can be freed, all its inner controls are then freed up).

  • Or you change the logic by instantiating the control only once, and you refresh its contents, like Laurens said.

(the issue is not related to cl_gui_cfw=>flush by the way)

See also this other answer.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48