Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello All
I'm working to TDM to generate XML which contain multiple hierarchy looping. I wanted to try the FlatToHeirarchyLoop as the source is coming from Database. Can someone please help me in getting few examples of this type of loop?
Any help is appreciated.
Thanks!
Irshad
Hi,
Prerequesite is to have a field in your input file with level hierarchy. If not, you cannot use this kind of loop.
Here is an example:
-Your input file is:
<records>
<record>
<level>1</level>
<unitid>0001</unitid>
</record>
<record>
<level>2</level>
<unitid>0002</unitid>
</record>
<record>
<level>3</level>
<unitid>0003a</unitid>
</record>
<record>
<level>3</level>
<unitid>0003b</unitid>
</record>
<record>
<level>3</level>
<unitid>0003c</unitid>
</record>
<record>
<level>1</level>
<unitid>0004</unitid>
</record>
</records>
-You want to get this output file:
<Root>
<Record level="1">
<level>1</level>
<unitid>0001</unitid>
<Record level="2">
<level>2</level>
<unitid>0002</unitid>
<Record level="3">
<level>3</level>
<unitid>0003a</unitid>
</Record>
<Record level="3">
<level>3</level>
<unitid>0003b</unitid>
</Record>
<Record level="3">
<level>3</level>
<unitid>0003c</unitid>
</Record>
</Record>
</Record>
<Record level="1">
<level>1</level>
<unitid>0004</unitid>
</Record>
</Root>
-You define your input structure:
-You define your output structure as recursive
-In your map you create your loop:
Regards.
Eric
Hi,
Prerequesite is to have a field in your input file with level hierarchy. If not, you cannot use this kind of loop.
Here is an example:
-Your input file is:
<records>
<record>
<level>1</level>
<unitid>0001</unitid>
</record>
<record>
<level>2</level>
<unitid>0002</unitid>
</record>
<record>
<level>3</level>
<unitid>0003a</unitid>
</record>
<record>
<level>3</level>
<unitid>0003b</unitid>
</record>
<record>
<level>3</level>
<unitid>0003c</unitid>
</record>
<record>
<level>1</level>
<unitid>0004</unitid>
</record>
</records>
-You want to get this output file:
<Root>
<Record level="1">
<level>1</level>
<unitid>0001</unitid>
<Record level="2">
<level>2</level>
<unitid>0002</unitid>
<Record level="3">
<level>3</level>
<unitid>0003a</unitid>
</Record>
<Record level="3">
<level>3</level>
<unitid>0003b</unitid>
</Record>
<Record level="3">
<level>3</level>
<unitid>0003c</unitid>
</Record>
</Record>
</Record>
<Record level="1">
<level>1</level>
<unitid>0004</unitid>
</Record>
</Root>
-You define your input structure:
-You define your output structure as recursive
-In your map you create your loop:
Regards.
Eric
Just to clarify, the level number determines the depth of where to go in the output hierarchy. It's typically used with a recursive output hierarchy as Eric points out.
Thanks this works for me!
I know this is old thread, but I am having few levels being missed.
I followed the steps mentioned above.
I am attaching my input json and output json.any help is greatly appreciated.
Hi,
Could you add a sort function (It is probably expecting your levels are sorted in the input file):
Regards
Eric