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?

Agile Talent Asked on December 18, 2020 in Product Collaboration.
Add Comment
1 Answer(s)

Nevermind.  I found an example in the SDK documentation.

explodeBOM(obj, pitem, 1);
private static void explodeBOM(IBaseScriptObj obj, IItem item, int level) throws APIException {
IRow     row;
String   bomNumber;
ITable   table = item.getTable(ItemConstants.TABLE_BOM);
Iterator it    = table.iterator();
    while (it.hasNext()) {
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;
}
Agile Talent Answered on December 18, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.