How to Create Movement in Dynamics AX 2012 Through X++
How to Create Movement in Dynamics AX 2012 Through X++
static void createMovement(Args _args)
{
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
InventDim inventDim;
container ledgerDimensions;
JournalCheckPost journalCheckPost;
//Journal
inventJournalTable.clear();
inventJournalTable.JournalType = InventJournalType::Movement;
inventJournalTable.initFromInventJournalName(InventJournalName::find('Journal Name '));
inventJournalTable.insert();
//Lines
inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.TransDate = systemDateGet();
inventJournalTrans.ItemId = '10001';
inventJournalTrans.initFromInventTable(InventTable::find(inventJournalTrans.ItemId));
inventJournalTrans.Qty = 1;
ledgerDimensions = ["1000000","1000000", 0];
inventJournalTrans.LedgerDimension = AxdDimensionUtil::getLedgerAccountId(ledgerDimensions);
inventDim.InventLocationId = '01';
inventDim.modifiedField(fieldNum(inventDim,InventLocationId));
inventJournalTrans.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;
inventJournalTrans.insert();
//Post
journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
journalCheckPost.run();
}
Comments
Post a Comment