Quintiq file version 2.0
#parent: #root
Method GetPISPIPs (
  Process_MP process,
  ProductInStockingPointInPeriod targetpispip,
  Boolean isupstream
) as structured[ProductInStockingPointInPeriod] id:Method_FormSupplyChainVisualization_GetPISPIPs
{
  #keys: '[134266.1.1803426731]'
  Body:
  [*
    // Get output or input PISPIPs of a process of a specific period
    // in alphabetical order
    pispips := null( ProductInStockingPointInPeriods );
    
    if( isupstream )
    {
      pispips := selectsortedset( process,
                                  ProcessInput.ProductInStockingPoint_MP.ProductInStockingPointInPeriod,
                                  pispip,
                                  pispip.Period_MP() = targetpispip.Period_MP()
                                  and ( not process.istype( LaneLeg )   
                                        or pispip.ProductInStockingPoint_MP().Product_MP() = targetpispip.ProductInStockingPoint_MP().Product_MP() ),
                                  pispip.ProductInStockingPoint_MP().IsSystem().AsQUILL()
                                  + pispip.ProductInStockingPoint_MP().Name() );
    }
    else
    {
      pispips := selectsortedset( process,
                                  ProcessOutput.ProductInStockingPoint_MP.ProductInStockingPointInPeriod,
                                  pispip,
                                  pispip.Period_MP() = targetpispip.Period_MP()
                                  and ( not process.istype( LaneLeg )   
                                        or pispip.ProductInStockingPoint_MP().Product_MP() = targetpispip.ProductInStockingPoint_MP().Product_MP() ),
                                  pispip.ProductInStockingPoint_MP().IsSystem().AsQUILL()
                                  + pispip.ProductInStockingPoint_MP().Name() );
    }
    
    return &pispips;
  *]
  ReturnsOwning: true
}
