Skip to Content

Issue!!!! Multiple OOPs ALV at same time

Hi All,

I have requirement to display multiple ALVs. I have used OOPS method since I have to display ALV in different TABS. As seen below

Number of tabs are dynamic and can be displayed up to 20.

To achieve the requirement I have called method SET_TABLE_FOR_FIRST_DISPLAY in a loop. below is code snippet.
LOOP AT gt_zco_csprot00 INTO ls_zco_csprot00.


 lv_name = sy-tabix.
 CLEAR cont_name.
 CONCATENATE 'CONT' lv_name INTO cont_name.


CREATE OBJECT gref_con
 EXPORTING
 container_name = cont_name
 EXCEPTIONS
 cntl_error = 1
 cntl_system_error = 2
 create_error = 3
 lifetime_error = 4
 lifetime_dynpro_dynpro_link = 5
 OTHERS = 6.
 CREATE OBJECT gref_alv_grid
 EXPORTING
 i_parent = gref_con
 EXCEPTIONS
 error_cntl_create = 1
 error_cntl_init = 2
 error_cntl_link = 3
 error_dp_create = 4
 OTHERS = 5.

 CALL METHOD gref_alv_grid->set_table_for_first_display
 EXPORTING
 is_layout = ls_layout
 i_save = 'A'
 CHANGING
 it_outtab = gt_final1
 it_fieldcatalog = gt_fcat
 EXCEPTIONS
 invalid_parameter_combination = 1
 program_error = 2
 too_many_lines = 3
 OTHERS = 4.
 ENDLOOP.

Every iteration is giving me a new reference yet my ALV is not showing proper data and data from last ALV is being overwritten in all previous ALV.

I know I can create difference objects to solve the issue but since it's in dynamic in nature I need a dynamic solution.

Help will be appreciated.!!!!

REPORT ztest_dna.
INITIALIZATION.
CLASS lcl_class DEFINITION.
 PUBLIC SECTION.
 METHODS display.
 METHODS enter IMPORTING val TYPE i.
 DATA: value TYPE i.
ENDCLASS.
CLASS lcl_class IMPLEMENTATION.
 METHOD display.
 WRITE:/ me->value.
 ENDMETHOD.
 METHOD enter.
 me->value = val.
 ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
 DATA: lo_class TYPE REF TO lcl_class.
 DO 20 TIMES.
 CREATE OBJECT lo_class.
 CALL METHOD lo_class->enter
 EXPORTING
 val = sy-index.
 lo_class->display( ).
 ENDDO.

Above program is for testing yet this one works fine. But with ALV it's not working.

P.S. : Data is going correct in method set_table_for_first_display.

Regards,

Nooruddin Bohra

images.png (14.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Sep 28, 2017 at 01:16 PM

    As already written, create different references/occurences, so internal table records or CREATE DATA statement are suggested. In particular, care to variables that are not passed 'by value' in ALV class methods (so including the internal data table)

    Also to prevent interraction between the different ALV, don't forget to also use a different HANDLE or LOG_GROUP in your variant/layout management (structure DISVARIANT)

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 28, 2017 at 12:10 PM

    You should store the different ALV references into different global reference variables (for instance an internal table of references), because the references which are not related anymore to a global or static variable are freed.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 28, 2017 at 10:40 AM

    I can't give you a solution for the whole requirement, but it's clear that your code is creating all the ALV at once, and is displaying them all in the same custom control (CONT_NAME), so only one is displayed. Instead, if you are using a tabstrip with server paging (each time a tab is selected, it triggers the PAI), you must load only one ALV at a time, the one corresponding to the current tab.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Sandra Rossi,

      Thanks for the suggestion. Apologies I forgot to share that in every iteration I am preparing container Name. For every tab I have different container and I am displaying ALV in different container and not in single container.

      lv_name = sy-tabix.
       CLEAR cont_name.
       CONCATENATE 'CONT' lv_name INTO cont_name.
      
  • Sep 29, 2017 at 10:01 AM

    We've done something alike and used the same container & ALV for all the tabs, and used a globally defined field-symbol as data table for the ALV.

    Switching tabs resulted in changing the table the global field-symbol refers to, rebuilding the field catalog, and updating the ALV.

    Add comment
    10|10000 characters needed characters exceeded