Explode a BOM in Groovy script
I am working on a event handler groovy script. While looking at a part, the script will be executed from a menu selection on the Actions menu. If the part has a BOM, I would like to fill an array with a unique list of the component part numbers. Not just the top level, but every level of that BOM. Is there some function or method to get this, or would some kind of recursive procedure need to be called to build that array?
Nevermind. I found an example in the SDK documentation.
IRow row;
String bomNumber;
ITable table = item.getTable(ItemConstants.TABLE_BOM);
Iterator it = table.iterator();
row = (IRow)it.next();
bomNumber = (String)row.getValue(ItemConstants.ATT_BOM_ITEM_NUMBER);
obj.logMonitor(“level: ” + (String)level + ” part: ” + bomNumber);
IItem bomItem = (IItem)row.getReferent();
explodeBOM(obj, bomItem, level + 1);
}
return null;
}