InventJournalId journalNum;
JournalCheckPost journalCheckPost;
InventDim inventDim;
InventJournalTrans journalTrans;
InventJournalTable inventJournal;
JournalTableData journalTableData;
Counter lineNum;
InventLocation inventLocation;
public void createJournal()
{
this.createHeader();
this.createLine();
this.postJournal()
}
public void createHeader()
{
InventJournalName inventJournalName;
NumberSeq num;
num = NumberSeq::newGetNum(InventParameters::numRefInventJournalId());
journalNum = num.num();
inventJournalName = InventJournalName::find("JournalName");
inventJournal.initFromInventJournalName(inventJournalName);
inventJournal.JournalId = journalNum;
inventJournal.JournalType = InventJournalType::Movement;
inventJournal.Description = "Description";
inventJournal.insert();
journalTableData = JournalTableData::newTable(inventJournal);
lineNum++;
}
public void createLine()
{
inventDim.clear();
inventDim.initValue();
inventDim.InventSiteId = inventLocation.InventSiteId;
inventDim.InventLocationId = inventLocation.InventLocationId;
inventDim.wMSLocationId = inventLocation.WMSlocationIdDefaultIssue;
inventDim = InventDim::findOrCreate(inventDim);
journalTrans.clear();
journalTrans.initValue();
journalTrans.initFromInventJournalTable(inventJournal);
journalTrans.JournalType = inventJournal.JournalType;
journalTrans.TransDate = "Trans_Date";
journalTrans.ItemId = "ItemId";
journalTrans.InventDimId = inventDim.InventDimId;
journalTrans.initFromInventTable(InventTable::find("ItemId"));
journalTrans.LineNum = lineNum;
journalTrans.Qty = "Quantity";
journalTrans.CostAmount = journalTrans.Qty * journalTrans.CostPrice;
journalTrans.insert(false);
lineNum++;
}
public void postJournal()
{
inventJournal.selectForUpdate(true);
inventJournal.SystemBlocked = true;
inventJournal.update();
journalCheckPost = InventJournalCheckPost::newJournalCheckPost(JournalCheckPostType::Post, inventJournal);
journalCheckPost.run();
}
No comments:
Post a Comment