Create System Structure from Mfg. Item Structure

Introduction

This document intended to provide a detailed guide and examples on how to write EKL script to create System Structure from Mfg Item Structure

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

Pre-requisites:

Licenses –

  • CSV(Collaborative Industry Innovator)
  • 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 System structure from Mfg. Item structure


Example

Create System Structure form Mfg. Item Structure EKL Script
Note: There is only one EKL script file for the "Create System Structure from Mfg. Item Structure" EKL script. Therefore no need of "Get Level" script.

Detail Explanation

Get list of children’s of Root Mfg. Item in same sequence as they appear in tree.

Below lines of code is responsible to get list of all “MfgProcessOccurrence” available under Root System

listOfMfgItemOcc = oRootMfgProcOcc->Query("MfgProcessOccurrence", "")//run a query to find mfg items
// This list will be the entire list of MfgProcessOccurrence objects available under selected Root Mfg Item Node

How to manage Outsourced Scenario

How to prevent Creation of Children’s of Outsourced Item:

When Mfg item have type “CreateAssembly”, its attribute “Outsourced” is checked.

  • If the Outsourced attribute is set to “Yes”, then a system object of type “General Operation” is created and its occurrence is not added in dictionary of Existing Objects.
  • If the Ousourced Attribute is set to “No”, then system object of type “General System” is created and its Occurrence is added in dictionary of existing object

Next time, when the iteration is going for an item, if its owner is available in Dictionary of Existing Objects, its owner is extracted from the dictionary. If the owner is not available, then the variable “strMfgItemType” is set to “NaN”. This skips all further steps and the loop goes for next item.

Below Lines of Code checks whether the Owner of item to be created is available or not and decided whether to create the item or not:

If oDicoSysObjs.HasAttribute(strOwnerName)
{
   //Get the ProdSysOcc from the dictionary of system occurrences
   ParentSysOcc = oDicoSysObjs.GetAttributeObject(strOwnerName)
}
else
   strMfgItemType = "NaN" 
//This prevents creation of further tree if one of the hierarchical owner is set as outsourced

Below Lines of Code is responsible for managing “Outsourced” scenario.

//Code to create system objects:
If strMfgItemType == "CreateAssembly"
{
     Set oCreateAssembly = currMfgItemRef //conver MfgItemRef to CreateAssembly                 
     strOutsourced = oCreateAssembly.V_Outsourced //Get the Outsourced attribute value                             
     If strOutsourced == "Yes"
     {
          oProdSysOcc = ParentSysOcc.InsertNewOperation(oOperationType)// Create new operation
          Set oOperationRef = oProdSysOcc.Reference
          oOperationRef.Name = strMfgItemName
          oProdSysOcc.AssignProcess(oFProcOcc)
          /*here we dont add the created object in dictionary of parents to prevent cration of items 
          under it */
     }
     else
     {
          //Create a new system
          oProdSysOcc = ParentSysOcc.InsertNewSystem(oSystemType)
          //Set the attribute values
          Set oSystemRef = oProdSysOcc.Reference
          oSystemRef.Name = strMfgItemName
          oDicoSysObjs.SetAttributeObject(strMfgItemName, oProdSysOcc) //Add the object in DicoSysObjs
     }
}

If user want to create custom operation type for outsourced item, it is needed to change the value of oOperationType. Also the variable type of oOperationRef needs to be changed accordingly.

Similary, for creating custom system type, value of “oSystemType” needs to be changes and variable type of oSystemRef will also change accordingly.

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 saperated by ";", 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 Mfg Item to another attribute of System 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 Mfg item to V_Name of System object. Add the new if block at start of “If else” nest.

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

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

If the user want to create specialized type of Operations, modify the EKL script as mentioned below.

  • Create a string variable to store specialized operation type at the beginning of script
Let CustoOperationTypeString(String)
Set CustoOperationTypeString = “Internal Type or Specialized type”
  • Create a variable to store Reference Object of Specialized Operation. Modify the variable type accordingly
Let oCustoOperationReference(Reference type for desired operation reference)
  • Add below “else if” block in “if else” nest, which manages to create different operation types. Modify the values as per the Specialized operation type
else if strMfgItemType == "Type of MFG Item currently reffering"

{
    oProdSysOcc = ParentSysOcc.InsertNewOperation(CustoOperationTypeString) 
    /*String CustoOperationTypeString is used here to decide type of operation to be 
    created */

    //Set the attributes
    Set oCustoOperationReference = oProdSysOcc.Reference  //The variable created above
    oCustoOperationReference.Name = strMfgItemName
    //Assign the Mfg item to the operation
    oProdSysOcc.AssignProcess(oFProcOcc)
    oDicoSysObjs.SetAttributeObject(strMfgItemName, oProdSysOcc)
}

3. Requirement 3: Create MID Structure and System Structure from Product Structure at once

If user wants to create both the MID Structure and System structure at once, one new EKL Script needs to be created which calls two EKL scripts, one is Create MID Structure from Product Structure (You can find it on this page) and other is Create System Structure From MID Structure (This script is attached above)

The code for new script is as given below:

/* Action created by KAE5 1/4/2022 */

/*
Input argument selection:
oRootProductOcc (ProductOccurrence): Root Product Object
oRootMfgProcOcc(MfgProcessOccurrence)
oRootSysOcc(ProdSystemOccurrence)
*/

Let CreateMIDStructFromPrdStruct(AdvisorAction)
Let CreateSysStructFromMIDStruct(AdvisorAction)
Set CreateMIDStructFromPrdStruct = `CreateStructures_EKL_SCripts A.1\\Relations\\Create MID Structure from Product Structure`
Set CreateSysStructFromMIDStruct = `CreateStructures_EKL_SCripts A.1\\Relations\\Create System Structure from MID Structure`

CreateMIDStructFromPrdStruct.Run(oRootProductOcc,oRootMfgProcOcc)  //Run the action to create MID structure

CreateSysStructFromMIDStruct.Run(oRootMfgProcOcc,oRootSysOcc) //Run the action to create System structure

PopupMessage("All The stuctures are created successfully!")

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.
2. For "Create Process Structure from Mfg. Item Structure" there is only one scripts file. So, create a action file as given in the video and set the input arguments as given in the script and the script will be ready to use. )


References link

<>

Author

For questions/improvements please refer to ​​@KA