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.
Showing results for 
Search instead for 
Did you mean: 

Custom container

0 Kudos

How to refresh the data in the custom container in ooalv?

Because in my application I took one input field (city ) and for that i provided drop down,based on the selected city, i want to display the data in the custom container which is placed below the given input field in a screen, first time container was displaying correct records for that selected city,

but second time when i changed the city again, that time also container showing the previous records only, so can any one tell how to avoid this problem?


Active Contributor

Probably you are experiencing the case that several UI controls (ALV grid in your case) are assigned to the same UI container, only the first control assigned is displayed.

I mean, you probably instantiate a new ALV grid each time. Either you free the first control (method FREE), or you instantiate only once. If you change the ALV contents, call the method REFRESH_TABLE_DISPLAY.

0 Kudos

You may want to move your ALV creation logic to a method or perform; because you are going to call it from two places; one initially when you first display ALV, second when you edit ALV (the city field) this time changed data.

For this method you may want pass an internal table(say lt_alv_data) and pv_flag_edit as input. Inside method/perform:

If you are using different classes to create custom container and alv; look for similar methods in those classes ; the whole idea is if you want to regenerate alv with changed data, just set new data and display the alv again, below pseudo code may come handy.

DATA go_cust_container   TYPE REF TO cl_gui_custom_container.  "Global
DATA go_alv_grid         TYPE REF TO cl_salv_table.            "Global

if go_cust_container is not bound.
 create custom container.

if go_alv_grid is not bound.
create go_alv_grid object.   "This is where ALV is generated first 
**pass lt_alv_data ( which will have latest data )

IF pv_flag_edit IS NOT INITIAL.   "This is where an ALV is regenrated with changed(from edit) 
          go_alv_grid->set_data( CHANGING t_table = lt_alv_data ).

0 Kudos

When you say "pseudo code", you'd better write an algorithm rather than proposing wrong ABAP code, because people would think that they can copy some parts of your code.

Active Contributor
0 Kudos

By the way, when you said ooalv, I assumed that you used CL_GUI_ALV_GRID, but maybe you used SALV (wrapper of CL_GUI_ALV_GRID) or other OO ALV flavor. If you used SALV, there's no method FREE (the workaround is to call the method FREE of the enclosing container because it frees the controls it contains too, and you have to reinstantiate both the container and ALV controls) and the method to refresh is named just REFRESH.