6. September 2023 17:08
6. September 2023 17:52
7. September 2023 09:52
7. September 2023 10:09
7. September 2023 11:18
7. September 2023 13:45
FindParentNo(VAR DocTable : Record "DocTable") ParentNo : Code[20]
IF (DocTable."Previous No." = '') AND (DocTable."Follow-Up No." = '') THEN
EXIT('');
// wenn auf Parent selber
IF (DocTable."Previous No." = '') AND (DocTable."Follow-Up No." <> '') THEN
EXIT(DocTable."No.");
// wenn irgendwo unterhalb vom Parent
IF DocTable."Previous No." <> '' THEN BEGIN
ParentNo := DocTable."Previous No.";
REPEAT
IF DocTable2.GET(ParentNo) THEN BEGIN
IF DocTable2."Previous No." <> '' THEN
ParentNo := DocTable2."Previous No."
ELSE
ParentNo := DocTable2."No.";
END;
i+=1;
UNTIL (DocTable2."Previous No." = '') OR (i = 100);
END;
EXIT(ParentNo);
NewDocTableRec."Previous No." := OldDocTableRec."No.";
…
OldDocTableRec."Follow-Up No." := NewDocTableRec."No.";
…
ParentNo := FindParentNo(OldDocTableRec);
IF ParentNo <> '' THEN BEGIN
FollowUpTable."Initial Parent No." := ParentNo;
FollowUpTable."Follow-Up No." := NewDocTableRec."No.";
END ELSE BEGIN
FollowUpTable."Initial Parent No." := OldDocTableRec."No.";
FollowUpTable."Follow-Up No." := NewDocTableRec."No.";
END;
InsertOK := FollowUpTable.INSERT;