Example 2 - Available stock below ROP (Restricted calendar)
          This topic describes the process of defining an item, location based on ROP schedule logic when the available stock is below ROP.
         
         The Pre-requisites for this scenario:
The Calculate Schedules input values for the Macro or worksheet:
- Order Start Offset: “” (macro) or 0 (macro or worksheet)
 - Requirements horizon: “” (macro) or 365 (worksheet)
 
Global inputs (cycle period and engine call values):
- Current Planning Period: FY16 M07 (2016-06-27 – 2016-07-24)
 - Start_date: 2016-06-27 (Current Planning Period's Start Date)
 - Cycle Future Horizon: 52 weeks
 - End_date: 2017-06-27 (Current Planning Period's Start Date + Cycle Future Horizon in days)
 
Item code: 10339
Location code: B1
Measure mapping inputs:
- Default Source Method: 2 (Purchase)
 - Opening stock: 13
 - Reorder Point (ROP): 100
 - Receiving calendar ID: 2
 - Freeze Period: 10
 - Lead Time (Purchase): 7
 - Minimum Lot Quantity (Purchase): 20
 - Increment (Purchase): 5
 
ROP schedule logic
          If the Opening Stock < ROP, get the corresponding interpolation calendar from current Engine Settings based on the Measure mapping for Receiving Calendar ID (ID = 2). The default pattern for the interpolation calendar (Monday available):
          
           
         
         | Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | 
|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 0 | 0 | 0 | 0 | 
For No override pattern for the order receiving dates:
- The first possible order date in the future horizon is calculated as Start_date + MAX of:
           
- Order Start Offset = 0
 - Lead Time (Purchase) = 7
 - Freeze Period = 10
 - 2016-06-27 + 10 = 2016-07-07
 
 - Receiving_date = 1st non-zero day in the receiving calendar >= first_order_date AND <=End_date:
           
Non-zero days from Start_date Day of week Before or After first_order_date? Before or After End_date? 2016-06-27 Monday BEFORE BEFORE 2016-07-04 Monday BEFORE BEFORE 2016-07-11 Monday AFTER BEFORE  - If the receiving_date is identified, check for any existing orders available prior to receiving_date:
           
- Get Orders (Start_date: 2016-06-27, receiving_date: 2016-07-04). See, Get Orders logic flow.
 - Sum of the orders (planned, fixed, firm and scheduled) prior to receiving_date is displayed.
 - Get Orders: 40
 
 - Available stock (Opening stock + Get Orders): 53
 
If the Available Stock < ROP, determine the order type and order locations:
- From measure mapping: Default Source Method = 2 (Purchase)
 - For Order Locations (Purchase):
           
Table 1. For Supply allocation of type = Transfers In, these are the populated attributes Allocation Type Measure Item attribute Location attribute Source Location Purchases Supplier Combination item_id location_id supplier_id  - Purchases measure populated = TRUE
 - Item Attribute mapped for this allocation = TRUE
 - Location attribute mapped for this allocation = TRUE
 - Supplier attribute mapped for this allocation = TRUE
 - Check the Scenario Values for Supply Combination (SPLS_RECEIPT_TUPLE) and matching attributes:
           
- Item_id: 10339
 - Destination_location_id: B1
 - PCONST for a value ! = 0
 
 - The first match that is returned:
           
Measure Name Item Location Value Item_id Destination_location_id Source_lovation_id Supplier combination 10339 S001@B1 1 10334 B1 F1  
If Allocation! = 0 found = TRUE:
- Return order destination as matched Purchase allocation's item element: 10339
 - Return order destination ("Destination Location") as matched Purchase allocation's location element: S001@B1.
 - Return order source ("Source Location") as matched Purchase allocation's location element: S001@B1.
 - If valid elements Get Order Locations = TRUE, check for a possible critical expedite exception for the planned order based on the Receiving Date and Start Date (need date) using the standard Get Critical Flag process for an order. Critical_flag = Get Critical Flag (Receiving_date, Start_date).
 - A Planned Transfer Order with this data is generated:
           
- Value = 50 (ROP - Available Stock, rounded to min lot + n increments)
 - Source Measure = Planned Shipment (Derived from: Order mapping for planned order type)
 - Destination Measure = Planned Receipt (Derived from: Order mapping for planned order type)
 - Item = 10339
 - Destination Location = S001@B1 (Derived from Get Order Locations).
 - Source Location = OUT: S001@B1 (Derived from Get Order Locations).
 - Delivery date = 2016-07-11 (receiving_date)
 - Ship date = 2016-07-04 (receiving_date - lead time)
 - Need date = 2016-06-27 (Start_date)
 - Critical Flag = Critical_flag
 
 - If mapped, set output measure ‘Schedule Last Calculated’ = current date & time.