haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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 );
      }
    }
  *]
}