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: 

Insert values into dynamically created internal table

Former Member
0 Kudos

Hi Gurus,

Kindly help,

I have created a dynamic internal table using:

CALL METHOD cl_alv_table_create=>create_dynamic_table

Now I want to insert values into the dynamic internal table. How Do I insert values into corresponding columns of the dynamic internal table.

I have searched for many codes on net but I could not find appropriate one.

For example:

vendor_101_xyz_international HY01 HY02 HY03 HY04 Total

article description fergy mash kenyi yaya

101 saffron 04 06 09 01 20

I created dynamic internal tabel with columns:

vendor_101_xyz_international HY01 HY02 HY03 HY04 Total

And now I wanto add values:

101 saffron 04 06 09 01 20

Here coulumns HY01 HY02 HY03 HY04 can change to one or two or any number.

Regards,

Dep

3 REPLIES 3

kesavadas_thekkillath
Active Contributor
0 Kudos

Hi,

If you are able to create a dynamic internal table then why are you not able to create a dynamic line type.


field:symbols:<fs> type any.
data:wf_ref type ref to data.

create data wf_ref like line of <fs_tab>.  "<fs_tab> is your dynamic internal table
if wf_ref is bound.
assign wf_ref->* to <fs>.
endif.

Now you can use <fs> as your work area.

Search for more details in SCN regarding this.

kesav

jarryq
Explorer
0 Kudos

Hi,

I'm not sure about your requirement but you can try to append an initial line and then loop at the dynamic table like this:


field-symbols: <fs_data> type standard table,
               <fs_wa>   type any,
               <fs_val>  type any.

assign dynamic_table->* to <fs_data>. "your dynamic internal table
append initial line to <fs_data>.

loop at <fs_data> assigning <fs_wa>.

    assign component 'HY01' of structure <fs_wa> to <fs_val>.
    <fs_val> = 'saffron'. "value to be inserted
    
    assign component 'HY02' of structure <fs_wa> to <fs_val>.
    <fs_val> = '04'.
    
    "and so on..

endloop.

Hope this helps.

Former Member
0 Kudos

Thank You All.