| Quintiq file version 2.0 | 
| #parent: #root | 
| Method LinkPISPs ( | 
|   PISPNodeInRoutings pispnodeinroutings, | 
|   Boolean asinput | 
| ) | 
| { | 
|   Description: 'Add pisp to all the operations in this routing step as operation input.' | 
|   TextBody: | 
|   [* | 
|     // Traverse through each operation in the routing step to link the PISP | 
|      | 
|     traverse( pispnodeinroutings, Elements, pispnodeinrouting ) | 
|     { | 
|       pispnodes := construct( PISPNodeInRoutings ); | 
|       pispnodes.Add( pispnodeinrouting ); | 
|       pisp := pispnodeinrouting.ProductInStockingPoint_MP(); | 
|      | 
|       /* | 
|         Link/unlink all pisps to the operations when either none or all | 
|         of the pisps are/are not linked to this operation. | 
|         If only some operations are linked, link the PISPs which are not | 
|         linked to the operations yet. | 
|       */ | 
|      | 
|       unlinkedoperations := selectset( this, Operation, op, | 
|                                        isnull( op.GetOperationBOM( pisp.ProductID(), pisp.StockingPointID(), true ) ) ); | 
|      | 
|       islinkedtoalloperations := unlinkedoperations.Size() = 0 // All operations are linked | 
|                                  or unlinkedoperations.Size() = this.Operation( relsize ); // All operations are unlinked | 
|      | 
|       // If all operations are/are not entirely linked to this PISP, select all operations within the routing step | 
|       if( islinkedtoalloperations ) | 
|       { | 
|         unlinkedoperations := selectset( this, Operation, op, true ); | 
|       } | 
|      | 
|       traverse( unlinkedoperations, Elements, op ) | 
|       { | 
|         op.LinkPISPs( pispnodes, true ); | 
|       } | 
|     } | 
|   *] | 
| } |