Transfer one level Teamcenter BOM based on data from Excel sheet using the Tc BOM Structure Synchronize Snap

This example pipeline demonstrates how to transfer a single-level BOM from an Excel sheet into Teamcenter, including the error handling branches.


Whole pipeline starting with File Reader and ending with File Writer Snap.

Steps

Note:

The example demonstrates how to create a BOM structure using source information. As source an excel file is choosen to be able to share it more easily. The implementation of BOM creation can be done in more then one way. This is the first approach described here. Other possible solutions will follow.

An Excel file contains pairs of Head and Child elements listed in rows to define BOM structure. Since creation of relation needs unique Teamcenter IDs (UID) to identify an existing object each head and child elements ID has to be given in excel. To keep the example simple only a One Level BOM is described. At the end uid information of BOM occurrence object shall be written to excel file.

Note:

UIDs in Teamcenter are as the name says UNIQUE. The UIDs in the excel file for this example only exist in our Teamcenter system as expected for our example. Generate your own objects e.g. with the Create Teamcenter elements based on data from Excel sheet and use the UIDs created there.


Excel sheet named 'BOM' with one header and columns to specifiy the name and UID of the head object and the child object to be related in BOM. Additionally column quantity defines values for BOM relation attribute in Teamcenter.

For the pipelines purpose this file will be uploaded and stored at SnapLogic.


An Excel file element is listed on SnapLogic project below files category.

As a first step a new pipeline has to be created.


pipeline_properties.png

First step in the pipeline will the read operation of the file. Here we utilize the File Reader Snap.


The file reader snap setting UI referes to the prior listed file.

This Snap is creating a binary stream which is needed to be processed now. It will be read by an Excel Parser to create a JSON document stream in the pipeline. Since the Excel sheet has a header row and the sheet is named as 'BOM', the appropriate setting in the Snap is done.


Parse field setting according to the Excel sheet with one header line and specified sheet name 'BOM'.

With the base information from excel (head UID, child UID) a BOM structure can be build in a format the Tc BOM Structure Synchronize Snap expects. The schema of the Snap input is described in documentation. Its minimal content is based on “lineObject” objects including a list object “children” which include itself a lineObject per BOM line and optional lineData for relation attributes. Additional some properties like “precise”, “bomViewType” and so on can be set.

{
    "lineObject": "", //place UID of head here
    "revisionRule": "Latest Working",
    "bomViewType": "view",
    "precise": false,
    "children": [
      {
        "lineObject": "",  //place UID of child here
        "lineData": {
          "bl_quantity": "1" //as example
        }
      }
    ]
}

First each row of excel is mapped to this schema in a Mapper Snap.


Mapper Snap with 8 rows in Mapping table. Expressions in Mapping table transform head information and one children information to target schema.

One head object can include n objects in children list. Currently we have n JSON documents each for one child as reflected in Excel file. To collect all children for one BOM head a Group By Fields Snap can be used.


snap_GroupByField.png

The output of the Snap is one groupBy lineObject since the example has only one BOM Head and a list of corresponding BOM rows for this BOM Head.


Output JSON of Group By Field Snap with one lineObject property in 'groupBy' JSON object and multiple objects in 'group'.

This can be mapped to the schema the Tc BOM Structure Synchronize Snap expects.


Mapping table of Mapper Snap removing 'group' embracing created by former Group Snap.

Output of Mapper Snap corresponds schema for Snap.


Output JSON of the Mapper Snap displaying BOM information in schema 1 lineObject with children list including n objects.

The document is send to Tc BOM Structure Synchronize Snap which can be configured like this. Expand attributes are set to minimize output content of Snap to only needed information. These attributes are:

  • object_name
  • object_string
  • bl_quantity
  • bl_occurrence
  • bl_occurrence_uid

Properties of Tc BOM Structure Synchronize Snap with field 'Structure data path' value is dollar sign and five configured 'Expand attributes'.

