What is it exactly that you wish to achieve. Is it only ordering and what is the correct order. Maybe you can put a code sample as well.
Please imagine a family (the rows where ParentID = NULL), each family can have a members which can be other family, brotheres, sisters etc...
When you put my example into tree you will have
Code:
MAIN
|-12
| |-91
|-07
|-04
| |-06
| |-02
| |-11
|-08
It will be enough to put data in correct order, but more usefull it will be to create also additional column with information about how deep in structure is each member, so I will be able to move data on report from left margin.
I was starting witch such code:
Code:
DEFINE TEMP-TABLE tmpMenu
FIELD tmpCounter AS INTEGER
FIELD tmpMenuID AS CHARACTER
FIELD tmpParentMenuID AS CHARACTER
FIELD tmpMenuDesc AS CHARACTER
FIELD tmpSequence AS CHARACTER.
DEFINE VARIABLE cParentID AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER INITIAL 0 NO-UNDO.
FOR EACH Menu:
iCounter = iCounter + 1.
END.
FOR EACH Menu WHERE MenuID = 'MAINMENU':
/*DISPLAY MenuID ParentMenuID MenuDesc.*/
cParentID = Menu.MenuID.
CREATE tmpMenu.
ASSIGN
tmpMenu.tmpCounter = iCounter
tmpMenu.tmpMenuID = Menu.MenuID
tmpMenu.tmpParentMenuID = Menu.ParentMenuID
tmpMenu.tmpMenuDesc = Menu.MenuDesc.
/*tmpMenu.tmpSequence = Menu.Sequence.*/
END.
REPEAT WHILE iCounter > 1:
FOR EACH Menu WHERE ParentMenuID = cParentID:
iCounter = iCounter - 1.
CREATE tmpMenu.
ASSIGN
tmpMenu.tmpCounter = iCounter
tmpMenu.tmpParentMenuID = Menu.ParentMenuID
tmpMenu.tmpMenuID = Menu.MenuID
tmpMenu.tmpMenuDesc = Menu.MenuDesc.
/*tmpMenu.tmpSequence = Menu.Sequence.*/
END.
cParentID = tmpMenu.tmpMenuID.
END.
FOR EACH tmpMenu BY tmpCounter DESCENDING:
DISPLAY tmpCounter tmpMenuID tmpParentMenuID tmpMenuDesc tmpSequence.
END.
DELETE tmpMenu.
But don't suggest this code as it's not working
, need to revew the my initial idea.
BTW I have problem with line
Code:
tmpMenu.tmpSequence = Menu.Sequence.
when uncommented the progress is complaining about wrong syntax. I know that there is a problem with word sequence but using "sequence" or 'sequence' is not resolving a problem.