Thursday, March 12, 2020

X++ Create and post movement journal in AX 2012

static void createMovementJournalAx(Args _args)
{
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
InventJournalNameId inventJournalName;
InventDim inventDim;
JournalCheckPost journalCheckPost;

//Below code creates journal header
inventJournalTable.clear();
inventJournalName = InventJournalName::standardJournalName(InventJournalType::Movement);
inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalName ));
inventJournalTable.insert();

//Below code creates journal lines
inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.TransDate = systemDateGet();
inventJournalTrans.ItemId = "L0001";
inventJournalTrans.initFromInventTable(InventTable::find("L0001"));
inventJournalTrans.Qty = 25;
inventDim.InventSiteId = '1';
inventDim.InventLocationId = '13';
inventDim.wMSLocationId = '13';
inventJournalTrans.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;
inventJournalTrans.insert();


//The below code posts the journal
journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
journalCheckPost.run();
}


No comments:

Post a Comment

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