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: 

How to create New columns for the Internal Table Dynamically?

Former Member
0 Kudos

HI Guys,

In my logic i have to create new columns depending on the logic which i am executing.

My requirement is .I have to display o/p like this

Material || Year || Period || Mix ratio || Vendor ||Mix Ratio || Vendor || Mix Ratio Vendor || Mix ratio || Vendor || Mix ratio.............................from table's CKMLMV003 and CKMLMV001.Her i have to display the o/p in the above format and i have to display Vendor and Mix Ratio for 5 columns irrespective of data .If i have more than 5 columns for any record then i have to create a New columns dynamically for Vendor and Mix ratio.If anybody want my code i can Submit But plz tell with example how to do?

<b>The O/P must be finally shown in ALV Grid</b>

Thanks,

Gopi

5 REPLIES 5

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You must create the entire internal table dynamically, you can not add columns to a statically define internal table. Here is an example of creating a dynamic internal table.

Regards,

Rich Heilman

0 Kudos

Hi Rich,

I was not able to undertsand that one clearly.Can u explain by giving an example or shall i send my code to u.My req is i have to create the Columns Dynamically . My problem is i don't know how to use Dynamic Internal Table in my logic.

Can u please show mer with example having some logic and finally i have tio display in the grid.

Thanks,

Gopi.

Former Member
0 Kudos

Is there an upper limit to the number of such columns?

Easiest way is to define table with (say) 10 sets to start with and just hide / remove unused oned from the ALV field catalog so that they dont show.

Costs a bit in memory usage perhaps, but should not be an issue unless you report is an unusable size.

Andrew

uwe_schieferstein
Active Contributor
0 Kudos

Hello Anne

Perhaps the following sample report <b>ZUS_SDN_RTTI_CREATE_STRUC...</b> in thread

may be useful.

Regards

Uwe

Former Member
0 Kudos

I think Andrew has the simple answer to your problem i.e. just define an internal with as many columns as you could possibly need, and then hide any in the ALV report which ended up with no data i.e. just set the "fieldcat-no_out" flag to "X" to suppress them from the initial ALV output.

Jonathan