Create and Post general journal through X++

Got the solution

it is always recommed to use in standard way of using ,
so that it will populate the data in required table , so that you will not find the any problem

Refer below code, modify and write (for that event) where you want to create & post general journal accordingly.

Hope it will help you.

ttsbegin;
select firstonly LedgerJournalName order by JournalName desc where LedgerJournalName.JournalName like “JV*”
&& LedgerJournalName.Dimension[1] == CustInvoiceJour.Dimension[1];

_LedgerJournalTable.JournalName = LedgerJournalName.JournalName;
_LedgerJournalTable.Dimension[1] = LedgerJournalName.Dimension[1];
_LedgerJournalTable.initFromLedgerJournalName();
_LedgerJournalTable.insert();

//*************Inserted to General Journal Line
_numberSeq = NumberSeq::newGetVoucherFromCode(LedgerJournalName.VoucherSeries);
_LedgerJournalTrans.voucher = _numberSeq.voucher();
_LedgerJournalTrans.JournalNum = LedgerJournalName.JournalName;
_LedgerJournalTrans.Dimension[1] = LedgerJournalName.Dimension[1];
_LedgerJournalTrans.AccountType = LedgerJournalACType::Ledger ;
_LedgerJournalTrans.OffsetAccountType = LedgerJournalACType::Ledger ;
_LedgerJournalTrans.Txt = " Being amount credited against invoice no -" + CustInvoiceJour.InvoiceNumber;
_LedgerJournalTrans.AccountNum = CustINvoiceJour.OrderAccount;
_LedgerJournalTrans.AmountCurCredit = CustInvoiceJour.InvoiceAmount;
_LedgerJournalTrans.CurrencyCode = “INR” ;
_LedgerJournalTrans.ExchRate = Currency::exchRate(_LedgerJournalTrans.currencyCode);
_LedgerJournalTrans.OffsetAccount = CustVendRelation.VendAccountNum;
_LedgerJournalTrans.Approved = noyes::Yes ;
_LedgerJournalTrans.ApprovedBy = Curuserid() ;
_LedgerJournalTrans.TransDate = CustInvoiceJour.InvoiceDate;
_codenum = _LedgerJournalTrans.Voucher ;
_LedgerJournalTrans.insert();
// ************ End Creating Lines for Journal

ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(_LedgerJournalTable ,NoYes::Yes);
ledgerJournalCheckPost.run();
Info(“Journal Voucher” + _LedgerJournalTrans.JournalNum+" has been created & posted ! ");
ttscommit;

can you please explain me for what purpose LedgerJournalTableData ,LedgerJournalTransData, LedgerJournalStatic classes are used in creating payment journal lines and in my case if I directly assign customer account like US-025 to ledgerdimension field compile time error pops out.So for what purpose getDynamicAccount method is used in above coding?