Create Mfg. Item Structure from Product Structure

Introduction

This document intended to provide a detailed guide and examples on how to write EKL script to Create Mfg Item structure from Product Structure

Version – Validated on 2021x FD09 (FP2140), 2022x FD01 (FP2205), 2023x FD02 (FP2314)

Pre-requisites:

Licenses –

  • CSV(Collaborative Industry Innovator)
  • MDG(Mechanical Designer)
  • PPL(Process Engineer)
  • KDI(Template Designer)

Disclaimer: Licenses mentioned above are as per 2021x, 2022x and 2023x documentation.

Logical Flow

Below is the logical flow for Creating Mfg. Item structure from product structure


Example

Create Mfg. Item Structure from Product Structure

Get Level of Product Item

Detail Explanation

Get list which includes root product and its children’s in same sequence as they appear in tree.

Below lines of code is responsible to get list of all “ProductOccurrence” including root product in a same sequence as they appear in the tree.

listOfProdOcc->AddItem(oRootProductOcc, 1) //Add root product to this list

//Find all the objects of type "ProductOccurrence" inside Root Product Occ
listOfChildProdOcc = oRootProductOcc->Query("ProductOccurrence", "") 

// Above list will be the entire list of ProductOccurrence objects available under Root Product node
listOfProdOcc = listOfProdOcc + listOfChildProdOcc //Add both the lists

Get level of Current Product from tree:

To get level of product item in tree, another EKL script is called by passing Product occurrence and a variable to store Level. The script returns the level of the passed product as output.

The below lines of code calls the external action file

oFindLevelAction.Run(oProdOcc, i)  //A action script which finds the level of occurrence in the tree

The Action file called above is attached in this page in Example section.

How to decide Mfg Item type, manage Make or Buy scenario and how to manage Multi-Instantiation

Make and Buy Scenario:

If it is needed to create a Provided Part for a Product, which is an assembly, but it is Outsourced or will be purchased from outside, the user needs to set the “V_description” attribute of that products items reference to “Buy” (The attribute is case sensitive. if specified as "BUY" it will not work.). The code will handle the scenario as given below.

If the user don’t need this scenario, just keep “V_description” of the products reference as either Make, blank or any other value than “Buy”.

Steps followed to decide Mfg item type:

  1. If the product item have children’s and its “V_description” attribute is not set as “Buy”, then create object of type Manufacturing Assembly.
  2. If the product have no children’s or its “V_description” attribute is set to “Buy”, then create Provided Part for the product.

Steps followed for managing Multi-Instantiation:

In the script, every time an new object is created, its reference is added in dictionary (Volatile instance) with V_Name(strPartNo) used as its key.

  1. Check if the reference with V_Name of item to be created is already available in Dictionary of existing objects.
  2. If the reference is not created previously, create a new reference and add it in Dictionary of existing object. Set attributes of new objects reference and instance.
  3. If the reference with V_Name of item to be created is available in dictionary, extract it and create its new instance. Set the attributes of newly instantiated object.

For example – Below script will manage multi-instantiation, Make or Buy Scenario and will decide which type of Mfg item to create:

If oListOfFilteredChildren.Size() > 0 and strDescription <> "Buy"
{
   strTypeToCreate = "CreateAssembly"
   new(strTypeToCreate, ProdTitle, NULL) 
   Trace(1, "Creation Time = ", BuildDate())
}
else
{
   strTypeToCreate = "Provide"
   /*if the dictionary of already available objects don’t have the object with current objects title,  
   then create a new object with same title as product item*/
   If oDicoExistingObjs.HasAttribute(ProdTitle) == false
   {
      new(strTypeToCreate, ProdTitle, NULL) 
      oDicoExistingObjs.SetAttributeObject(ProdTitle, oMfgItemRef)
      Trace(1, "Creation Time = ", BuildDate())
   }
   else
   {
      /*If the Mfg itsm object with current product items title is available in the dictionary of 
      already available objects, then just retrieve it from the dictionary */
      Set oMfgItemRef = oDicoExistingObjs.GetAttributeObject(ProdTitle)
      Trace(1, "Reuse Existing Time = ", BuildDate())
   }
}

Preventing creation of Children’s for Mfg item if its corresponding product item is set to buy

