2010 Oct 19 7:09 AM
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
2010 Oct 19 9:29 AM
<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
2010 Oct 19 7:43 AM
You have to use assign component statament to do that.
Check my reply here
2010 Oct 19 8:34 AM
2010 Oct 19 8:39 AM
2010 Oct 19 10:11 AM
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
2010 Oct 19 9:29 AM
<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
2010 Oct 19 10:27 AM
Thanks Marcin..
It works..
Can u pls. help me out with any useful links reg. dynamic internal tables??
Thanks
John