I have some calculations in the area of payroll which result in a lot of data each per month/year and two dates: an begin date (mm/yyyy) and an end date (mm/yyyy).
What I want: generating an internal table which has as many columns as begda-year till endda-year has (in years). For example my begda is 05/2010 and endda is 03/2013, then I need a table like this which has columns 2010, 2011, 2012, 2013 and rows for each month:
The difficult part for me is, that the table colums (or the endda and begda) are always varying, how could I realize this? Creating some kind of dynamic table?
Check CREATE DATA HANDLE documentation. I do not recommend to use
cl_alv_table_create=>create_dynamic_table
because of its internal limitations.How many years are going to be working with on general? Instead of thinking of it in terms of rows perhaps just remember that there are only as many rows in a table as you append to it.
You can create the dynamic structure through whichever means, either through create_data or cl_alv_table_create (which will work fine as long as you don't have several thousand columns).
So do psuedo code and help you out a bit:
I don't remember off the top of my head how to work with run-time created data, but a quick search on google can let you know that.
Check this code. Hope it helps: