When an item (Released Product) is entered on a PO line, and the line is saved , system need to upload the document handling at the line level. All “External” documents contained on the PRODUCT related to the Released Product should be uploaded.
I also want to check BOM versions for the item and all items underneath it according to its valid, approved and active BOM (go down all levels of the BOM tree). If the above condition failed system should not upload and throw an error. Please check the below image for further reference.
I can able to relate how to avoid duplicate documents but regarding BOM its bit confusing as I could able to relate it with my code can u able to provide any code for me?
And also I am getting this error when i try to attach the document with the above code I mentioned earlier in my post,
What issue do you have with this code? Have you tried Docu::copy()?
This could be a issue,
docuRefProduct.RefTableId == (tableNum(ecoResProduct) || tableNum(inventTable)) &&
docuRefProduct.RefRecId == inventTable.Product &&
You should be doing something like below (calling the same method inside it).
Check if there circularity on BOM. If there is circularity, it may go into infinite loop.
Write a class and have a method like below,
In this example BOMFind is the class.
Note - the below code is only for your reference.
static void BOMFindMethod(BOMId _bomId)
{
BOM bom;
InventTable inventTable;
BOMId bomId;
while select bom
where bom.BOMId == _bomId
{
info(strFmt(’%1 → %2’, bom.BOMId, bom.ItemId));
inventTable = InventTable::find(bom.ItemId);
if (inventTable.isBOMAllowed())
{
bomId = inventTable.bomId(systemDateGet(), bom.BOMQty, bom.inventDim());
if (bomId)
{
BOMFind::BOMFindMethod(bomId);
}
}
}
}