‎2009 Sep 22 1:06 AM
Hello,
I am writing a report using different set hierarchy. The set(s) have multiple nodes, and I need an internal table for each of the nodes. If the report is using a set with 10 nodes 10 internal tables are required, if the set has 15 nodes 15 internal tables are needed.
Many times the set hierarchies get re-defined. New nodes get added, old nodes get deleted or reassigned to another hierarchy, etc. So after a while, the two sets may now have 12 nodes and 13 nodes (instead of 10, 15). Correspondingly the data declaration statements in the program have to be changed.
DATA: ITAB01 TYPE STANDARAD TABLE OF <STRUC01>,
ITAB02 TYPE STANDARD TABLE OF <STRUC02>,
......
ITAB09 TYPE STANDARD TABLE OF <STRUC09>,
ITAB10 TYPE STANDARD TABLE OF <STRUC10>.requires to be modified as
DATA: ITAB01 TYPE STANDARAD TABLE OF <STRUC01>,
ITAB02 TYPE STANDARD TABLE OF <STRUC02>,
......
ITAB09 TYPE STANDARD TABLE OF <STRUC09>,
ITAB10 TYPE STANDARD TABLE OF <STRUC10>,
ITAB11 TYPE STANDARAD TABLE OF <STRUC11>,
ITAB12 TYPE STANDARD TABLE OF <STRUC12>.Similarly,
DATA: ITAB01 TYPE STANDARAD TABLE OF <STRUC01>,
ITAB02 TYPE STANDARD TABLE OF <STRUC02>,
......
ITAB14 TYPE STANDARD TABLE OF <STRUC14>,
ITAB15 TYPE STANDARD TABLE OF <STRUC15>.requires to be changed to
DATA: ITAB01 TYPE STANDARAD TABLE OF <STRUC01>,
ITAB02 TYPE STANDARD TABLE OF <STRUC02>,
......
ITAB12 TYPE STANDARD TABLE OF <STRUC12>,
ITAB13 TYPE STANDARD TABLE OF <STRUC13>.Is there a way of coding the data declaration dynamically? I know about dynamic programs, but not sure if it is a good option, esp since we have many sets that have more than 100 nodes.
Or can you suggest some other way of writing these reports?
Thank you,
Fred.
‎2009 Sep 22 2:10 AM
Hello Fred,
That's a big task, even if it looks "easy". My first idea is, your request can not be covered by dynamic programming. a) every node has a different structure (I guess), b) the code itself has to be adjusted to the nodes in use as well. I.e. when a dynamic data declaration would be possible, the coding has to adhere the used number of nodes.
My recommendation:
- declare as many standard tables (nodes) as possible
- the code for each node has to be implemented
- define the number of used nodes by a parameter or an interface
Have success,
Heinz
‎2009 Sep 22 2:39 AM
Interesting though tough one.
You can use dynamic internal table creation (and it's work area) using:
CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
Have a read through Rich's Blog - [Dynamic Internal Tables and Structures - ABAP|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417800%29ID1759109750DB10206591421434314571End?blog=/pub/wlg/2071]
Good luck!
‎2009 Sep 24 10:13 PM
Heinz, Aabhas:
Thank you both for your time and suggestions. I could not go ahead with dynmic data declaration, so created deep structures to get what I needed.
Thank you very much again to you both,
Fred.