‎2010 Oct 05 4:51 PM
Hi,
I have the situation where I want to create an editable ALV whose column fields will be known during run time. So, here I'm using Dynamic Internal table concept.
Let me give a picture how my present program works,
Inside the fieldcatalog, ifc I have passed the deep structure of type lvc_s_styl, by pointing to the reference table and reference field.
Then I'm using the below code,
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
i_length_in_byte = 'X'
IMPORTING
ep_table = dy_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN dy_table->* TO <dyn_table>.
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.And I got the dynamic Internal table having one field (let it be the first column of that internal table) corresponding to the deep structure where we need to pass the fieldname and style = cl_gui_alv_grid=>mc_style_enabled.
Suppose, I have an internal table containing all the fieldnames (consider there are 5 fields) to be in editable mode, lets say, itab.
FIELD-SYMBOLS <t_celltab> TYPE ANY.
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
LOOP AT itab INTO wa.
ASSIGN COMPONENT 1 OF STRUCTURE <dyn_wa> TO <t_celltab>.
CLEAR ls_stylerow.
ls_stylerow-fieldname = wa-fildname.
ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT ls_stylerow INTO TABLE lt_styletab.
INSERT LINES OF lt_styletab INTO TABLE <t_celltab>.
ENDLOOP.And the last bit of code is not working.
My question is simple, How can i assign an internal table (type lvc_s_styl) containing values, to that deep structure field of that dynamic internal table?
Thanks in advance!
Edited by: kishan P on Oct 5, 2010 9:22 PM
‎2010 Oct 05 11:13 PM
I had a similar requirement and was able to get this to work. This may help.
create a local field symbol.
field-symbols: <l_celltab> type lvc_t_styl,
data: li_celltab type line of lvc_t_styl.Then assign the contents (assuming you already declared this celltab of type lvc_t_styl in your fieldcatalog and therefore into your <dyn_wa> table.
assign ('<dyn_wa>-celltab') to <l_celltab>.
loop at <dyn_wa>-celltab into li_celltab.
insert li_celltab into table <l_celltab>.
endloop.I hope you find this helpful. I have this working for me in a complex ALV I wrote a few years back.
‎2010 Oct 05 11:13 PM
I had a similar requirement and was able to get this to work. This may help.
create a local field symbol.
field-symbols: <l_celltab> type lvc_t_styl,
data: li_celltab type line of lvc_t_styl.Then assign the contents (assuming you already declared this celltab of type lvc_t_styl in your fieldcatalog and therefore into your <dyn_wa> table.
assign ('<dyn_wa>-celltab') to <l_celltab>.
loop at <dyn_wa>-celltab into li_celltab.
insert li_celltab into table <l_celltab>.
endloop.I hope you find this helpful. I have this working for me in a complex ALV I wrote a few years back.
‎2010 Oct 06 5:51 AM
Hi Srihari,
Just write,
assign lt_styletab to <t_celltab>.
in place of
INSERT LINES OF lt_styletab INTO TABLE <t_celltab>.
Regards,
Amitava
‎2010 Oct 06 9:48 AM
Thanks guys,
Now I got the data into <t_celltab> by using the below code,
ASSIGN lt_styletab TO <t_celltab>.
But, when i try to pass this value to my dunamic internal table, its not working.
I'm presently using the below code for that..
ASSIGN ('<dyn_wa>-celltab') TO <t_celltab>.
APPEND <dyn_wa> TO <dyn_table>.
Any suggestions?
‎2010 Oct 06 12:28 PM
Hi Srihari,
Use this code ...
LOOP AT <dyn_table> assigning <dyn_wa>.
LOOP AT itab into wa.
ASSIGN ('<dyn_wa>-celltab') TO <t_celltab>.
CLEAR ls_stylerow.
ls_stylerow-fieldname = wa-fildname.
ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT ls_stylerow INTO TABLE lt_styletab.
assign lt_styletab to <t_celltab>.
ENDLOOP.
ENDLOOP.
Now your dynamic table will be populated with the styles. This is the code if I have assumed ur code correctly....
Regards,
Amitava
‎2013 May 09 11:39 PM
.
Hi Amitava/Srihari,
In the above code, I can see data in <t_celltab> , but i don't see in <dyn_wa> . In my case instead of modyfing , i am appending data to <dyn_table> .
This is what my code looks like
ASSIGN COMPONENT 'CELLTAB' Of STRUCTURE <dyn_wa> TO <t_celltab>
IF syst-subrc EQ 0.
ASSIGN assign lt_styletab to <t_celltab>. "I can see data
ENDIF.
APPEND <dyn_wa> TO <dyn_table> . "No data in <dyn_wa> , obviosuly no data in <dyn_table>
Let me know, what i am doing wrong . Thanks
Regards
Srikanth
‎2013 May 13 5:58 PM