Create Part Instance from a Bill of Material

The extension of the product lifecycle management footprint to as-delivered, as-serviced, as-maintained configuration requires PLM solutions to be very adaptive to fit the industry evolving needs in terms of process to move from an engineering BOM to a manufacturing BOM and now to instances of these BOMs.

I was recently illustrating a development training class with such example to demonstrate how easy it was to create such a structure on the fly.

Here is the intended configuration. We start from the native part and part BOM to create a similar structure with every instance having a “definition” reference to their original part.

part BOM and instances

Here is the data model representation (the dotted line being a property of type item).

instances itemtype integration

The Instantiation Process

I’m posting the client side code we created during the training. Such processing should better be run server side to avoid stopping the process before it’s finished and for better performance.

create an instance of a Part

The first method you need is one to create the instance (here of type “InstancedPart”. The input is the part definition and the output is the instancePart id.

function createInstance (part){
   var newInstance = inn.newItem("InstancedPart","add");
   newInstance.setProperty("name",part.getProperty("name","noname"));
   newInstance.setProperty("definition",part.getID());
   newInstance = newInstance.apply();
   return newInstance.getID();
}

create an instance of a Part BOM

Then you need to create an instance of a part BOM, the relationship between two parts. In the data model I called this link “InstancedPartBOM”.

function createInstanceBOM(parentInstanceIdpart,childInstanceIdpart){
    var parentInstance = inn.newItem("InstancedPart","edit");
    parentInstance.setID(parentInstanceIdpart);
    var instanceBOM = parentInstance.createRelationship("InstancedPartBOM","add");
    instanceBOM.setProperty("related_id",childInstanceIdpart);
    parentInstance.apply();
    if (parentInstance.isError()){
        return false;
    }else {
        return true;
    }
}

process the children’s part level (recursive)

Once you have a query which returns the whole Bill of Material, you need to travel this BOM recursively from top to bottom and run the previously defined methods (part instance and part BOM instance) at every level of the BOM.

function instantiateChildren(parentItem,instanceId,fullBOM){
   var childBoms = parentItem.getRelationships("Part BOM");
   for (var j=0 ; j< childBoms.getItemCount();j++){
      var childBom = childBoms.getItemByIndex(j);
      var qty = childBom.getProperty("quantity","1");
      for (var k=0 ; k< qty;k++){
         var instanceNum = createInstance(childBom.getRelatedItem());
         var instanceBOM = createInstanceBOM(instanceId, instanceNum);
         if (!instanceBOM){
            aras.alertError("Failed");
         }
      instantiateChildren(childBom.getRelatedItem(),instanceNum);
      }
   }
   return true;
}

The full method:

The full method should be called by a client side action attached to an item of type “Part”. The action will send the selected item to the method. When starting the method we will query the full BOM before running a recursive instantiation, based on the previously defined methods.

Once again, this should better be done server side, but the code would almost be the same as the IOM is used the same way server side and client side. Take it as a “How to create and manipulate item structure with Aras Innovator” and use it and tweak it to fill your requirements.

Leave a Reply