Create and post movement journal in AX 2012

static void createMovementJournalAx(Args _args)
{
AxInventJournalTable AxinventJournalTable = new AxinventJournalTable();
AxInventJournalTrans AxinventJournalTrans = new AxinventJournalTrans();
InventJournalNameId inventJournalName;
AxInventDim axinventDim = new axinventDim();
JournalCheckPost journalCheckPost;

//Below code creates journal header
//inventJournalTable.clear();
inventJournalName = InventJournalName::standardJournalName(InventJournalType::Movement);
AxinventJournalTable.parmJournalNameId(inventJournalName);
AxinventJournalTable.parmLedgerDimension(InventJournalName::find(inventJournalName).LedgerDimension);
AxinventJournalTable.save();

//Below code creates journal lines
//inventJournalTrans.clear();
// AXinventJournalTrans.inventJournalTableRecord(AxinventJournalTable.inventJournalTable());
AXinventJournalTrans.parmJournalId(AXinventJournalTable.parmJournalId());
AXinventJournalTrans.parmTransDate(systemDateGet());
AXinventJournalTrans.parmLedgerDimension(AxinventJournalTable.parmLedgerDimension());
//inventJournalTrans.ItemId = “S0010″;
// AXinventJournalTrans.inventTableRecord(InventTable::find(“S0010″));
AXinventJournalTrans.parmItemId(‘8.1134.434/14’);
AxinventJournalTrans.parmQty(10);
//AxinventJournalTrans.parmCostPrice(10);
// AxinventJournalTrans

axinventDim.parmInventSiteId(‘VIC’);
//inventDim.InventColorId = “Black”;
axinventDim.parmInventLocationId(‘AMT01GRWTH’);
// inventDim.wMSLocationId = ‘BULK-001′;
AxinventJournalTrans.parmInventDimId(inventDim::findOrCreate(axinventDim.inventDim()).inventDimId);
AxinventJournalTrans.save();
axinventDim.save();
//The below code posts the journal
journalCheckPost = InventJournalCheckPost::newPostJournal(AxinventJournalTable.inventJournalTable());
journalCheckPost.run();
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s