project QadFinancials > class TFRWTreeView > method GetFRWTreeLevel2NodeCreateNode
Parameters
icTargetChart | input | character | |
tNode | input-output | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/tfrwtreeview.p)
/* now we can start building the tree in the temp-table */
empty temp-table tparentlist.
empty temp-table tchildlist.
empty temp-table tnode.
/* we have to find the FRWAncode again, because during the column processing the buffer can be changed - was a defect */
find frwancode where frwancode.frwancodecode = vcancode and
frwancode.frwancodefrwchartcode = ictargetchart no-lock no-error.
if not available frwancode then do:
/*this analysis code has been changed and now belongs to another report chart
{us/bbi/pxmsg.i &MSGNUM=12417 &ERRORLEVEL=1 &MSGBUFFER=tcErrorMessage}*/
create tErrorTable.
assign tErrorTable.tcErrorMessage = trim(#T-83'This Analysis Code belongs to another Report Chart':255(75935415)T-83#)
oiReturnStatus = -1.
return.
end.
/* Getting the FRWTreeNode again,too */
find frwtreenode where frwtreenode.frwancode_id = frwancode.frwancode_id and
frwtreenode.parentfrwtreenode_id = 0 no-lock no-error.
if not available frwtreenode then do:
/*This Analysis Code is not defined on a Tree
{us/bbi/pxmsg.i &MSGNUM=11986 &ERRORLEVEL=1 &MSGBUFFER=tcErrorMessage} */
create tErrorTable.
assign tErrorTable.tcErrorMessage = trim(#T-38'This Analysis Code is not defined on a Tree.':255(245995331)T-38#)
oiReturnStatus = -1.
return.
end.
create tchildlist.
assign tchildlist.tichildlistnodeid = frwtreenode.frwtreenode_id
tchildlist.tichildlistparentnodeid = 0
tchildlist.tichildlistgeonumber = 0
tchildlist.tichildlistancodeid = frwancode.frwancode_id
tchildlist.tlistotalafter = frwtreenode.frwtreenodeistotalafter
tchildlist.tlishiddenrow = frwtreenode.frwtreenodeishiddenrow
tchildlist.tlishideamount = frwtreenode.frwtreenodeistextonly
tchildlist.tigeoincrement = 1000000000
tchildlist.tichildlistgeonumber = 0
tchildlist.tlisinvertactivitysign = frwtreenode.frwtreenodeisinvertactsign
tchildlist.tlisinvertbalancesign = frwtreenode.frwtreenodeisinvertbalsign
tchildlist.tlisblankrowbefore = frwtreenode.frwtreenodeisblankrowbefore
tchildlist.tlisblankrowafter = frwtreenode.frwtreenodeisblankrowafter
tchildlist.tcchildlistancodecode = frwancode.frwancodecode
tChildList.tcDescription = frwtreenode.frwtreenodedescription
tChildList.tcChildlistnodename = frwtreenode.FRWTreeNodeCode
virootnodeid = frwtreenode.frwtreenode_id.
assign viteller = 0
vlhiderootnode = no.
do while true:
/* each iteration goes 1 level deeper in the tree, until no more child-nodes are found */
/* the parent list from the previous loop is written to the final tamp-table tnode */
assign
viteller = viteller + 1.
for each tparentlist by tparentlist.tiparentlistnodeid by tparentlist.titreesequence:
create tnode.
assign tnode.tinodeid = tparentlist.tiparentlistnodeid
tnode.tiparentnodeid = tparentlist.tiparentlistparentnodeid
tnode.tigeonumber = tparentlist.tiparentlistgeonumber
tnode.tiancodeid = tparentlist.tiparentlistancodeid
tnode.tcancodecode = tparentlist.tcparentlistancodecode
tnode.tlistotalafter = tparentlist.tlistotalafter
tnode.tlishideamount = tparentlist.tlishideamount
tnode.tlishiddenrow = tparentlist.tlishiddenrow
tnode.tlisinvertbalancesign = tparentlist.tlisinvertbalancesign
tnode.tlisinvertactivitysign = tparentlist.tlisinvertactivitysign
tnode.tlisblankrowbefore = tparentlist.tlisblankrowbefore
tnode.tlisblankrowafter = tparentlist.tlisblankrowafter
tnode.tigeonumber = tparentlist.tiparentlistgeonumber
tNode.tcNodeDescription = tParentList.tcDescription
tNode.tiSequence = tParentList.titreesequence
tNode.tcNodeName = tParentList.tcParentlistnodename
tNode.tiAmountInView = viAmountInView.
if tparentlist.tlparentlisthasnochildren = no then assign tnode.tlisleaf = yes.
else assign tnode.tlisleaf = no.
if viteller = 2 then assign tnode.tlisroot = yes.
assign tnode.titreelevel = viteller - 1.
if tnode.titreelevel > vimaxlevel then assign vimaxlevel = tnode.titreelevel.
find frwancode where frwancode.frwancode_id = tnode.tiancodeid no-lock no-error.
if not available frwancode then do:
/*Error in tree structure. Node(#) has invalid analysis code ID #. Aborting program
{us/bbi/pxmsg.i &MSGNUM=11962 &ERRORLEVEL=1 &MSGARG1=string(tnode.qnodeid) &MSGBUFFER=tcErrorMessage} */
create tErrorTable.
assign tErrorTable.tcErrorMessage = trim(#T-58'Error in tree structure. Node(#) has invalid analysis code ID # '&1'. Aborting program.':255(818356836)T-58#, string(tnode.tinodeid))
oiReturnStatus = -1.
return.
end.
assign
tnode.tcanalysiscodetype = frwancode.frwancodeanalysetype
tnode.tcanalysiscodexbrl = frwancode.frwancodexbrelement
tnode.tcanalysiscodetaxonomy = frwancode.frwancodetaxoname
tnode.tcanalysiscodedesc = frwancode.frwancodedescription.
/* lookup the translated analysis code description */
if vlNeedTranslation then do:
find translationstring where translationstring.parentobject_id = frwancode.frwancode_ID and
translationstring.lng_id = viLanguageID no-lock no-error.
if available translationstring then assign tnode.tcanalysiscodedesc = translationstring.translationstringtext.
end.
if (tnode.tcanalysiscodetype = "t" or tnode.tcanalysiscodetype = "s") and tnode.tlisleaf = yes then
do:
assign tnode.tlisaddedtoparent = yes
tnode.tlhasallchildrenadded = yes.
if tnode.tiparentnodeid <> 0 then do:
find bnode where bnode.tinodeid = tnode.tiparentnodeid.
assign bnode.tlisleaf = yes
tnode.tlisleaf = no.
end.
end.
end. /* for each tparentlist */
if not can-find(first tchildlist) then leave.
/* there are no more child-nodes, so the tree is complete */
/* now we throw away the old parent list and replace it by the list of the child-nodes built in previous iteration */
for each tparentlist:
delete tparentlist.
end.
assign vicurrentparentid = 0.
for each tchildlist by tchildlist.tichildlistparentnodeid by tchildlist.titreesequence:
if vicurrentparentid = 0 then assign vicurrentparentid = tchildlist.tichildlistparentnodeid.
if vicurrentparentid <> tchildlist.tichildlistparentnodeid then do:
assign vicurrentparentid = tchildlist.tichildlistparentnodeid.
end.
create tparentlist.
assign tparentlist.tiparentlistnodeid = tchildlist.tichildlistnodeid
tparentlist.tiparentlistparentnodeid = tchildlist.tichildlistparentnodeid
tparentlist.tiparentlistancodeid = tchildlist.tichildlistancodeid
tparentlist.tcparentlistancodecode = tchildlist.tcchildlistancodecode
tparentlist.tlistotalafter = tchildlist.tlistotalafter
tparentlist.tlishideamount = tchildlist.tlishideamount
tparentlist.tlishiddenrow = tchildlist.tlishiddenrow
tparentlist.tlisinvertbalancesign = tchildlist.tlisinvertbalancesign
tparentlist.tlisinvertactivitysign = tchildlist.tlisinvertactivitysign
tparentlist.tlisblankrowbefore = tchildlist.tlisblankrowbefore
tparentlist.tlisblankrowafter = tchildlist.tlisblankrowafter
tparentlist.tigeoincrement = tchildlist.tigeoincrement
tparentlist.titreesequence = tchildlist.titreesequence
tparentlist.tiparentlistgeonumber = tchildlist.tichildlistgeonumber
tparentlist.tlparentlisthasnochildren = no
tParentList.tcDescription = tChildList.tcDescription
tParentList.tcParentlistnodename = tChildList.tcChildlistnodename.
delete tchildlist.
end.
/* now lookup the child-nodes of the new parent list */
for each tparentlist by tparentlist.tiparentlistparentnodeid by tparentlist.titreesequence:
assign vichildcount = 0.
/* find the children in the database */
for each frwtreenode where frwtreenode.parentfrwtreenode_id = tparentlist.tiparentlistnodeid no-lock:
assign vichildcount = vichildcount + 1.
end.
if vichildcount <> 0 then
assign vigeoincrements = integer(tparentlist.tigeoincrement / (vichildcount * 2)).
assign vichildcount = 0.
for each frwtreenode where frwtreenode.parentfrwtreenode_id = tparentlist.tiparentlistnodeid no-lock by frwtreenode.frwtreenodesequence:
assign vichildcount = vichildcount + 1.
assign tparentlist.tlparentlisthasnochildren = yes.
create tchildlist.
assign tchildlist.tichildlistnodeid = frwtreenode.frwtreenode_id
tchildlist.tichildlistparentnodeid = frwtreenode.parentfrwtreenode_id
tchildlist.tichildlistancodeid = frwtreenode.frwancode_id
tchildlist.tlistotalafter = frwtreenode.frwtreenodeistotalafter
tchildlist.tlishideamount = frwtreenode.frwtreenodeistextonly
tchildlist.tlishiddenrow = frwtreenode.frwtreenodeishiddenrow
tchildlist.tlisinvertactivitysign = frwtreenode.frwtreenodeisinvertactsign
tchildlist.tlisinvertbalancesign = frwtreenode.frwtreenodeisinvertbalsign
tchildlist.tlisblankrowbefore = frwtreenode.frwtreenodeisblankrowbefore
tchildlist.tlisblankrowafter = frwtreenode.frwtreenodeisblankrowafter
/* tchildlist.QChildListGEONumber = tparentlist.QParentListGEONumber */
tchildlist.tigeoincrement = vigeoincrements
tchildlist.tichildlistgeonumber = tparentlist.tiparentlistgeonumber + ((vichildcount - 1) * tchildlist.tigeoincrement) + 4
tchildlist.titreesequence = frwtreenode.frwtreenodesequence
tChildList.tcDescription = frwtreenode.frwtreenodedescription
tChildList.tcChildlistnodename = frwtreenode.FRWTreeNodeCode.
if tchildlist.tlistotalafter = yes then assign vichildcount = vichildcount + 1. /* done to make the geo-number jump so that there is room for the total after */
find frwancode where frwancode.frwancode_id = frwtreenode.frwancode_id no-lock no-error.
if not available frwancode then do:
/*Corruption: FRWTreeNode contains an invalid FRWAnCode_ID #
{us/bbi/pxmsg.i &MSGNUM=12021 &ERRORLEVEL=1 &MSGARG1=string(frwtreenode.frwancode_id) &MSGBUFFER=tcErrorMessage}*/
create tErrorTable.
assign tErrorTable.tcErrorMessage = trim(#T-94'Corruption: FRWTreeNode contains an invalid FRWAnCode_ID #'&1'.':255(129896324)T-94#, string(frwtreenode.frwancode_id))
oiReturnStatus = -1.
return.
end.
assign tchildlist.tcchildlistancodecode = frwancode.frwancodecode.
end.
end.
end.
/* assign leaf type */
for each tnode no-lock:
if tNode.tlIsleaf then assign tNode.tiLeafType = 1.
end.