Hi,
While I am creating general journal getting below error
and afterward, debug it and found ledger.offsetLedgerDimension getting 0, here it is getting an error
if (isConfigurationkeyEnabled(configurationKeyNum(PublicSector))) is enabled in my Ax 2012 R3. So, I disabled the Public sector configuration key it will is resolved issue finally Post the general journal.
But I knew this is not a correct way to post the general journal so please advise me.
this is my code
static void LedgerJournal(Args _arg) { AxLedgerJournalTable axjournalTable; AxLedgerJournalTrans axjournalTrans; LedgerJournalTable journalTable; LedgerJournalCheckPost journalCheckPost; container acctPattern,offsetacctPattern; ; axjournalTable = new AxLedgerJournalTable(); axjournalTrans = new AxLedgerJournalTrans(); axjournalTable.parmJournalName("GenJrn"); axjournalTable.save(); axjournalTrans.parmJournalNum(axjournalTable.ledgerJournalTable().JournalNum); axjournalTrans.parmTransDate(systemDateGet()); axjournalTrans.parmCurrencyCode("USD"); axjournalTrans.parmAmountCurCredit(1000); axjournalTrans.parmAccountType(LedgerJournalAcType::Ledger); acctPattern = ['110180-001','110180',2,'BusinessUnit','001','Department','022']; axjournalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern)); axjournalTrans.parmOffsetAccountType(LedgerJournalActype::Ledger); offsetacctPattern = ['112000-002','112000',2,'BusinessUnit','002','Department','023']; axjournalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offsetacctPattern)); axjournalTrans.save(); journalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(axjournalTable.ledgerJournalTable(),NoYes::Yes); journalCheckPost.run(); info(strFmt("Journal No: %1",axjournalTable.ledgerJournalTable().JournalNum)); }
Regards,
John
*This post is locked for comments
Thanks crispin.
Add these clearField method before calling parmOffsetLedgerDimension()
axjournalTrans.clearField(fieldNum(LedgerJournalTrans, OffsetLedgerDimension), false);
the error is resolved.
Thanks for your support :)
In that case, it is highly unlikely that you will get an error saying "Customer 110180-001-022 does not exist"
Can you trace, which line from the above Code triggers the error? That will help narrow down to the exact cause.
I'm not changing 'cust' to 'ledger'
axjournalTrans.parmAccountType(LedgerJournalAcType::Ledger); this is correct code
while copying i made a mistake crispin
How does it work? After changing from "Cust" to "Ledger" ? Still getting some error?
Yes, you are correct.I made a mistake while copying the code...
this is correct code axjournalTrans.parmAccountType(LedgerJournalAcType::Ledger);
Any suggestion above the error ??
Regards,
John
There might be multiple Errors in your Code.
The first one I spotted, is this line.
axjournalTrans.parmAccountType(LedgerJournalAcType::Cust);
If it is of type Cust, your immediate next line ( where you set an accountPattern consisting of Ledger Dimension ) is contradicting.
I guess, the correct type is Ledger (not cust), (or Cust, and just the cust account, not ledger dimension)
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156