yanweiyuan3
2023-10-26 a89f9faebe6e90c5cf1faeb1d551825e0cb2a06d
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
45
Quintiq file version 2.0
#parent: #root
Method SetIsLinkedWithFinishedGoodAttributes
{
  Description: 'Method to traverse the supply chain to determine if there are any products that are not used to produce finished goods.'
  TextBody:
  [*
    // Reset IsLinkedWithFinishedGood
    traverse( this, Global_MappingProduct_MP, instance )
    {
      instance.IsLinkedWithFinishedGood( false );
    }
    
    traverse( this, Global_MappingOperation, instance )
    {
      instance.IsLinkedWithFinishedGood( false );
    }
    
    traverse( this, Global_MappingOperationBOM, instance )
    {
      instance.IsLinkedWithFinishedGood( false );
    }
    
    productspool := selectset( this, Global_MappingProduct_MP, product,
                               product.ProductMajorType() <> "成品" );
    operationspool := this.Global_MappingOperation( relget );
    operationbomspool := this.Global_MappingOperationBOM( relget );
    
    // Traverse each finished good and search for linked products/operations/lanes
    traverse( this, Global_MappingProduct_MP, product,
              product.ProductMajorType() = "成品" )
    {
      uniquebomids := construct( Strings );
      product.IsLinkedWithFinishedGood( false );
      product.SetIsLinkedWithFinishedGoodAttributes_Recursive( 0, // depth
                                                               100, // maxdepth
                                                               productspool,
                                                               operationspool,
                                                               operationbomspool,
                                                               uniquebomids );
      uniquebomids := uniquebomids.Unique();
      product.BOMCount( uniquebomids.Size() );
    }
  *]
}