I have 2 screens 7000 and 7001, 7000 screen contains one button when we click on it it has to navigate to the 7001 screen, but it was not working as expected. SCREEN 7000 also have some details to display as an alv.

screen was navigating to screen 7001 but the data was not getting refresh. can any one help on it. I am using alv grid container. for both the screens i am using same alv grid

Sample code:

screen 7000 PAI:
WHEN 'DISPLAY'.
      call SCREEN 7001.

screen 7001 PBO:
 GET REFERENCE OF m_instance->gt_field INTO lr_output.

  CREATE OBJECT gr_grid
    EXPORTING
      i_parent = cl_gui_container=>default_screen.

  CALL FUNCTION 'ZLSO_GENERATE_GENERIC_FIELDCAT'
    EXPORTING
      ir_input_value   = lr_output
    IMPORTING
      et_fieldcat_fcat = lt_fldcat
    EXCEPTIONS
      xc_invalid_type  = 1
      xc_empty_table   = 2
      xc_unknown_error = 3
      OTHERS           = 4.
  IF sy-subrc <> 0.
    MESSAGE ' Error in generating ALV' TYPE 'E'.
  ENDIF.

  CALL METHOD gr_grid->set_table_for_first_display
    EXPORTING
      is_layout       = gs_layout
    CHANGING
      it_fieldcatalog = lt_fldcat
      it_outtab       = m_instance->gt_field.

  gr_grid->refresh_table_display( ).

1 Answers

3
Sandra Rossi On Best Solutions

1) The main issue

Probably you are experiencing the case that several UI controls are assigned to the same UI container, only the first control assigned is displayed.

To avoid that issue, you must free the extra controls so that only one control remains assigned to each container.

In your case, you have 2 ALV Grids assigned to the same dummy container DEFAULT_SCREEN; your control being an instance of the class CL_GUI_ALV_GRID, you may call the method FREE to free it.

2) There's another problem in your code

The solution above should solve your immediate issue, but that will create another one, because you will have to re-instantiate the ALV Grid when navigating back to the screen 7000, and that will reset the scroll position and so on.

You may avoid it by changing something else in your code, as I explain below.

A dynpro (ABAP screen) contains UI elements, but if you assign a control to a "dummy screen" (any of the static attributes *SCREEN* of CL_GUI_CONTAINER), this control will be displayed over the dynpro (the UI elements of the dynpro are not shown at all, except the toolbar).

Instead of using dummy screens, you should define a custom control area in your dynpro, give it a name, then in the PBO, create a custom container (class CL_GUI_CUSTOM_CONTAINER) by indicating the area name, and assign the ALV Grid to that container.

If you do that in your two screens, then you will have only one ALV Grid per container, and you won't need to free and re-instantiate the controls at each navigation step.