Inserting journal lines by code- Line numbers appear with negative sign

Hi,

I have added a new button on the Journal lines form and once clicked, it will display the records from a custom table and user can click on one of the record, after that System will create those many lines in the Journal lines table.

Everything is OK and even posting also is fine.

While looking at the LedgerJournalTrans table, I found that except the 1st line all lines have negative values.

I am putting the code below and attaching the ledgerjournal table screen shot.

Please advise

Thanks

Thomas


void clicked()
{
LedgerJournalTrans uPD_LedgerJournalTrans;
LedgerJournalTrans localLedgerJournalTrans;
MenaAxJLines menaAxJLines;
Dialog dialog;
DialogField dfJournalNum;
MenaAxJournalId journalID;
AmountCurDebit amtCurDebit;
AmountCurCredit amtCurCredit;
;

super();

dialog = new Dialog(“Select Payroll Journal(MenaPay)”);
dfJournalNum = dialog.addField(typeid(MenaAxJournalId)," MenaPay Journal No.");

if (dialog.run())
{
LedgerJournalTrans_ds.delete();
journalID = dfJournalNum.value();
menaAxJLines = MenaAxJLines::find(journalID);

ttsbegin;

while select menaAxJLines
order menaAxJLines.RecId asc // To retain the sequence of the lines, how the data entry user created it in the original application
where menaAxJLines.JournalNum == journalID
{
LedgerJournalTrans_ds.create();
LedgerJournaltrans.TransDate = MenaAXJLines.TransDate;
LedgerJournalTrans.AccountType = LedgerJournalACType::Ledger;
LedgerJournalTrans.AccountNum = MenaAXJLines.LedgerAccount;

//JournalFormTrans.enableButtonsActive();

LedgerJournalTrans.AmountCurDebit = abs(MenaAxJLines.DebitAmount);
LedgerJournalTrans.AmountCurCredit = abs(MenaAxJLines.CreditAmount);
LedgerJournalTrans.Txt = MenaAxJLines.Description + " (MenaPay Ref: “+ menaAxJLines.JournalNum +”)" ;
LedgerJournalTrans.Dimension[3] = MenaAxJLines.Dept;
LedgerJournalTrans.MenaAxJRN = MenaAXJLines.JournalNum;

LedgerJournalTrans_ds.write();

}
ttscommit;
LedgerJournalTrans_ds.research();
}

}