Thursday, March 12, 2020

X++ Create and post Journal voucher

In this blog we will see how to write the job for Create and post Journal voucher in dynamics ax 2012.

static void legerDimCreateGLJournal(Args _args)
{
   AxLedgerJournalTable journalTable;
AxLedgerJournalTrans journalTrans;
container accCon;
container offSetCon;
LedgerJournalTable ledgerJournalTable;
ledgerJournalCheckPost ledgerJournalCheckPost;
;


journalTable = new AxLedgerJournalTable();
journalTrans = new AxLedgerJournalTrans();

//Journal Name
journalTable.parmJournalName("GenJrn");
journalTable.save();

journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum);
journalTrans.parmTransDate(systemDateGet());
journalTrans.parmAccountType(LedgerJournalACType::Ledger);

accCon = ["110110","110110", 2, "BusinessUnit","001", "Department", "023"];
journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(accCon));

journalTrans.parmAmountCurDebit(20);

journalTrans.parmOffsetAccountType(LedgerJournalACType:: Ledger );
offSetCon = ["110110","110110", 2, "BusinessUnit","001", "Department", "024"];
journalTrans.clearField(fieldNum(LedgerJournalTrans, OffsetLedgerDimension), false);
journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId( offSetCon));

journalTrans.save();

ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(journalTable.ledgerJournalTable(),NoYes::Yes);
ledgerJournalCheckPost.run();


info(strFmt("Journal No. %1.", journalTable.ledgerJournalTable().JournalNum));

}

No comments:

Post a Comment

Please do not add any spam link in the comment box.