How to generate voucher for general journal using x++?

Hi All,

I am trying to create general journal header and lines using x++ code where the data is imported from excel, my header and n no of line for the header is creating successfully, but the voucher is generated differently for each line which causes the issue, how to generate voucher according to debit and credit balance using x++ coding, the obtained result of journal lines is attached below

Please suggest a solution.

Thanks,

Gopinath

Hi All,

I wanted to generate the voucher as populated in standard process so that it gets validated correclty, please suggest an answer. I am pasting my code for creating ledger journaltrans here. please suggest an answer.

numberSeq = NumberSeq::newGetVoucherFromId((ledgerjournalname.NumberSequenceTable));` LedgerjournalTrans.Voucher = numberSeq.voucher(); ```LedgerjournalTrans.JournalNum = LedgerjournalTable.JournalNum;
LedgerjournalTrans.CurrencyCode = ``"USD"``;` LedgerjournalTrans.ExchRate = Currency::exchRate(LedgerjournalTrans.CurrencyCode); ```LedgerjournalTrans.AccountType = LedgerJournalACType::Cust;
LedgerjournalTrans.parmAccount(conPeek(con, 2), LedgerjournalTrans.AccountType);` LedgerjournalTrans.Txt = conPeek(con, 1); ```LedgerjournalTrans.AmountCurCredit = conPeek(con, 3);
LedgerjournalTrans.TransDate = str2Date(conPeek(con, 4), 123);` LedgerjournalTrans.OffsetAccountType = LedgerjournalTable.OffsetAccountType; ```LedgerjournalTrans.OffsetLedgerDimension = LedgerjournalTable.OffsetLedgerDimension;
```LedgerjournalTrans.insert();`` `` ``Thanks, Gopinath`

Try using \Classes\LedgerJournalEngine\initValue

Can you please tell me how can i initialize the class… By using LedgerJournalTable

ledgerJournalEngine = new LedgerJournalEngine();
ledgerJournalEngine.ledgerJournalTable(ledgerJournalTable);
ledgerJournalEngine.initValue(ledgerJournalTrans);

Thanks Kranthi…

I am marking the thread as answered. Let me know if you think otherwise.