How to list out all the member who is under who for example I want list out the
member who is under Member 'A' Is that possible to list to the grid or tree? I would do that using a Treeview-control, as that represents the true structure best.
Filling the tree depends on the tree You want to use (MS, DBI, ...). I prefer the
TreView from DBI-Tech, but You can do it with the MS (that You already have <s>)
as well.
The principle is similar to what I sent You. You have an outer loop that scans
to the Member's table and adds a Parent-Node for each member. Then, before skipping
to the next member, call a subroutine, that creates the children and for each of
the children recursively calls itself if it finds children. Be careful to have all
variables in this subroutine being local and ideally make the selects into arrays.
Additionally to the parent-ID I passed in my subroutine, You will have to pass a
second parameter, the parent-level. This represents the Node-level (indentation of
the node) and is passed down adding one for each level.
That would be (*untested*) something like this
local ln_Level
ln_Level = 1
select MEMBERS
scan
=CreateNode(MEMBERS.ID, ln_Level)
=AddChildren(MEMBERS.ID, ln_Level)
endscan
function AddChildren (tc_Parent, tn_ParentLevel)
local ln_ThisLevel, ln_i
local array la_Dummy[1,2]
ln_ThisLevel = tn_ParentLevel + 1
select ID, ...;
from MEMBERS;
where Parent_ID = tc_Parent;
into array la_Dummy
if _tally # 0
for ln_i = 1 to alen(la_Dummy, 1)
=CreateNode(la_Dummy[ln_i, 1], ln_ThisLevel)
=AddChildren(la_Dummy[ln_i, 1], ln_ThisLevel)
endfor
endif
return
endfunc
function CreateNode(tc_MemberID, tn_NodeLevel)
wait window "Member: "+ tc_MemberID +" Level: "+ allt(str(tn_NodeLevel)) time 0.5
return
endfunc
HTH