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: 

Problem with Custom container ->cl_gui_custom_container/cl_gui_alv_grid

0 Kudos

Hi,

I want to reuse the same custom container screen for a different data.

First screen there will be button 1 and button 2

if I click button 1 then calculate and display data in custom container, if button 2 is clicked then calculate and display data with in the same custom container.

For this

1. Created Custom container - CONTAINER

2. In program defined and created custom container and custom alv grid

g_custom_container TYPE REF TO cl_gui_custom_container,
        alv_grid                     TYPE REF TO cl_gui_alv_grid.
       IF g_custom_container IS INITIAL.
            CREATE OBJECT g_custom_container
                EXPORTING
              container_name = 'CONTAINER'.

            CREATE OBJECT alv_grid
               EXPORTING
                i_parent = g_custom_container.
      ENDIF.

3. Display data using CALL METHOD alv_grid->set_table_for_first_display

every thing works great for button 1

4. when button 2 is clicked then calculate and display different set of data in same custom container which is used earlier.

5. here I used

call method alv_grid->free.
    call method g_custom_container->free.

6. create above objects once again and tried to use

call method alv_grid->set_table_for_first_display

, to reuse the same custom container 'CONTAINER' again for a different set of data and getting ABAP dump.

In debug mode, when I used the above method FREE for both ALV_GRID and G_CUSTOM_CONTAINER objects are not clearing.

Please let me know how can I reuse the same container for a different set of data when button2 is pressed.

Thanks in advance,

Krishna

Please use code tags to format your code and post in the correct forum

Edited by: Rob Burbank on Oct 1, 2010 2:37 PM

4 REPLIES 4

Former Member
0 Kudos

Hi,

try this way:


call method alv_grid->finalize.
call method alv_grid->free.
call method g_custom_container->finalize.
call method g_custom_container->free.

Regards,

Felipe

uwe_schieferstein
Active Contributor
0 Kudos

Hello Krishna

I would recommend to use a different approach instead of trying to initialize your container instances:


DATA:
  go_container_1 TYPE REF TO cl_gui_custom_container,
  go_container_2 TYPE REF TO cl_gui_custom_container,
  go_grid_1          TYPE REF TO cl_gui_alv_grid,
  go_grid_2          TYPE REF TO cl_gui_alv_grid.

" NOTE: Do this coding BEFORE calling the screen

* (1) Create 2 containers
CREATE OBJECT g_container_1
                EXPORTING
              container_name = 'CONTAINER'.
CREATE OBJECT g_container_2
                EXPORTING
              container_name = 'CONTAINER'.
" NOTE: If it is not possible to use the same container name then either create an additional
"            dummy screen having a second CUSTOM_CONTROL element or replace
" the customer containers with docking containers -> here you do not need to give a container name

* (2) Create 2 grid instances using a different container

* (3) Link the first container to the screen using its LINK method:
  CALL METHOD go_container_1
    EXPORTING 
       repid = <...>
      dynnr = <...>.

* (4) Perhaps you need to define a second dummy screen to which you link the second container

* (5) Display first grid instance (as default)

Now when the user pushes button 2 (to display the second grid) link container_1 to the dummy screen

and link container_2 to your main screen.

Regards

Uwe

Former Member
0 Kudos

Hi Ram,

Try using CLEAR statement, instead of FREE.

CLEAR: g_custom_container.

Regards,

Nisha Vengal.

0 Kudos

Thanks all for the suggestions.

I tried all options and it hasn't worked when I clicked back button, giving dump. Finally i created 2 screens and removed free statement and it worked well.

Thanks