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: 

Table type in dynamic internal table

Former Member
0 Kudos

I have created a dynamic internal table. I want to add one more column in the dynamic internal table which should be table type or need to create one table type while creating dynamic internal table.

Any suggestions plzz.

Thx,

Klad.

1 REPLY 1

former_member10945
Contributor
0 Kudos

If i understand you correctly you are looking to take a table generated dynamically and add another column to it.

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 that helps you out.