Kevin Kok Khah Whey
2023-11-07 5ae534ab606e6f2ba5ea60914224d665b0447d5a
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
Quintiq file version 2.0
#parent: #root
Method SynchronizeDataToMacroPlan (
  MacroPlan macroPlan,
  String executionUser,
  Boolean isUnitOfMeasure_MP,
  Boolean isCustomOrder,
  Boolean isForeacst,
  Boolean isSalesSegment_MP,
  Boolean isProduct_MP,
  Boolean isConversionFactor,
  Boolean isOperation,
  Boolean isOperationBOM,
  Boolean isProductInLane,
  Boolean isAIPISPIP,
  Boolean isInventorySupply,
  Boolean isStockingPointCost,
  Boolean isOperationCost,
  Boolean isDOI_DSI,
  Boolean isCustomerGrade,
  Boolean isStockingPoint_MP,
  Boolean isCurrency_MP,
  Boolean isCurrencyRate_MP,
  Boolean isLane,
  Boolean isLaneLeg
)
{
  TextBody:
  [*
    organcodelist := selectvalues( this, Global_MappingOperationBOM, bom,true, bom.OrganCode() );
    businessTypes := macroPlan.BusinessType().Tokenize( "," );
    if( not isnull( businessTypes ) and businessTypes.Size() > 0 ) {
        traverse( businessTypes, Elements, item ) {
            info( "Business type : " + item )  
        }
        organcodelist := selectvalues( this, BusinessType.OrganCode, organ, businessTypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() );
    }
    else{
      if( businessTypes.Size() = 0 ){
        if( not isnull( selectset( this, BusinessType, b, b.BusinessTypeName() = "" ) ) ){
          organcodelist := selectvalues( this, BusinessType.OrganCode, organ, organ.BusinessType().BusinessTypeName() = "", organ.OrganCodeName() );
          }
        }
      }
    
    if( organcodelist.Size() = 0 ){
      organcodelist := selectuniquevalues( this, Global_MappingOperationBOM, bom,true, bom.OrganCode() );
      }
    
    macroPlan.InitialUnitAndStockingPoint();
    
    if ( isUnitOfMeasure_MP ) {
      Global_MappingUnitOfMeasure_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser );
    }
    
    if ( isCustomOrder ) {
      Global_MappingCustomOrder::SynchronizeMacroPlanData( this, macroPlan, businessTypes, organcodelist, executionUser );
    }
    
    if ( isForeacst ) {
      Global_MappingForecast::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist );
    }
    
    if ( isSalesSegment_MP ) {
      Global_MappingSalesSegment_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes );
    }
    
    if ( isProduct_MP ) {
      Global_MappingProduct_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, macroPlan.IsKeyProduct() );
    }
    
    if ( isConversionFactor ) {
      Global_MappingConversionFactor::SynchronizeMacroPlanData( this, macroPlan, executionUser );
    }
    
    if ( isOperation ) {
      Global_MappingOperation::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist );
    }
    
    if ( isOperationBOM ) {
      Global_MappingOperationBOM::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist, macroPlan.IsKeyProduct(), macroPlan.CreatePurchaseSupplyMaterial() );
    }
    
    if ( isProductInLane ) {
      Global_MappingProductInLane::SynchronizeMacroPlanData( this, macroPlan, businessTypes, executionUser );
    }
    
    if ( isAIPISPIP ) {
      Global_MappingActualProductInStockingPointInPeriod::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist, macroPlan.IsKeyProduct() );
    }
    
    if ( isInventorySupply ) {
      Global_MappingInventorySupply::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist, macroPlan.IsKeyProduct() );
    }
    
    if ( isStockingPointCost ) {
      Global_MappingStockingPointCost::SynchronizeMacroPlanData( this, macroPlan, businessTypes, executionUser );
    }
    
    if ( isOperationCost ) {
      Global_MappingOperationCost::SynchronizeMacroPlanData( this, macroPlan, executionUser, businessTypes, organcodelist );
    }
    
    if ( isStockingPoint_MP ) {
      Global_MappingStockingPoint_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser );
    }
    
    if ( isCurrency_MP ) {
      Global_MappingCurrency_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser );
    }
    
    if ( isCurrencyRate_MP ) {
      Global_MappingCurrencyRate_MP::SynchronizeMacroPlanData( this, macroPlan, executionUser );
    }
    
    if ( isLane ) {
      Global_MappingLane::SynchronizeMacroPlanData( this, macroPlan, executionUser );
    }
    
    if ( isLaneLeg ) {
      Global_MappingLaneLeg::SynchronizeMacroPlanData( this, macroPlan, executionUser );
    }
  *]
}