Friday, November 27, 2015

Dynamics AX 2012 create and post General Journal Using X++

Create and  post General Journal Using X++

static void CreateGLJournalPost(Args _args)
{
AxLedgerJournalTable journalTable
AxLedgerJournalTrans journalTrans;
   
container acctPattern;
container offSetAcctPattern;
LedgerJournalTable ledgerJournalTable;
ledgerJournalCheckPost ledgerJournalCheckPost;

;
   
   
journalTable = new AxLedgerJournalTable();
journalTrans = new AxLedgerJournalTrans();
   
//Journal Name
journalTable.parmJournalName("GL");
journalTable.save();

journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum);
journalTrans.parmTransDate(systemDateGet());
journalTrans.parmCurrencyCode("SAR");
journalTrans.parmAmountCurDebit(1200);
   

acctPattern = ["11030101-01-02","11030101", 2, "Region","01","Branch", "02"];
journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern));
journalTrans.parmAccountType(LedgerJournalACType::Ledger);
   

offSetAcctPattern = ["41010101-01-02","41010101", 2, "Region","01","Branch", "02"];
journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offSetAcctPattern));
journalTrans.parmOffsetAccountType(LedgerJournalACType:: Ledger );
journalTrans.save();

ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(journalTable.ledgerJournalTable(),NoYes::Yes);
ledgerJournalCheckPost.run();
info(strFmt("Journal No. %1.", journalTable.ledgerJournalTable().JournalNum));
}

Thanks

1 comment: