Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method FindCreatePISPIPNodeAndEdge ( 
 | 
  output owning shadow[SCVConfiguration] owner, 
 | 
  shadow[SCVNode] ownernode, 
 | 
  ProductInStockingPointInPeriod pispip, 
 | 
  Boolean isupstream, 
 | 
  Process_MP process, 
 | 
  output Number depth 
 | 
) as shadow[SCVNode] id:Method_FormSupplyChainVisualization_FindCreatePISPIPNodeAndEdge 
 | 
{ 
 | 
  #keys: '[133968.0.65085111]' 
 | 
  Body: 
 | 
  [* 
 | 
    // Create a node that the current node will link to 
 | 
    scvNode := this.GetPISPIPNode( &owner, ownernode, pispip, isupstream ); 
 | 
     
 | 
    if( isnull( scvNode ) ) 
 | 
    { 
 | 
      scvNode := this.CreateSCVPISPIPNode( &owner, pispip, false /*isroot*/ ); 
 | 
       
 | 
      // Establish their linkage 
 | 
      this.CreateSCVEdge( &owner, ownernode, scvNode, isupstream, process ); 
 | 
    } 
 | 
     
 | 
    // Quantity to grab edge value, so that we can truncate branch if the value is 0 
 | 
    quantity := 0.0;   
 | 
                                                                                                                                                                                                                                 
 | 
    this.ReturnEdgeLabel( &owner, ifexpr( isupstream, scvNode, ownernode ), ifexpr( isupstream, ownernode, scvNode ), quantity );        
 | 
     
 | 
    // Set depth to 0, meaning stop the drilling, 
 | 
    if( quantity = 0.0 and owner.IsHideZeroSupplyPaths() ) 
 | 
    { 
 | 
      scvNode.IsDepthLimitMet( true ); 
 | 
    } 
 | 
    else 
 | 
    { 
 | 
      // if it is upstream, we will generate inventory supply node, 
 | 
      // if it is downstream, we will generate sales demand node 
 | 
      if( isupstream ) 
 | 
      { 
 | 
        this.CreateSCVISNode( &owner, scvNode, pispip, isupstream ); 
 | 
      } 
 | 
      else 
 | 
      { 
 | 
        this.CreateSCVSDNode( &owner, scvNode, pispip, isupstream ); 
 | 
      } 
 | 
    } 
 | 
     
 | 
    value := max( owner, SCVNode, e,  
 | 
                  e.Depth() = scvNode.Depth()  
 | 
                  and e.IsUpstream() = scvNode.IsUpstream(),  
 | 
                  e.SortSequence() ); 
 | 
                   
 | 
    scvNode.SortSequence( value + 1 );  
 | 
     
 | 
    return scvNode; 
 | 
  *] 
 | 
} 
 |