Imoprt from csv file not creating a balancing line

navisionerinnavisionerin Member Posts: 161
hi guys, I am writing an import but its only creating one balancing line for my journal whereas I want it to create balancing line for each document No in the import. Here's my code. Not sure what I'm doing wrong?

WITH GenJnlLine DO BEGIN
SETRANGE("Journal Template Name",JournalTemplateName);
SETRANGE("Journal Batch Name",JournalBatchName);
SETRANGE("Line No.",FromLineNo,LineNo);
IF FINDSET THEN BEGIN
CLEAR(TempDimCode);
REPEAT
IF (xGenJnlLine."Source Line No." > 0) AND (NoOfDocLines = xGenJnlLine."Source Line No.") THEN BEGIN
InsertBalLine(xGenJnlLine,-Amt,-AmtLCY);
CLEAR(Amt);
CLEAR(AmtLCY);
CLEAR(NoOfDocLines);
END;
xGenJnlLine := GenJnlLine;
Amt += Amount;
AmtLCY += "Amount (LCY)";
NoOfDocLines += 1;
UNTIL NEXT = 0;
InsertBalLine(xGenJnlLine,-Amt,-AmtLCY);
GenJnlLine.MODIFYALL("Creditor No.",'');
GenJnlLine.MODIFYALL("Source Line No.",0);
END;
SETRANGE(Amount,0.0);
DELETEALL(TRUE);
END;
Sign In or Register to comment.