Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

General journal getting error

Posted on by 286

Hi,

While I am creating general journal getting below error 

4846.Screenshot_5F00_1.png

and afterward, debug it and found ledger.offsetLedgerDimension getting 0, here it is getting an error 

3566.Screenshot_5F00_2.png

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

  • Verified answer
    Peter John Profile Picture
    Peter John 286 on at
    RE: General journal getting error

    Thanks crispin.

    Add these clearField method before calling parmOffsetLedgerDimension()

    axjournalTrans.clearField(fieldNum(LedgerJournalTrans, OffsetLedgerDimension), false);

    the error is resolved.

    Thanks for your support :)

  • Crispin John Augustine Profile Picture
    Crispin John Augustine 37,081 on at
    RE: General journal getting error

    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.

  • Peter John Profile Picture
    Peter John 286 on at
    RE: General journal getting error

    I'm not changing 'cust' to 'ledger'

    axjournalTrans.parmAccountType(LedgerJournalAcType::Ledger); this is correct code

    while copying i made a mistake crispin

  • Crispin John Augustine Profile Picture
    Crispin John Augustine 37,081 on at
    RE: General journal getting error

    How does it work? After changing from "Cust" to "Ledger" ? Still getting some error?

  • Peter John Profile Picture
    Peter John 286 on at
    RE: General journal getting 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

  • Crispin John Augustine Profile Picture
    Crispin John Augustine 37,081 on at
    RE: General journal getting error

    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)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans