Posting the Transfer Journal for a Item using X++ code in AX2009
static void CreateTransferJournal(Args _args)
{
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
InventJournalCheckPost inventJournalCheckPost;
NumberSeq num;
boolean _throwserror=true;
boolean _showinforesult=true;
InventDim frominventDim,ToinventDim;
;
ttsbegin;
inventJournalTable.clear();
num = new NumberSeq();
num = NumberSeq::newGetNum(InventParameters::numRefTransferId());
inventJournalTable.initFromInventJournalName(InventJournalName::find(InventParameters::find().TransferJournalNameId));
inventJournalTable.Description = "Inventory Transfer Journal";
inventJournalTable.SystemBlocked = true;
inventJournalTable.insert();
info("Entry Inserted");
info(strfmt("The Voucher generated is %1",inventJournalTable.JournalId));
inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.ItemId = "1101";
frominventDim.InventLocationId="21";
//frominventDim.configId = "02";
frominventDim.inventSiteId ="2";
ToinventDim.InventLocationId = "34";
ToinventDim.InventSiteId = "3";
// ToinventDim.configId = "02";
ToinventDim = InventDim::findOrCreate(ToinventDim);
frominventDim = InventDim::findOrCreate(frominventDim);
inventJournalTrans.InventDimId = frominventDim.inventDimId;
inventJournalTrans.initFromInventTable(InventTable::find("1101"));
inventJournalTrans.Qty = 10;
inventJournalTrans.ToInventDimId = ToinventDim.inventDimId;
inventJournalTrans.TransDate = SystemDateget();
inventJournalTrans.insert();
inventJournalCheckPost = InventJournalCheckPost::newJournalCheckPost(JournalCheckpostType::Post,inventJournalTable);
inventJournalCheckPost.parmThrowCheckFailed(_throwserror);
inventJournalCheckPost.parmShowInfoResult(_showinforesult);
inventJournalCheckPost.run();
inventJournalTable.SystemBlocked = false;
inventJournalTable.update();
ttscommit;
}
No comments:
Post a Comment