Hi,
First off - don't blame me for the structure of this table ;-) I'm just trying to write a business view using this JDE table.
The table in question is the F0901 (Accounts Master) table in JD Edwards, which holds the entire account hierarchy.
What I need to do is to be able to start at a "leaf" on this table and "walk" back up the tree structure to the "root", using a recursive function, building a path between these two points as I go
I am having a brainstorm on exactly how to do this. My initial problem is that there is no self-referencing "foriegn key" in the table structure and the "key" that I have to use to find a parent is "compound".
The algorithm goes as follows:
For a child with a given business unit (GMMCU), account number (GMOBJ) and subsidiary account number (GMSUB), at a given level of the tree (GMLDA), the parent can be determined as the row:
- which has the same GMMCU as the child GMMCU
- which has a GMLDA one less than the child GMLDA
- which has the maximum (GMOBJ + GMSUB) that is less than or equal to the child (GMOBJ + SUB)
The description of the parent is held in GMDL01.
A "simplified" version of the code that I am currently using is:
SELECT
GM.GMDL01
FROM
F0901 GM
WHERE
GM.GMMCU = &Mcu
AND
GM.GMLDA = &ParentLevel
AND
(GM.GMOBJ || GM.GMSUB) =
( SELECT
MAX(GM1.GMOBJ || GM1.GMSUB)
FROM
F0901 GM1
WHERE
GM1.GMLDA = &ParentLevel
AND
GM1.GMMCU = &Mcu
AND
GM1.GMOBJ <= &Object
);
However, when running the recursive function, in which the above query is embedded, it is taking excessive amounts of time (30 minutes) to retrieve the paths for the approx 88,000 leaves that I need to do this for. I realise that there is an inefficiency in having "(GM.GMOBJ || GM.GMSUB)" on the LHS of the query, and I am sure there is way to do this using a correlated query, but I am stumped on how to do this with this compound key (MCU, OBJ & SUB)
Can anyone enlighten me - many thanks for any help you can provide.
Regards,
Harry Haines
First off - don't blame me for the structure of this table ;-) I'm just trying to write a business view using this JDE table.
The table in question is the F0901 (Accounts Master) table in JD Edwards, which holds the entire account hierarchy.
What I need to do is to be able to start at a "leaf" on this table and "walk" back up the tree structure to the "root", using a recursive function, building a path between these two points as I go
I am having a brainstorm on exactly how to do this. My initial problem is that there is no self-referencing "foriegn key" in the table structure and the "key" that I have to use to find a parent is "compound".
The algorithm goes as follows:
For a child with a given business unit (GMMCU), account number (GMOBJ) and subsidiary account number (GMSUB), at a given level of the tree (GMLDA), the parent can be determined as the row:
- which has the same GMMCU as the child GMMCU
- which has a GMLDA one less than the child GMLDA
- which has the maximum (GMOBJ + GMSUB) that is less than or equal to the child (GMOBJ + SUB)
The description of the parent is held in GMDL01.
A "simplified" version of the code that I am currently using is:
SELECT
GM.GMDL01
FROM
F0901 GM
WHERE
GM.GMMCU = &Mcu
AND
GM.GMLDA = &ParentLevel
AND
(GM.GMOBJ || GM.GMSUB) =
( SELECT
MAX(GM1.GMOBJ || GM1.GMSUB)
FROM
F0901 GM1
WHERE
GM1.GMLDA = &ParentLevel
AND
GM1.GMMCU = &Mcu
AND
GM1.GMOBJ <= &Object
);
However, when running the recursive function, in which the above query is embedded, it is taking excessive amounts of time (30 minutes) to retrieve the paths for the approx 88,000 leaves that I need to do this for. I realise that there is an inefficiency in having "(GM.GMOBJ || GM.GMSUB)" on the LHS of the query, and I am sure there is way to do this using a correlated query, but I am stumped on how to do this with this compound key (MCU, OBJ & SUB)
Can anyone enlighten me - many thanks for any help you can provide.
Regards,
Harry Haines