How to Create Transfer Journal in Dynamics AX 2012 Through X++
How to Create Transfer Journal in Dynamics AX 2012 Through X++
static void createTransfer(Args _args)
{
InventJournalTable inventJournalTable;
InventJournalNameId inventJournalName = 'Journal Name';
InventJournalTrans inventJournalTrans;
InventDim inventDim_From,inventDim_To;
InventJournalCheckPost journalCheckPost;
//header
inventJournalTable.clear();
inventJournalTable.JournalType = InventJournalType::Transfer;
inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalName));
inventJournalTable.insert();
//lines
inventDim_From.clear();
inventDim_From.InventLocationId = '01';
inventDim_From.modifiedField(fieldNum(InventDim,InventLocationId));
inventDim_From = InventDim::findOrCreate(inventDim_From);
inventDim_To.clear();
inventDim_To.InventLocationId = '02';
inventDim_To.modifiedField(fieldNum(InventDim,InventLocationId));
inventDim_To = InventDim::findOrCreate(inventDim_To);
inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.TransDate = systemDateGet();
inventJournalTrans.ItemId = '';
inventJournalTrans.initFromInventTable(InventTable::find(inventJournalTrans.ItemId));
inventJournalTrans.Qty = -1;
inventJournalTrans.InventDimId = inventDim_From.inventDimId;
inventJournalTrans.ToInventDimId = inventDim_To.inventDimId;
inventJournalTrans.CostAmount = inventJournalTrans.calcCostAmount();
inventJournalTrans.insert();
//Post
journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
journalCheckPost.run();
}
Comments
Post a Comment