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: 

append rows to dynamic internal table

Former Member
0 Kudos
5,624

HI all,

I have a dynamic internal table <fs_itab>, i need to append rows if some condition is not satisfying...

some of the fields on that intenal table are always same hence i need to append rows only for that columns.fields.

how is it possible?

for example <field1> , <field2> are always constant while dynamic generation of <fs_itab>..

so whiel appending the row i need to just modify these fields only...

am trying the following code..but its getting failed.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = gt_fieldcata01

IMPORTING

ep_table = <fs_data_tempa01>

EXCEPTIONS

generate_subpool_dir_full = 1

OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

ASSIGN <fs_data_tempa01>->* TO <fs_itab>.

CREATE DATA new_linetempa01 LIKE LINE OF <fs_itab>.

ASSIGN new_linetempa01->* TO <fs_wa>.

<fs_wa>-field1 = '1'

<fs_wa>-field2 = '2'.

append <fs_wa> to <fs_itab>

pls help me out to resolve the issue

thanks

john

1 ACCEPTED SOLUTION

MarcinPciak
Active Contributor
0 Kudos
1,248

<fs_wa> is of type any so you can't statically address its fields. The system simply don't recognize them as during runtime you could i.e. use structure of some other type which wouldn't have these fields, right?

So all you need is to address these fields dynamically.


field-symbols <any_field> type any.

assign component 'FIELD1' of structure <fs_wa> to <any_field>.
if sy-subrc = 0.
   <any_field> = 1.
endif.

assign component 'FIELD2' of structure <fs_wa> to <any_field>.
if sy-subrc = 0.
   <any_field> = 2.
endif.

append <fs_wa> to <fs_itab>.

<any_field> in turn points to content of field1 and field2 respectively. As you have addressed them dynamically (by assgining this field to new field symbol) you are able to change its content by this field symbol.

Regards

Marcin

6 REPLIES 6

kesavadas_thekkillath
Active Contributor
0 Kudos
1,248

You have to use assign component statament to do that.

Check my reply here

0 Kudos
1,248

Thanks Keshav..

sorry,but i really dint get that ref.link.

0 Kudos
1,248

Hi John,

Refer to my reply in the below threads on working with dynamic internal tables -

[;

[;

Hope it helps.

Regards,

Ravikiran

0 Kudos
1,248

Hello Ravi..

But I dint get ur links ...sorry..

could you kindly help me in achieving the result? ..pls...

actually the dynamic internal table is empty and i need to insert the value into certain fields which are always constant in the dynamic internal table.

thanks

john

Moderator message: please do not use SMS speak.

Edited by: Thomas Zloch on Oct 19, 2010 11:30 AM

MarcinPciak
Active Contributor
0 Kudos
1,249

<fs_wa> is of type any so you can't statically address its fields. The system simply don't recognize them as during runtime you could i.e. use structure of some other type which wouldn't have these fields, right?

So all you need is to address these fields dynamically.


field-symbols <any_field> type any.

assign component 'FIELD1' of structure <fs_wa> to <any_field>.
if sy-subrc = 0.
   <any_field> = 1.
endif.

assign component 'FIELD2' of structure <fs_wa> to <any_field>.
if sy-subrc = 0.
   <any_field> = 2.
endif.

append <fs_wa> to <fs_itab>.

<any_field> in turn points to content of field1 and field2 respectively. As you have addressed them dynamically (by assgining this field to new field symbol) you are able to change its content by this field symbol.

Regards

Marcin

0 Kudos
1,248

Thanks Marcin..

It works..

Can u pls. help me out with any useful links reg. dynamic internal tables??

Thanks

John