> I have three columns in a table. ParentID, ChildID, Description.
>
> How do I indent successive lines of child accounts in an
> accounting report in R:BASE for Windows when it is unknown
> as to how many children levels exist in the table?
Hi Tom. To do this, I think you need to do something that I generally
consider a bad design decision, which is to encode information into the
ChildID. The ChildID needs to encode the path through the tree to the
ultimate parent.
For instance if you use alpha codes for the areas, make them three chars
each:
United States = USA
Eastern US = EUA
etc.
Then the eastern US figures would be encoded USAEUA. You need to use an key
column wide enough to take your maximum number of levels (if you want to
allow for ten levels, you need thirty characters).
Once you do this, you can easily sort your report by the key column. This
will get everything in the right order. To get the indenting, use an
expression like:
vRegionName = (SFIL(' ', (SLEN(KeyColumn))) + RegionNameColumn
which will stick a variable number of spaces on the beginning of the region
name, depending on how deep you are in the tree. Place vRegionName in the
first column of the report -- it will be appropriately indented.
Two notes:
1. You can use numerically encoded text strings in place of character
strings, which will give you more control over the sort order of the child
nodes in the tree.
2. If you already have ids in place and don't want to muck with the existing
tables, you can implement this scheme on the side by adding a table with the
existing keys to encoded keys mapping, then joining the two tables together
in a view to do the report. You can maintain this table manually, or, with
triggers, make sure it is maintained automatically for you.
--
Larry
================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: INTRO rbase-l
================================================
TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: UNSUBSCRIBE rbase-l
================================================
TO SEARCH ARCHIVES:
http://www.mail-archive.com/rbase-l%40sonetmail.com/