Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Recycling objects (alv-grid)

former_member1161170
Participant
0 Kudos

Hi gurus.

I must get seven different grids (seven different totals) starting from a gui.

I wouldnu2019t wish to declare seven containers and seven alv-grid, I would prefer declare only one time both objects. So every time I use the FREE instruction and then the CREATE again:

DATA: r_cont_2 TYPE REF TO cl_gui_custom_container, r_alv_2 TYPE REF TO cl_gui_alv_grid, gs_layout2 TYPE lvc_s_layo. IF NOT r_cont_2 IS INITIAL. FREE r_cont_2. CLEAR r_cont_2. ENDIF. IF NOT r_alv_2 IS INITIAL. FREE r_alv_2. CLEAR r_alv_2. ENDIF. CREATE OBJECT r_cont_2 EXPORTING container_name = 'SCR_TXT2'. CREATE OBJECT r_alv_2 EXPORTING i_parent = r_cont_2. CASE ok_code. WHEN '1'. CALL METHOD r_alv_2->set_table_for_first_display EXPORTING is_layout = gs_layout2 CHANGING it_fieldcatalog = it_fdcat u201C <<< Changed for table 1!!! it_outtab = it_tab1 u201C <<< Table 1 EXCEPTIONS OTHERS = 4. WHEN '2'. CALL METHOD r_alv_2->set_table_for_first_display EXPORTING is_layout = gs_layout2 CHANGING it_fieldcatalog = it_fdcat u201C <<< Changed for table 2!!! it_outtab = it_tab2 u201C <<< Table 2 EXCEPTIONS OTHERS = 4. u2026u2026.. ENDCASE.

When I get the first output, I get the first grid correct (any table, everything is ok). When I get the second output and over, I see the first table again. In debug mode I can see the second new table correctly when I call the method, and I can see the objects full before the FREE instruction, and empty after.

Is there a solution, or must I declare seven alv-grid?

Must I declare seven containers too?

Thanks for you replies.

1 ACCEPTED SOLUTION

huseyindereli
Active Contributor
0 Kudos

Hi ,

Use one instance for alv and container . Change fieldcat , layout using SET_FRONTEND_FIELDCATALOG

SET_FRONTEND_LAYOUT methods , than refresh grid.

2 REPLIES 2

huseyindereli
Active Contributor
0 Kudos

Hi ,

Use one instance for alv and container . Change fieldcat , layout using SET_FRONTEND_FIELDCATALOG

SET_FRONTEND_LAYOUT methods , than refresh grid.

0 Kudos

Wonderful !!!

It's perfect !!!