Hi Everyone,
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::Cust);
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,
James