Windchill REST Services > Windchill REST Services Domain Capabilities > Examples for Basic REST Operations > Examples for the PTC BOM Transformation Domain > Generating a Downstream Structure
  
Generating a Downstream Structure
By default, you can generate a downstream structure by adding a single or multiple copied parts from the upstream parent part to the downstream, as is. You can also generate a downstream structure based on the restructuring rules applied in the custom logic in Windchill. You can generate a downstream structure using an inline or specific upstream and downstream navigation criteria.
You can also generate the downstream structure in the context of change (change task or change notice).
* 
You can use the following API to fetch additional information of a part in the BOM structure required for this request:
POST /Windchill/servlet/odata/BomTransformation/XBOMParts('<RootPartOID>')/PTC.BomTransformation.GetManufacturingBOM?$expand=Components($levels=max)
Example: Generating a Downstream Structure with Restructuring Rules Not Configured in the Custom Logic
This example shows you how to generate a downstream structure where the upstream parts under the specified upstream root part are transferred or pasted as is to the specified downstream root part. In this example, the upstream root part has PartA1 (Design) and PartA2 (Design) parts under it. Use the following POST URI with the request body:
URI
POST Windchill/servlet/odata/BomTransformation/GenerateDownstreamStructure
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"DiscrepancyContext": {
"SourceRoot@odata.bind": "Parts('OR:wt.part.WTPart:241227')",
"TargetRoot@odata.bind": "Parts('OR:wt.part.WTPart:241207')",
"UpstreamNavigationCriteria@odata.bind": "NavigationCriterias('OR:wt.filter.NavigationCriteria:192828')",
"DownstreamNavigationCriteria@odata.bind": "NavigationCriterias('OR:wt.filter.NavigationCriteria:192832')"
}
}
The request adds PartA1 (Design) and PartA2 (Design) from the specified source (upstream) root part to the specified target (downstream) equivalent root part, as is. The request creates new equivalence links between the downstream BOM and the upstream BOM. The request also returns usage links for the two downstream parts.
Example: Generating a Downstream Structure Based on the Part Attribute with Restructuring Rules Configured in the Custom Logic
This example shows you how to generate a downstream structure based on the part attribute. In this example, the upstream parts under the specified upstream parent part are transferred or pasted to the downstream parent part based on the restructuring rules applied in the custom logic.
In this example, the specified source (upstream) parent part has PartA1 (Design) with Attribute1 as String1 and PartA2 (Design) with Attribute3 as String3, under it.
The specified target (downstream) parent part has PartC1 (Manufacturing) with Attribute2 as String2 and PartC2 (Manufacturing) with Attribute4 as String4, under it.
The following restructuring rules are configured in the associativity.properties.xconf file, for example:
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="transformoption=newPart"/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="targetType=wt.part.WTPart"/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="attributeMapping.rule1=Attribute1:String1:Attribute2:String2"/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="attributeMapping.rule2=Attribute3:String3:Attribute4:String4"/>
Use the following POST URI with the request body:
URI
POST Windchill/servlet/odata/BomTransformation/GenerateDownstreamStructure
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"DiscrepancyContext": {
"SourceRoot@odata.bind": "Parts('OR:wt.part.WTPart:245133')",
"SourcePartSelection": [
{
"Part@odata.bind": "Parts('OR:wt.part.WTPart:245307')"
}
],
"TargetRoot@odata.bind": "Parts('OR:wt.part.WTPart:245064')",
"TargetPart@odata.bind": "Parts('OR:wt.part.WTPart:245078')",
"UpstreamNavigationCriteria@odata.bind": "NavigationCriterias('OR:wt.filter.NavigationCriteria:192828')",
"DownstreamNavigationCriteria@odata.bind": "NavigationCriterias('OR:wt.filter.NavigationCriteria:192832')"
}
}
Upon executing the request, the Windchill system traverses the structure below the specified downstream parent part and ensures that:
When it detects a part with Attribute1 set to String1, it adds PartA1 (Design) as a new part, that is, PartA1 (Manufacturing) along with its attribute value, under the downstream part PartC1 (Manufacturing). This is because PartC1 (Manufacturing) has Attribute2 set to String2, and its part type is wt.part.WTPart.
When it detects a part with Attribute3 set to String3 , it adds PartA2 (Design) as a new part, that is, PartA2 (Manufacturing) along with its attribute value, under the downstream part PartC2 (Manufacturing). This is because PartC2 (Manufacturing) has Attribute4 set to String4, and its part type is wt.part.WTPart.
The request creates new equivalence links and usage links for both the new downstream parts.
Example: Generating a Downstream Structure in the Context of Change
This example shows you how to generate a downstream structure in the context of change. In this example, the upstream parts under the specified upstream root part are transferred or pasted as is to the specified downstream root part. In this example, the upstream root part has PartA1 (Design) and PartA2 (Design) parts under it. Use the following POST URI with the request body:
URI
POST Windchill/servlet/odata/BomTransformation/GenerateDownstreamStructure
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"DiscrepancyContext": {
"SourceRoot@odata.bind": "Parts('OR:wt.part.WTPart:436496')",
"TargetRoot@odata.bind": "Parts('OR:wt.part.WTPart:436477')",
"UpstreamNavigationCriteria@odata.bind": "NavigationCriterias('OR:wt.filter.NavigationCriteria:197478')",
"DownstreamNavigationCriteria@odata.bind": "NavigationCriterias('OR:wt.filter.NavigationCriteria:197482')"
},
"ChangeOid": "VR:wt.change2.WTChangeActivity2:436638"
}
The request adds PartA1 (Design) and PartA2 (Design) from the specified source (upstream) root part to the specified target (downstream) equivalent root part, as is. The request adds the modified target root part to the Resulting Objects table of the change object specified in the ChangeOid attribute.
To see more details, expand the upstream parts, downstream parts, equivalent links, and usage links.
URI with Expand
POST Windchill/servlet/odata/BomTransformation/GenerateDownstreamStructure?$expand=UpstreamPart($select=ID,Identity),DownstreamPart($select=ID,Identity),EquivalenceLink($select=ID,Annotations,DownstreamContext,UpstreamContext),UsageLink($select=ID;$expand=Uses($select=ID,Identity),UsedBy($select=ID,Identity))