The output JSON can look like this.


JSON document of output View for the Tc BOM Synchronize Snap.

At the end the excel shall contain uid information of occurrences. JSON output of Tc BOM Structure Synchronize Snap will be transformed in two steps. First “lineObject” is renamed.


Mapping table with checkbox 'Pass through' set and expressions to rename 'lineObject' to 'headLineObject'.

Currentlly we have one JSON document but we need as much documents as we have children in the BOM to write rows in the excel file at the end. Therefore a Splitter Snap is used now. It is important to copy the “headLineObject” in each document since head information is included there.


Properties of Splitter Snap where path to split is children list.

Each document represents one future row in excel file now and content can be mapped to column named fields.


Mapping table displaying expression to map target path fields 'head', 'headUID', 'child', 'childUID', 'quantity' and 'occurrenceUID'.

Two error cases are configured in this pipeline:

  • parsing error in Parser Snap
  • error while BOM synchronization in Tc BOM Structure Synchronize Snap

Therefore two Union Snaps follow to close pipeline branches.


Settings of Union Snap.


Settings of Union Snap 2.

The input for next Snap which shall format JSON to excel format contains objects including information about each Bom Line.


JSON document including four objects which each has six properties.

The Excel Formatter Snap reads the documents, converts the documents in XLSX format using a specified sheet and writes out binary data.


Settings of Excel Formatter Snap.

Last but not least the File Writer Snap is used to store the file “Result_bom_OOTB.xlsx” in directory.


Settings of File Writer Snap.

Whole pipeline is finished.


Whole pipeline starting with File Reader and ending with File Writer Snap.

The file including result information is now stored at SnapLogic.


result excel file in Snaplogic directory.

The Teamcenter data for the newly created relations is now visible in the stored file.


Content of excel file shows tab 'TeamcenterBOMResult' with five rows (one head row included) and column A to F.

Error handling branches

Two error cases are configured in this pipeline:

  • parsing error in Parser Snap
  • error while BOM synchronization in Tc BOM Structure Synchronize Snap

Parsing error in Parser Snap

To provoke an Error in Parser Snap the setting of “Sheet name” is changed to a non existing sheet.


Settings of Parser Snap.

A Mapper Snap creates a document containing the error.


Mapper to pass parser error and to set target value of 'transferResult' to 'no transfer'.

The output of the Mapper Snap is lead to the second Union Snap metioned before.


Validation of pipeline for case 'Parsing error' shows documents flow.

The error is stored in excel file to be analysed.


Content of excel file shows tab 'TeamcenterBOMResult' with two rows (one head row included) and column A to B displaying the error.

Error while BOM synchronization in Tc BOM Structure Synchronize Snap

To provoke an error in Tc BOM Structure Synchronize Snap UID of one BOM child is changed by removing last char.


Source excel file content for BOM transfer. Field childUID for fifth bom child is marked to show changed value.

The error moves to error View of Snap.


Pipeline validation run where Tc BOM Snap has error and message goes to error branch.

At the end the excel shall contain error information and given head and child information. JSON output of Tc BOM Structure Synchronize Snap will be transformed in two steps. First “lineObject” is renamed.


Mapper Snap with two expressions in Mapping table. One for renaming lineobject to headLineObject and one for contextData to headContextData.

To get as much lines in excel as there were BOM lines children list of original message is splitted. Head information and error message are to be included in every resulting JSON document.


Settings of Splitter Snap for splitting children list. Include pathes are renamed properties of former snap and error message and stacktrace.

Each document represents one future row in excel file now and content can be mapped to column named fields. To former input information two columns are added for errorMessage and errorStacktrace.


Mapping table displaying expression to map target path fields 'head', 'headUID', 'child', 'childUID', 'quantity', 'errorMessage' and 'errorStacktrace'.

The error is stored in excel file to be analysed.


Excel content including errorMessage column.