BOM Journal Creation
1. Go to Inventory management > Journal entries > Items > Bills of materials.
2. Click New.
3. In the Warehouse field, This should be the Warehouse where the Item in the Setup table is on-hand
4. Click OK.
5. Click Functions.
6. Click Report as finished.
7. Click New.
8. In the Item number field, enter or select a value.
9. Close the page.
10. In the Item number field, type a value.
11. In the Color field, enter or select a value.
12. Close the page.
13. In the Color field, type a value.
14. In the Quantity field, This should be a negative to remove the “Nested”/BOM item from inventory
15. Select the Post now check box.
16. Click OK.
*** Before it posts make sure all lines are for the correct store warehouse.
模拟上面的操作,代码如下
public static void main(Args _args)
{
// Create journal
InventJournalTable inventJournalTable;
//Create record in the table
BOMParmReportFinish bomParmReportFinish;
InventJournalTrans inventJournalTrans;
bomParmReportFinish.initValue();
bomParmReportFinish.initParmDefault();
bomParmReportFinish.ParmId = NumberSeq::newGetNum(CompanyInfo::numRefParmId()).num();
bomParmReportFinish.JournalId = inventJournalTable.JournalId;
bomParmReportFinish.itemId = '1000084';
bomParmReportFinish.validateFieldValue(fieldstr(BOMParmReportFinish, ItemId));
bomParmReportFinish.initFromInventTable(InventTable::find(boMparmReportFinish.ItemId));
bomParmReportFinish.qty = -1;
bomParmReportFinish.validateFieldValue(fieldstr(BOMParmReportFinish, qty));
BOMId activeBOMId;
InventDim inventDim;
activeBOMId = BOMVersion::findActive(bomParmReportFinish.ItemId, boMparmReportFinish.TransDate, bomParmReportFinish.Qty, inventDim).bomId;
bomParmReportFinish.bomId = activeBOMId;
if (boMparmReportFinish.validateWrite())
{
boMparmReportFinish.insert();
}
//Post the journal
BOMReportFinish bomReportFinish;
JournalCheckPost journalCheckPost;
bomReportFinish = BOMReportFinish::newParmBuffer(bomParmReportFinish, true);
bomReportFinish.run();
}