BOM Journal Creation

1. Go to Inventory management > Journal entries > Items > Bills of materials.

2. Click New.

BOM Journal Creation in D365FO_ERP


3. In the Warehouse field, This should be the Warehouse where the Item in the Setup table is on-hand

4. Click OK.

BOM Journal Creation in D365FO_ERP_02


5. Click Functions.

BOM Journal Creation in D365FO_ERP_03


6. Click Report as finished.

BOM Journal Creation in D365FO_X++_04

7. Click New.

BOM Journal Creation in D365FO_X++_05


8. In the Item number field, enter or select a value.

BOM Journal Creation in D365FO_D365FO_06


9. Close the page.

BOM Journal Creation in D365FO_D365FO_07


10. In the Item number field, type a value.

11. In the Color field, enter or select a value.

BOM Journal Creation in D365FO_X++_08


12. Close the page.

BOM Journal Creation in D365FO_X++_09


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.

BOM Journal Creation in D365FO_ERP_10



*** 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();

}