Dear All,
I have written the procedure below. What it should do: i goes over a table with a for each, containing parent lines, as well as, child lines. I know that this doesn't work due to a problem with the buffer but i don't know how to solve this without having to write a seperate procedure for each level. (a child can have a child as wel). In the table every record has a unique sequence numer (= numHeader), a level numer (= numLevel) and a parentnumber ( (= numParent) this contains the sequence number of the parent).
What happens:
The first parent is found. This parent has 2 children (and these children have no children). So, the parent is written in the xml file. (see /*1*/ in code) The 2 children are written (by running the same procedure again). (see /2*/ in code) The for each ends and progress goes toe the "end procedure". (/*3*/ in de code) Then it goes back to the line under the RUN createsubelements(INPUT buf_listmst.numheader). (/*4*/ in de code) And this is where it goes wrong. Here the buffer is no more.
What can i do to solve this? i'm really out of ideas!
PROCEDURE createsubelements:
DEFINE INPUT PARAMETER numParent$v AS INTEGER NO-UNDO.
FOR EACH buf_listmst NO-LOCK
WHERE buf_listmst.reccode = ""
AND buf_listmst.company = "020"
AND buf_listmst.doccde = "ActRepy"
AND buf_listmst.numParent = numParent$v:
END PROCEDURE. /*3*/
Thanks a lot fot all ideas or suggestions.
best regards,
Elise
I have written the procedure below. What it should do: i goes over a table with a for each, containing parent lines, as well as, child lines. I know that this doesn't work due to a problem with the buffer but i don't know how to solve this without having to write a seperate procedure for each level. (a child can have a child as wel). In the table every record has a unique sequence numer (= numHeader), a level numer (= numLevel) and a parentnumber ( (= numParent) this contains the sequence number of the parent).
What happens:
The first parent is found. This parent has 2 children (and these children have no children). So, the parent is written in the xml file. (see /*1*/ in code) The 2 children are written (by running the same procedure again). (see /2*/ in code) The for each ends and progress goes toe the "end procedure". (/*3*/ in de code) Then it goes back to the line under the RUN createsubelements(INPUT buf_listmst.numheader). (/*4*/ in de code) And this is where it goes wrong. Here the buffer is no more.
What can i do to solve this? i'm really out of ideas!
PROCEDURE createsubelements:
DEFINE INPUT PARAMETER numParent$v AS INTEGER NO-UNDO.
FOR EACH buf_listmst NO-LOCK
WHERE buf_listmst.reccode = ""
AND buf_listmst.company = "020"
AND buf_listmst.doccde = "ActRepy"
AND buf_listmst.numParent = numParent$v:
IF CAN-FIND(FIRST buf2_Listmst NO-LOCK
WHERE buf2_Listmst.reccode = ""
AND buf2_Listmst.company = "020"
AND buf2_Listmst.doccde = "ActRepy"
AND buf2_Listmst.numparent = buf_listmst.numheader)
THEN DO:
ELSE hSAXWriter:WRITE-DATA-ELEMENT("level" + STRING(buf_listmst.numlevel), buf_listmst.desctext).
END. /*FOR EACH buf_listmst*/WHERE buf2_Listmst.reccode = ""
AND buf2_Listmst.company = "020"
AND buf2_Listmst.doccde = "ActRepy"
AND buf2_Listmst.numparent = buf_listmst.numheader)
THEN DO:
lok = hSAXWriter:START-ELEMENT("Level" + STRING(buf_listmst.numlevel)). /*1*/
hSAXWriter:INSERT-ATTRIBUTE("Titel", buf_listmst.desctext).
RUN createsubelements(INPUT buf_listmst.numheader). /*2*/
lok = hSAXWriter:END-ELEMENT("Level" + STRING(buf_listmst.numlevel)). /*4*/
END. /*IF CAN-FIND(FIRST buf2_Listmst*/hSAXWriter:INSERT-ATTRIBUTE("Titel", buf_listmst.desctext).
RUN createsubelements(INPUT buf_listmst.numheader). /*2*/
lok = hSAXWriter:END-ELEMENT("Level" + STRING(buf_listmst.numlevel)). /*4*/
ELSE hSAXWriter:WRITE-DATA-ELEMENT("level" + STRING(buf_listmst.numlevel), buf_listmst.desctext).
END PROCEDURE. /*3*/
Thanks a lot fot all ideas or suggestions.
best regards,
Elise