Hi,
I am having a problem with loops. Hope someone can help.
I am writing a dataport to import General Journal Line entries. Every entry is divided into several journal lines. All lines of an entry are identified by the document no. As for some entries I have a VAT difference, I would like the OnPostDataItem trigger to go through every document and to sum up the amounts of all lines referring to a G/L account and to compare the sum with the amount in the line referring to the customer account. If I have a VAT difference the highest of the G/L amounts should be adjusted. Therefore I tried the following:
FIND('-');
Comparer:='x';
REPEAT
LineNo:="Line No.";
IF "Document No."<>Comparer THEN BEGIN
Comparer:="Document No.";
Max:=0;
Summe:=0;
WHILE "Document No."=Comparer DO BEGIN
IF "Account Type"="Account Type"::Customer THEN BEGIN
InvoiceAmount:=Amount;
END ELSE BEGIN
Summe:=Summe+Amount;
IF ABS(Amount)>Max THEN BEGIN
Max:=ABS(Amount);
MaxLine:="Line No.";
END;
END;
NEXT;
END;
IF InvoiceAmount+Summe<>0 THEN BEGIN
GET('ALLGEMEIN','STANDARD',MaxZeile);
Amount:=Amount-Summe-InvoiceAmount;
VALIDATE(Amount);
"VAT Amount":="VAT Amount"-Summe-InvoiceAmount;
VALIDATE("VAT Amount");
MODIFY;
END;
GET('ALLGEMEIN','STANDARD',LineNo);
END;
UNTIL NEXT=0;
I am glad for every hint. Thanx already!
Jens
Comments
works perfect! Many, many thanks. You saved my day!!!
I kept on thinking about that problem all day. ](*,)
Jens