How to create a LedgerJournal? AX 2012 R2

Hi everybody,

I’m new in AX, and I want to create an LedgerJournal by X++.

Whats the best form to create it?

I actually use this form:

axLedgerJournalTable = AxLedgerJournalTable::construct();

axLedgerJournalTable.parmJournalName(journalName);

axLedgerJournalTable.parmName(_description);

axLedgerJournalTable.save();


axLedgerJournalTrans = AxLedgerJournalTrans::construct();

axLedgerJournalTrans.parmJournalNum(axLedgerJournalTable.ledgerJournalTable().JournalNum);

axLedgerJournalTrans.parmTransDate(str2Date(_date,123));

axLedgerJournalTrans.parmAccountType(LedgerJournalACType::Ledger);

axLedgerJournalTrans.parmLedgerDimension(_dimensionAccount);

axLedgerJournalTrans.parmTxt(_description);

axLedgerJournalTrans.parmCurrencyCode(validateCurrency.CurrencyAX);

axLedgerJournalTrans.GMA_parmOriginAccount(_originAccount);

if (_debit != 0)

{

axLedgerJournalTrans.parmAmountCurDebit(_debit);

}

else

{

if(_credit != 0)

axLedgerJournalTrans.parmAmountCurCredit(_credit);

}

axLedgerJournalTrans.save();


I only create the ledgerJournal, but when the user wants to register the LedgerJournal throws these errrors:

"The voucher “NumberOfVoucher” has already been used on the date “TodayDate”

"The voucher “NumberOfVoucher” has already been used on the date “TodayDate” and so on.

Why this happens ?

PD: Multiple users use the app for create ledgerJournals

Check the scope parameter for the number sequence. Make sure that is set to “Company”

Manually clean up the number sequence from Organization administration=> Common=> Number sequences=> Number sequences.

There is a problem with voucher generation, the code is resulting a voucher that has already been used.

Try to debug your code and see how the voucher number is set?