After creating new Mfg item, it is inserted under its parent.

  • If the level of item is 2, it is inserted under Root MID. If the corresponding product of current Mfg item is not set to “Buy”, its occurrence is added in dictionary of Mfg Objects with ProdTitle (v_name) as key.
  • If the level of item is greater than 2 and its parent/owner is available in the Dictionary of Mfg Objects: its owner’s occurrence is retrieved from dictionary of Mfg Objects using the owners “v_name” attribute as key. The current Mfg item is inserted under its owner. If the corresponding product of current Mfg item is not set to “Buy”, its occurrence is added in dictionary of Mfg Objects with ProdTitle (v_name) as key.

The code between below comments is responsible to manage insertion under correct parent and decides whether to create children’s or not for Make and Buy scenario.

//Insert the created object inside proper owner
.
.
//Insertion of Mfg Item Ends

How to set additional attribute and other custom attributes:

To set other extra attributes of the created objects, there is one string defined at the start of the EKL script. The attributes to be set are mentioned in this string separated by semicolon “;”. User can add more attributes in this string, which are needed to be set. The script will set the attributes mentioned in the string separated by “;”. No additional changes are required.

Note: While specifying attributes of Instance object, add “Inst_” as prefix in the attribute name. For example, for “V_description” of Instance, specify it as “Inst_V_description”

The below lines of code defines the string will attributes to be set or copied from product to MID item.

//Add more attribute names in below string, which are needed to be copied from product to Mfg item
Set oAttributeString = "V_description;Inst_V_description"

The string is split  at “;” and saved in a list as elements.

//Split the string to saperate attribute names
oListOfAttributes = SplitString(oAttributeString, ";")

Code between below comment is responsible for setting the Additional attributes.

//Set the Additional OOTB or Specialized attributes
.
.
//Setting Additional or OOTB attributes ends

Here under some Use Case about possible adaptation of the script

1. Copy one attribute of Product to another attribute of Mfg Item:

Add a new “If” block in the “If Else” nest in the code section where additional OOTB or specialized attributes are set. This code copies one attribute of Product item to other attribute of Mfg item. Ex. V_description of Product to V_Name of Mfg object. Add the new if block at start of “If else” nest.

If strAttribute == “Attribute Name of Product”
{
    if oProdRef.AttributeType(strAttribute) == "String"
    {
       strAttributeValue = oProdRef.GetAttributeString(strAttribute)
       strAttribute = “The Atrribute Name of System object to be Set”                                                              
       oMfgItemRef.SetAttributeString(strAttribute,strAttributeValue)
    }
    else if oProdRef.AttributeType(strAttribute) == "Real"
    {
       strAttributeValue = oProdRef.GetAttributeReal(strAttribute)
       strAttribute = “The Atrribute Name of System object to be Set”                                                             
       oMfgItemRef.SetAttributeReal(strAttribute,strAttributeValue.ToReal())
    }
    else if oProdRef.AttributeType(strAttribute) == "Integer"
    {                             
       strAttributeValue = oProdRef.GetAttributeReal(strAttribute)
       set intAttributeValue = strAttributeValue.ToReal()
       strAttribute = “The Atrribute Name of System object to be Set”                                                           
       oMfgItemRef.SetAttributeInteger(strAttribute, intAttributeValue)
    }
}

2. Requirement 2: Create specialized types of Mfg item as per requirement

If the user want to create specialized type of Mfg item, modify the lines of code mentioned below. Just modify the value of string “strTypeToCreate” with custom object type.

//Manage Make or Buy Scenario
If oListOfFilteredChildren.Size() > 0 and strDescription <> "Buy"
{
      strTypeToCreate = "CustomType"  //Just change this value with specialized object type
      Set oMfgItemRef = new(strTypeToCreate, ProdTitle, NULL) 
      /*Other code to manage object creation is added here. (Already available in script) */
}
else
{
      strTypeToCreate = "CustomType" //Just change this value with specialized object type
      /*Other code to manage object creation is added here. (Already available in script) */
}

How to Deploy

This video given below describes: How to deploy the "Create MID Structure from Product Structure" EKL Script?. However, the process is same for following EKL Script:
   1. Create Process Structure from Mfg. Item Structure

(Note: 
1. Instead of creating a separate Physical Product for containing each create structure EKL script, you can create the action files for the above EKL scripts in the same Physical Product that we are going to create for "Create Mfg. Item Structure from Product Structure" EKL Script.)

​​​​​​​

References link

<>

Author

Person of Contact - @KA