Program logic

The TFORM_CALC_RESOURCE_CAPACITY program calculates the capacity hours as follows:

  • Clean-up the results from the previous execution as follows:
    • Remove previously generated capacity records from the SC_RESOURCE_SHIFT_CAPACITY and SC_RESOURCE_UNIT_SHIFT_CAPACITY tables as follows:
      DELETE FROM SC_RESOURCE_SHIFT_CAPACITY WHERE resource_capacity_source = ‘Generated’
      DELETE FROM SC_RESOURCE_UNIT_SHIFT_CAPACITY WHERE resource_capacity_source = ‘Generated’
    • Commit changes when the records are deleted successfully.
    • Log an error message and stop the processing when an error exists.
    • Complete the task log record with the actual status.
  • Calculate the capacity hours using shift details and working calendar. These steps describe the processing logic of capacity hours calculation:
    • Determine the <planning horizon>. Resource capacities are calculated for each day in the <planning horizon> as follows:
      • Determine the <planning horizon start date>:
        • Find the start date of the earliest base calendar period in SZ_SCP_CALENDAR. <start date> = SELECT MIN(period_start_date) FROM SZ_SCP_CALENDAR where, base_period_flag = 'Y'.
        • Find the earliest calendar start date in SZ_MODEL_PARAMETER across all profiles. <start date> = SELECT MIN(parameter_value) FROM SZ_MODEL_PARAMETER where, parameter_name = 'CALENDAR_START_DATE'.
        • <planning horizon start date> = Earliest of the <start date> values specified in SZ_SCP_CALENDAR and SZ_MODEL_PARAMETER. If the specified value is null or empty, current date is considered.
      • Determine the <planning horizon end date> as follows:
        • Retrieve the value of the SCV configuration parameter SCP_DEFAULT_HORIZON_END_OFFSET_DAYS. If the specified value is null or empty, 0 is considered.
        • <planning horizon end date> = <planning horizon start date> + SCP_DEFAULT_HORIZON_END_OFFSET_DAYS.
    • Determine the <resource>s in scope. <resource>s in scope = SELECT resource_id FROM SC_RESOURCE WHERE source = <SOURCE>.
    • Determine the <capacity level> of the <resource>s in scope as follows:
      • Capacity hours can be calculated for a Resource or for a Resource unit level. When <capacity level> is Resource, capacity is calculated only for Resources. When <capacity level> is Resource Unit, capacity is calculated for Resource Units and aggregated to Resources.

        <capacity level> = SELECT capacity_level FROM SC_RESOURCE WHERE resource_id = <resource>.

      • If <capacity level> = Resource, continue with A - Capacity Calculation for Resources.
      • If <capacity level> = Resource Unit, continue with B - Capacity Calculation for Resource Units.
    • For each <resource> in scope with <capacity level> = Resource. See, Capacity Calculation for Resources.
    • For each <resource> in scope with <capacity level> = Resource Unit:
      • Determine the <resource unit>s.

        One resource unit can be linked to one or more resources, using the resource relations defined in the SC_RESOURCE_RELATION table.

      • Retrieve <resource unit>s for the resources that have capacity level Resource Unit.

        SELECT resource_unit_id FROM SC_RESOURCE_RELATION WHERE resource_id IN (<resource>s in scope with <capacity level> = Resource Unit)

    • For each <resource unit>, see, Capacity Calculation for Resource Units.