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