Application Development and Automation 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: 
Read only

Editable & Dynamic ALV

Former Member
0 Likes
1,803

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

1 ACCEPTED SOLUTION
Read only

Former Member
1,203

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.

6 REPLIES 6
Read only

Former Member
1,204

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.

Read only

Former Member
0 Likes
1,203

Hi Srihari,

Just write,


assign lt_styletab to <t_celltab>.

in place of


INSERT LINES OF lt_styletab INTO TABLE <t_celltab>.

Regards,

Amitava

Read only

0 Likes
1,203

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?

Read only

0 Likes
1,203

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

Read only

0 Likes
1,203

.

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

Read only

0 Likes
1,203

This message was moderated.