error CIL when create ledger journal using X++

Hi,

I have an error like picture below when Create ledger Journal using Code X++

can you help me ?

Will you be able to show us your code to create journal?

changeCompany(silo)
{
ttsbegin;

select firstOnly numberSeqTable
where numberSeqTable.RecId == ledgerJournalName.NumberSequenceTable;

/select RecId from mainAccount
join dimensionAttributeValueCombination
where mainAccount.RecId == dimensionAttributeValueCombination.MainAccount
&& mainAccount.MainAccountId == account_get;
/

if (get_journal_entry != journalentry)
{
numberSeq = numberSeq::newGetVoucherFromCode(numberSeqTable.NumberSequence);
ledgerJournalTrans.Voucher = numberSeq.voucher();
get_voucher = ledgerJournalTrans.Voucher;

ledgerJournalTrans.Txt = refrence;
get_journal_name = ledgerJournalTrans.Txt;
ledgerJournalTrans.LedgerDimension = 5637153681;
//ledgerJournalTrans.LedgerDimension = mainAccount.RecId;

}else
{
ledgerJournalTrans.Voucher = get_voucher;
ledgerJournalTrans.Txt = get_journal_name;
//ledgerJournalTrans.LedgerDimension = mainAccount.RecId;
ledgerJournalTrans.LedgerDimension = 5637150618;
//AxLedgerJournalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern));
}
get_journal_entry = journalentry;

ledgerJournalTrans.JournalNum = axLedgerJournalTable.ledgerJournalTable().JournalNum;
ledgerJournalTrans.CurrencyCode = currencyid;
ledgerJournalTrans.ExchRate = Currency::exchRate(ledgerJournalTrans.CurrencyCode);

ledgerJournalTrans.AccountType = ledgerJournalACType::Ledger;
ledgerJournalTrans.AmountCurDebit = str2num(debit);
ledgerJournalTrans.AmountCurCredit = str2num(Credit);
ledgerJournalTrans.TransDate = trans_Date;
ledgerJournalTrans.OffsetLedgerDimension = 140567;

ledgerJournalTrans.insert();

//ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable, NoYes::Yes);
//ledgerJournalCheckPost.run();
ttsCommit;

}

It is unable to find the main account from the RecId that you are assigning either to LedgerDimension or OffserLedgerDimesnion. Please check the recId’s. If they are correct try to debug and see why it is not returning the main account.

Hi Kranthi,

so I must join MainAccount Table with DimensionAttributeValueCombination to get RecId ?
thanks

Need not be necessary. You should be knowing what values to be updated into ledgerDimesnion and offsetLedgerDimension. Enter a journal line manually with the expected values and see what values are updated in the ledgerJournalTrans table.
I am not really sure about the intention of your code. Are you just doing it for practice (or) is this something a real time logic that you are using to create a journal? Either way, you must think of building a ledgerDimenion/offsetLedgerDimension with the required values rather than hard coding it.

do you have reference code for create ledger journal ?
thanks

Here is a simple example from support team,
blogs.msdn.microsoft.com/…/

ledgerDimensions = [“131100-USA”,”131100″, 1, “COUNTRY”,”USA”];
can you explain value in code for ledgerdimension like above, because I use only main account, ex ledgerdimension = [“01-10-xxxxx”], like this can use ?

You can use ledgerDimensions = [“131100”,“131100”]

Hi,

I Have to try that acctPattern = [“01-00-11102”,“01-00-11102”];

but the ledgerdimension/accnumber cannot show in journal line like picture ,

what’s wrong ?

thanks

01-00-11102, is that only a main account (or) account and dimension combination?

that only main account, that format in my company using like that.

like this picture

mainaccount.PNG

that’s format wrong or what ?

thanks

That shouldn’t be a problem. Were you able to enter a journal manually with that main account?
If not check that the main account is allowed in the account structures.

yes , I could enter a journal manually,

i have check the main account was allowed in the account structures

pastedimage1480493515042v1.png

why ledgerdimension couldnot show in journal lines when I use acctPattern = [“01-00-11102”,“01-00-11102”]; ?

thanks

I don’t see any problem. Try to debug.