‎2009 Sep 10 1:00 PM
Hi experts,
I have a problem with my new function module:
I created a function module to easily make an ALV on a dynpro. In this function, I create the container (create object cl_gui_custom_container), and then the grid (create object cl_gui_alv_grid).
After thsi, I set the field catalogue, the layout...and then I made the ALV using method "set_table_for_first_display" of cl_gui_alv_grid.
No problem, everything works perfect. Until now: I have a dynpro with a tabstrip, in 2 of those tabs I want to have an ALV. I filled the tables, made the containers in the Tabs of the dynpro. BUt it won't work perfetct.
Problem now is that the function creates the container one time:
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING
container_name = container_name.
CREATE OBJECT grid
EXPORTING
i_parent = g_custom_container.
ENDIF.The first table/ALV will be filled. Then the function will be called a second time (second ALV, an other Tab). Function comes to create the container - but it still exists. So no new container will be created, instead the data of the second table will be shown in the first ALV.
Ok, I tried to remove the if-statement (IF g_custom_container IS INITIAL.). OK, works, until I change data in one of the ALVs.
My idea is to create the container dynamically, with different names. I called the function this way:
CALL FUNCTION 'ZZ_CREATE_ALV'
EXPORTING
container_name = 'T_ALV'
tab_name = 'GT_FIELDS'
CHANGING
output_tab = gt_fields.container_name is the name of the container on the dynpro/tab, tab_name is the name of the used table (as string), and output_tab is the table itself.
Now, the question: is it possible to make the name if my variant (here, g_custom_container and grid) dynamic, for example tab_name + "_grid" -> GT_FIELDS_GRID? Or any other ideas?
Thanks for your help
Michael
‎2009 Sep 14 9:40 AM
Just use an internal table. First line for first ALV, second line for second ALV.
‎2009 Sep 14 9:40 AM
Just use an internal table. First line for first ALV, second line for second ALV.
‎2009 Sep 14 9:58 AM
Hi Sandra,
first - thanks for your answer.
But I'm not sure if I understand you right:
Where should I use this table? Could you explain it a little bit more?
‎2009 Sep 14 11:03 AM
Okay, I try. For example, in your function module add a new importing parameter ALV_ID to identify the ALV. The new internal table (GT_IT) has 3 fields, alv_id, o_container, o_alv_grid. In your function module, instead of IF ... IS INITIAL, you write:
READ TABLE gt_it INTO gs_it WITH KEY alv_id = alv_id.
IF sy-subrc <> 0.
* create container (gs_it-o_container) and alv control (gs_x-o_alv_grid)
...
APPEND gs_it TO gt_it.
ENDIF.
...
* gs_it-o_alv_grid->method( ... ).
‎2009 Sep 14 11:14 AM
OK Sandra,
now it's much clearer!
But one thing I have to ask - how to fill this internal table?
Michael
‎2009 Sep 14 12:37 PM