‎2007 Dec 17 7:11 AM
Hi All,
Is it possible to add a column to a dynamic internal table as a first column?.My requirement is...i have a dynamic internal table ..now i have to add(enchancement) a column as first to this dynamic internal table. if possible ...suggest me how to proceed?
Thanks in advance,
Padmasri.
Edited by: Padmasri on Dec 17, 2007 8:12 AM
‎2007 Dec 17 7:28 AM
Given that you already have a field-symbol pointing at your original type named: <orgTable> and it also assumes that your table's row type is a structure, it wouldn't be too hard to modify it to support other types of line types. The following should work (although haven't tried it in the ABAP ide):
data lineType type ref to cl_abap_structdescr.
data tableType type ref to cl_abap_tabledescr.
data componentTable type component_table..
tableType ?= cl_abap_tabledescr=>describe_by_data( <orgType> ).
lineType ?= tableType->get_table_line_type( ).
componentTable = lineType->get_components( ).
append your additional type here.
append fooType to componentTable.
lineType ?= cl_abap_structDescr=>create( componentTable ).
tableType = cl_abap_tabledescr=>create( lineType ).
now create your new data area.
data newTable type ref to data.
field-symbol <newTable> type standard table.
create data newTable handle tableType.
assign newTable->* to <newTable>.
Hope this is helpful, Do reward.
‎2007 Dec 17 7:42 AM
Hi,
when u create a internal table structure, instead of append use insert statement and specify the position of that particular field. then u can use it as a first field r whatever.