Application Development and Automation 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: 
Read only

dynamically creating fields from values in internal table (crosstab)

Former Member
0 Likes
342

Hi,

I have the need to iterate over values in a given field of an internal table and create fields from each distinct value in another internal table. The resulting table would then be displayed in ALV Grid.

Here is a scenario to help make it clear:

original table:

pernr, wage type, amount

10000001, 1000, $100

10000001, 1001, $200

10000001, 1002, $300

10000002, 1000, $200

...

desired result:

pernr, wage type 1000 amount, wage type 1001 amount, wage type 1002 amount

10000001, $100, $200, $300

10000002, $200,,

...

The number of wage types needs to be determined at run time.

Thanks for any help!

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
310

There are many threads on [create dynamic internal table|https://www.sdn.sap.com/irj/scn/advancedsearch?query=createdynamicinternal+table&cat=sdn_all]

In a first loop, count the number of fields to create, then create the field-catalog and then the internal table, and last fill the new internal table.

Regards

1 REPLY 1
Read only

RaymondGiuseppi
Active Contributor
0 Likes
311

There are many threads on [create dynamic internal table|https://www.sdn.sap.com/irj/scn/advancedsearch?query=createdynamicinternal+table&cat=sdn_all]

In a first loop, count the number of fields to create, then create the field-catalog and then the internal table, and last fill the new internal table.

Regards