Delete a complete BOM (if any) using Batch Loader

オフライン

Hello,

I am learning how to use the batch loader to add a BOM to a specific part, but now I would like to do the opposite: I would like to come up with a script I can run with the Batch Loader that would delete a BOM regardless of how many components it has. How could I get started on this?

Regards,

PMateo

Parents
  • Hello guys, I just want to say thanks; the AML scripts suggested were fine, but I had an issue with the source_id of the parent parts. Right now the work-around I am using is to first run a query in SQL to get the part IDs from the item numbers, copy those to a txt file, and use the txt file as the input for the batch loader. So, just a small extra-step. Thank you everyone, and Jeff from Customer Support

  • オフライン in reply to pmateo

    If it is one time activity fine but if it is a regular activity you can create your own action and use it in AML

    Step 1: Create a C# method in ARAS named PartBOMDelete

    Step 2: Copy the below method


    Innovator inn = this.getInnovator();
    List < string > PartIDs = new List < string > ();
    var itemNumber = this.getProperty("parent_item");
    string getWhereClause = "[Part].item_number IN ('" + itemNumber.Replace(",", "','")+ "')";
    Item partItem = inn.newItem("Part", "get");
    partItem.setAttribute("select", "id");
    partItem.setAttribute("where", getWhereClause);
    partItem = partItem.apply();
    if (!partItem.isError())
    {
    int count = partItem.getItemCount();
    for (int i = 0; i < count; i++)
    {
    PartIDs.Add(partItem.getItemByIndex(i).getID());
    }
    }
    string partIdsInfo = string.Join("','", PartIDs);
    string deleteWhereClause = "[Part_BOM].source_id IN ('" + partIdsInfo + "')";
    if (!string.IsNullOrEmpty(partIdsInfo))
    {
    Item removeBom = inn.newItem("Part BOM", "delete");
    removeBom.setAttribute("where", deleteWhereClause);
    removeBom = removeBom.apply();
    if (removeBom.isError())
    {
    return inn.newError(removeBom.getErrorString());
    }
    }
    return inn.newResult("Part BOM deleted Successfully");

    Step 3: Save and Unlock the Method

    Step 4: Run the below AML query whenever required in Innovator Admin

    <AML>
    <Item action='PartBOMDelete' type='Method'>
    <parent_item>Itemnumber1,itemnumber2,itemnumber3</parent_item>
    </Item>
    </AML>

    Here we have created a custom action that will delete the Part BOM based on item number. Input here is Itemnumber1,itemnumber2,itemnumber3 and you can give any number of comma separated part number and note that it will delete only in latest generation.

    Thank You

    Gobikrishnan R

Reply
  • オフライン in reply to pmateo

    If it is one time activity fine but if it is a regular activity you can create your own action and use it in AML

    Step 1: Create a C# method in ARAS named PartBOMDelete

    Step 2: Copy the below method


    Innovator inn = this.getInnovator();
    List < string > PartIDs = new List < string > ();
    var itemNumber = this.getProperty("parent_item");
    string getWhereClause = "[Part].item_number IN ('" + itemNumber.Replace(",", "','")+ "')";
    Item partItem = inn.newItem("Part", "get");
    partItem.setAttribute("select", "id");
    partItem.setAttribute("where", getWhereClause);
    partItem = partItem.apply();
    if (!partItem.isError())
    {
    int count = partItem.getItemCount();
    for (int i = 0; i < count; i++)
    {
    PartIDs.Add(partItem.getItemByIndex(i).getID());
    }
    }
    string partIdsInfo = string.Join("','", PartIDs);
    string deleteWhereClause = "[Part_BOM].source_id IN ('" + partIdsInfo + "')";
    if (!string.IsNullOrEmpty(partIdsInfo))
    {
    Item removeBom = inn.newItem("Part BOM", "delete");
    removeBom.setAttribute("where", deleteWhereClause);
    removeBom = removeBom.apply();
    if (removeBom.isError())
    {
    return inn.newError(removeBom.getErrorString());
    }
    }
    return inn.newResult("Part BOM deleted Successfully");

    Step 3: Save and Unlock the Method

    Step 4: Run the below AML query whenever required in Innovator Admin

    <AML>
    <Item action='PartBOMDelete' type='Method'>
    <parent_item>Itemnumber1,itemnumber2,itemnumber3</parent_item>
    </Item>
    </AML>

    Here we have created a custom action that will delete the Part BOM based on item number. Input here is Itemnumber1,itemnumber2,itemnumber3 and you can give any number of comma separated part number and note that it will delete only in latest generation.

    Thank You

    Gobikrishnan R

Children