Indenting Trees
The snow has nearly all gone, just in time for the next batch! It was a douzy of a storm, fun driving conditions, amazing how much you forget over the hot dry 'roaded' summer. My newly licensed son was itching to get out there. Mom wouldn't let him, I had to agree, our insurance couldn't take it and we have way too many trees near our house. The trees looked very pretty thou and speaking of trees (what a segue) I have been asked numerous times if BIP can generate a tree structure, the more ambitious ask for an org chart. I plan to take a look at how to do the org chart another time, for now, how about a nice tree structure.
Between the two of us, Rob (colleague and data modeler extraordinaire) came up with a solution for a customer to generate this:

Its a tree of sorts, nothing fancy, we just wanted to get the structure right, so there are no details under the headings. Its getting the indenting correct that was the trick. The customer had a pretty fixed data structure and did not want to use nested tables.
The template is pretty simple, just a funky trick to get the indenting working. I mentioned the customer had a pretty fixed data structure. It made life easier, they only had 3 levels to worry about so the code to handle the indenting could be pretty straightforward and somewhat 'hard coded' for the data set.

It also has the advantage that the tree is in the right order ie
Level1
-Level2
-Level2
-- Level3
-Level2
Level1
Level1
...
The template looks like this

the fields contain

Of course the most interesting field is the C
<?if:number(LEVELS)=1?>
<?ORG_LONG_NAME?>
<?end if?>
<?if:number(LEVELS)=2?>
<?attribute@inblock:start-indent;'20.0pt'? > <?ORG_LONG_NAME?>
<?end if?>
<?if:number(LEVELS)=3?>
<?attribute@inblock:start-indent;'30.0pt'?> <?ORG_LONG_NAME?>
<?end if?>
A chhose statement would have worked just as well. You can see the dependence on the data order and the structure or more specifically LEVELS element. We need to check that to know how big the indentation should be.
The @block is also important, we need that to get the indentation to show only on the current text and not affect anything else. If we had been using tables we could have gotten around that.
Now we could have been a little smarter and written something to handle any number of levels ... answers on the back on a new Mac Book Pro 15-inch: 2.8GHz 4Gb 500Gb HD :0)





Recent Comments
Tim Dexter on Cool String Sorting: Hi Donal Sorry abou
Donal Slemon on Cool String Sorting: I really appreciate
tim on Indenting Trees: Hi Gareth Thanks, d
Gareth Roberts on Indenting Trees: Hi Tim, You've some
gBala on EBS R12 templates are here ... enjoy!: Tim -I want to see i
MD on Multi Database Data Templates: Hello Tim, Is there
Krishna on Adding OMR Marks: Hi, Is it possible
Oniaseth on What are you generating?: If you have to do it
amitmah on Conditional Rows and Columns: Hi I have some vari