Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Auto Posting Ledger Journal Take a Long Time

(0) ShareShare
ReportReport
Posted on by 555

Dear Experts,

I'm beginner develop dynamic ax, now creating auto post journal through X++ by using AxLedgerJournalTableClass and AxLedgerJournalTransClass

My data saved on my temporary table, then successfully create 1 journal with 1459 lines on 5 minute

Could I tune up my code to make it faster?

Here is Server Specification :

Processor     :  Intel i3 2.40Ghz

RAM             : 8 GB

And here is my code 

static void TestAutoPost(Args _args)
{
    AxLedgerJournalTable    journalTableClass;
    AxLedgerJournalTrans    journalTransClass;

    container ledgerDimension;
    container defaultDimension;

    VDI_LedgerJournal_Temp ledgerJournalTemp;
    LedgerJournalTable      ledgerJournalTable;
    LedgerJournalCheckPost  ledgerJournalCheckPost;
    int no = 1;

    DialogButton autopost;
    ;
    autopost = Box::yesNo("Do you want to auto post all journal?",DialogButton::Yes,"Auto Post Question");
    try{
        journalTableClass   = new AxLedgerJournalTable();

        select ledgerJournalTemp group by ledgerJournalTemp.JournalName,ledgerJournalTemp.Description;

        journalTableClass.parmJournalName(ledgerJournalTemp.JournalName);
        journalTableClass.parmName(ledgerJournalTemp.Description);
        journalTableClass.save();

        while
        select ledgerJournalTemp
        {
            journalTransClass   = new AxLedgerJournalTrans();

            journalTransClass.parmJournalNum(journalTableClass.ledgerJournalTable().JournalNum);
            journalTransClass.parmTxt(ledgerJournalTemp.LineDescription);
            journalTransClass.parmTransDate(ledgerJournalTemp.TransactionDate);
            journalTransClass.parmCurrencyCode(ledgerJournalTemp.CurrencyCode);
            journalTransClass.parmAmountCurDebit(ledgerJournalTemp.DebitAmount);
            journalTransClass.parmAmountCurCredit(ledgerJournalTemp.CreditAmount);
            defaultDimension = [1,"TransactionType",ledgerJournalTemp.LedgerDimension];
            journalTransClass.parmDefaultDimension(AxdDimensionUtil::getDimensionAttributeValueSetId(defaultDimension));
            journalTransClass.parmOffsetDefaultDimension(AxdDimensionUtil::getDimensionAttributeValueSetId(defaultDimension));
            journalTransClass.parmAccountType(LedgerJournalACType::Ledger);
            ledgerDimension = [ledgerJournalTemp.AccountNum+"-"+ledgerJournalTemp.LedgerDimension,ledgerJournalTemp.AccountNum,1,"TransactionType",ledgerJournalTemp.LedgerDimension];
            journalTransClass.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(ledgerDimension));
            journalTransClass.parmOffsetLedgerDimension(DimensionStorage::getDynamicAccount(ledgerJournalTemp.OffsetLedgerDimension, LedgerJournalACType::Bank) );
            journalTransClass.parmOffsetAccountType(LedgerJournalACType::Bank);
            journalTransClass.parmDocumentNum(ledgerJournalTemp.Document);
            journalTransClass.save();
            no++;
        }

        if(autopost == DialogButton::Yes){
            ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(journalTableClass.ledgerJournalTable(),NoYes::Yes);
            ledgerJournalCheckPost.run();
        }
        info(strFmt("Journal has been saved with %1 lines",no));
    }
    catch(Exception::Error){
        error(strFmt("Error at line %1",no));
    }
}


*This post is locked for comments

  • Bintang Profile Picture
    Bintang 555 on at
    RE: Auto Posting Ledger Journal Take a Long Time

    So far, make it to class is faster

    Big thanks for all respond

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Auto Posting Ledger Journal Take a Long Time

    You do not need to download it, the Trace parser tool is part of the AX installer DVD, that you could deploy. Use that explained in the blog article to collect information and analyze what is exactly slow in your case.

  • Bintang Profile Picture
    Bintang 555 on at
    RE: Auto Posting Ledger Journal Take a Long Time

    I did, and change it with firstonly but not significantly speed up performance

    I try to recreate code using service's classes : LedgerGeneralJournalService, LedgerGeneralJournal_LedgerJournalTable, LedgerGeneralJournal_LedgerJournalTrans, etc

    What do you think about it? Is it could speed it up?

  • Bintang Profile Picture
    Bintang 555 on at
    RE: Auto Posting Ledger Journal Take a Long Time

    I don't have access to download that tool

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Auto Posting Ledger Journal Take a Long Time

    You must capture an AX Trace for the code running on the AOS server, then analyze it using the AX Trace Parser Tool to see if it is the code, or if it is the SQL statement that is running slow. Or maybe it is running fast for a single row, but loops a million times which makes the total execution time high. You can only check it by verifying what is in the trace, and take action on it.

    See the Microsoft blog article about the tool:

    blogs.msdn.microsoft.com/.../dynamics-ax-trace-parser-part-3

    Also you should do an SQL Query Profiler trace as well for your database server while only your query is running to minimize noise, and then check the query plans executed for the report's select statement, to see if there are correct covering indexes, there are no index scans, and so on.

  • Bintang Profile Picture
    Bintang 555 on at
    RE: Auto Posting Ledger Journal Take a Long Time

    Hi all, thank for your respond

    I make it into a class method

    It takes 3 minute 14 second, faster than before

    any idea to make it faster?

    If it possible , I want it under 1 minute

    thank you

  • Verified answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Auto Posting Ledger Journal Take a Long Time

    The correct solution is what Crispin has suggested in case you only want to redesign your job.

    One piece I would add is that once you move the code server-side, make sure there are no user interactions in that piece (box class).

    However, consider other solutions as well like mentioned by the others. If you are importing/creating new journals, you may use the Data Import eXport Framework to do that, and process the created journal by a batch.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto Posting Ledger Journal Take a Long Time

    Hi!

    You can divide your journal (for example) into several journals (for example 1 journal 100 lines) in different transactions (and parallel post).

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,711 Super User 2024 Season 2 on at
    RE: Auto Posting Ledger Journal Take a Long Time

    Hi Tahta,

    What is exactly happening when you fill the temporary table? Are you trying to copy standard available functionality? See this page: Post multiple journals [AX 2012]. The journals can be posted using the batch framework, which will also speed up the process.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans