| Quintiq file version 2.0 | 
| #parent: #root | 
| Method GetSupplyChain ( | 
|   GraphProgramGraph tree | 
| ) as String | 
| { | 
|   Description: 'Construct the CSV string of the product specific supply chain. Input is tree from Treeify algorithm' | 
|   TextBody: | 
|   [* | 
|     // Construct of strings, each element correspond to one line in CSV string | 
|     pisps_string := construct( Strings ); | 
|      | 
|     // Header in CSV string | 
|     pisps_string.Add( "product;upstream;downstream;leadtime") | 
|      | 
|     // Select root node of tree | 
|     root := select( tree, Nodes, node, node.Name() = MEIO_Treeify::GetArtificialRootName() ); | 
|      | 
|     // Traverse through all non-root nodes to create CSV rows | 
|     traverse( tree, Nodes, node, node <> root ) | 
|     { | 
|       downstream := node.Object1().astype( ProductInStockingPoint_MP ); | 
|       upstream_node := select( node, Input, n, true ); | 
|       if( not isnull( upstream_node ) ) | 
|       { | 
|         // Collect leadtime, upstream PISP name, downstream PISP name, and leadtime between the two | 
|         leadtime := [String]downstream.MEIO_Leadtime(); | 
|         upstream := upstream_node.Input().Object1().astype( ProductInStockingPoint_MP ); | 
|         upstreamName := guard( upstream.Name(), MEIO_Treeify::GetArtificialRootName() ); | 
|          | 
|         // Create a row for the CSV on the header-format | 
|         pisp_string := downstream.Product_MP().Name() + this.Separator() + upstreamName + this.Separator() + downstream.Name() + this.Separator() + leadtime; | 
|         pisps_string.Add( pisp_string ); | 
|       } | 
|     } | 
|      | 
|     value := pisps_string.ToString( String::NewLine() ); | 
|     Transaction::Transaction().Propagate( attribute( ProductInStockingPointInPeriodPlanningLeaf, IsActiveInMEIO ) );  | 
|      | 
|     return value; | 
|   *] | 
| } |