RRPCalculateLoadedCapacity

RRP, Calculate Loaded Capacity

Major Business Rule

Object Name: B3300160

Parent DLL: CMFG

Location: Client/Server

Language: C

1.Functional Description

1.1Purpose

This function reads the Capacity Resource Profile table (F3303) and Detail Forecast table (F3460) to 

calculate the loaded capacity for the input Work Center.  This information is stored in the Loaded 

Capacity Array and returned to the calling application.  The function also writes Period Summary records 

to F3312 containing the loaded capacity for each Item in the Work Center that has forecast data 

available.


1.2Setup Notes and Prerequisites

• The calling application must call B3300140, RRP, Initialize Bucket Dates, before calling this 
function.  The Bucket Date Array pointer returned by B3300140 must be passed as input to this function.

• During the first call to this function, memory is allocated for the Loaded Capacity Array and is 
returned to the calling application so that is can be reused on subsequent calls.  The calling 

application must call B4000460, FreePtrToDataStructure, to free the memory when processing is complete.


1.3Special Logic


2.Technical Specifications


If the LoadedCapacityArrayPtr is NULL or the PeriodSummaryArrayPtr is NULL

Allocate memory for the arrays to hold NumberOfPeriods math numeric values

If the allocation fails

ErrorMessageID = '4374'

Exit the function with an error return code

End

End


// Read the resource profile and forecast file and load the loaded capacity array.

// Write Period Summary records.

Declare PeriodSummaryArray as an array of 56 math numerics

Clear the LoadedCapacityArray

Clear the PeriodSummaryArray

SaveItem = 0

If UnitOfMeasure = 'HR'

If PrimeLoadCode = 'L' or 'B'

LaborFlag = '1'

End

If PrimeLoadCode = 'M' or 'C'

MachineFlag = '3'

End

If PrimeLoadCode = 'B' or 'C'

LaborAndMachineFlag = '2'

End

Else

OtherUOMFlag = '9'

End

FirstPass = TRUE

Move the input Forecast Types to a ForecastTypeArray

CWCAPM = '1'

CWDCTO = 'FC'

CWMCU = WorkCenter

CWMMCU = Branch

CWUM = UnitOfMeasure

If UnitOfMeasure = 'HR'

If PrimeLoadCode = 'L' or 'B'

CWUNTY = '1'

End

If PrimeLoadCode = 'M' or 'C'

CWUNTY = '3'

End

Else

CWUNTY = '9'

End

Select F3303 records using key values Branch, WorkCenter, and UnitOfMeasure

Do while not EOF F3303

Read the next F3303 record

If F3303 read successful

If CTUNTY = LaborFlag, MachineFlag, LaborAndMachineFlag, or OtherUOMFlag

If CTTIMB <> LastTimeBasisCode

Call X0005 to retrieve the TimeBasisFactor for CTTIMB

Convert DL02 (TimeBasisFactor) from F0005 to numeric

If call to X0005 not successful

TimeBasisFactor = 1

End

End


// When Item changes, write period summary for previous item

If FirstPass = FALSE and SaveItem <> CTITM

CWITM = SaveItem

CWMMCU = SaveWorkCenter

Do X = 1 to NumberOfPeriods

If BucketDateArray[X] > 0 and PeriodSummaryArray[X] > 0

CWDRQJ = BucketDateArray[X]


// Check for past due dates

If PastDuePeriods >= X

If PastDuePeriods = 1

CWDRQJ = 0

End

If PastDuePeriods = 2

If X = 1

CWDRQJ = 1/1/1900  // Used for Past Due 
Date 1. Equal to Julian date value 1 

Else
CWDRQJ = 1/2/1900  // Used for Past Due 
Date 2. Equal to Julian date value 2

End
End

End

CWTRQT = PeriodSummaryArray[X] rounded to 0 

decimals

CWUORG = LoadedCapacityArray[X] rounded to 0 

decimals

Write a new record to F3312 using the assigned 

field values 

End

End

Clear the PeriodSummaryArray

End

FirstPass = FALSE


// Load forecast data into appropriate date buckets

SaveItem = CTITM

MFITM = CTITM

MFMCU = Branch

Round CTTRKS to 0 decimals

Round CTUORG to 0 decimals

SaveRequestedDate = 0

X = 0

F = 1

Do while ForecastTypeArray[F] <> blank and F < 5

MFTYPF = ForecastTypeArray[F]

Select records from F3460 using key values MFITM, MFMCU, and 

MFTYPF where

MFDRQJ >= (CTEFFF + CTTRKS) and MFDRQJ <= (CTEFFT + CTTRKS)

Do while F3460 fetch successful

Read the next F3460 record

If the fetch was successful and MFDRQJ > 0

SaveRequestedDate = MFDRQJ - CTTRKS

X = X + 1

Search for the date in BucketDateArray starting at 
index X that is >= SaveRequestedDate .

If date found and X > 0 and X <= NumberOfPeriods
MFFQT = (MFFQT / TimeBasisFactor) * CTUORG

Round MFFQT to 9 decimals

LoadedCapacityArray[X] = 

LoadedCapacityArray[X] + MFFQT

PeriodSummaryArray[X] = PeriodSummaryArray[X] 

+ MFFQT

End

End

End

F = F + 1

End

End

End

End


// Write the period summary for the last item processed

Do X = 1 to NumberOfPeriods

If BucketDateArray[X] > 0 and PeriodSummaryArray[X] > 0

CWDRQJ = BucketDateArray[X]


// Check for past due dates

If PastDuePeriods >= X

If PastDuePeriods = 1

CWDRQJ = 0

End

If PastDuePeriods = 2

If X = 1

CWDRQJ = 1/1/1900  // Used for Past Due Date 1. Equal to Julian 
date value 1 

Else
CWDRQJ = 1/2/1900  // Used for Past Due Date 2. Equal to Julian 
date value 2

End
End

End

CWTRQT = PeriodSummaryArray[X] rounded to 0 decimals

CWUORG = LoadedCapacityArray[X] rounded to 0 decimals

Write a new record to F3312 using the assigned field values 

End

End


Data Structure

D3300160 - RRP, Calculate Loaded Capacity

Data Item Data Structure DescriptionI/ORequiredNotes
MCU            Work Center                        IY

MMCU             Branch                        IY

UM            Unit Of Measure                  IY

GENLNG      Bucket Date Array Ptr            IY      From B3300140

INT01            Past Due Periods                  IY

INT01            Number Of Periods                  IY

PILC            Prime Load Code                  IY

TYPF            Forecast Type 1                  I

TYPF            Forecast Type 2                  I

TYPF            Forecast Type 3                  I

TYPF            Forecast Type 4                  I

TYPF            Forecast Type 5                  I

GENLNG      Loaded Capacity Array Ptr      I/OY

SUPPS            Suppress Error Message            I      '1' = Suppress runtime error 

message                                                                                                

                                                             handling 

                                                                        ' ' = Allow runtime error 

message                                                                               handling

DTAI            Error Message ID                  O      ' ' = Success 

                                                                        '3143' = Table access error 

                                                                        '4374' = Memory allocation 

failed


^

Parameter NameData ItemData TypeReq/OptI/O/Both
szWorkCenterMCUcharNONENONE

An alphanumeric code that identifies a separate entity within a business for which you want to track costs. For example, a business unit 
might be a warehouse location, job, project, work center, branch, or plant. You can assign a business unit to a document, entity, or person for 
purposes of responsibility reporting. For example, the system provides reports of open accounts payable and accounts receivable by 
business unit to track equipment by responsible department. Business unit security might prevent you from viewing information about business units 
for which you have no authority.

szBranchMMCUcharNONENONE

A code that represents a high-level business unit. Use this code to refer to a branch or plant that might have departments or jobs, which 
represent lower-level business units, subordinate to it. For example:     o Branch/Plant (MMCU)     o Dept A (MCU)     o Dept B (MCU)     o Job 123 
(MCU) Business unit security is based on the higher-level business unit.

szUnitOfMeasureUMcharNONENONE

A user defined code (00/UM) that identifies the unit of measurement for an amount or quantity. For example, it can represent a barrel, box, 
cubic meter, liter, hour, and so on.

idBucketDateArrayPtrGENLNGIDNONENONE

General purpose ID variable.

nPastDuePeriodsINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

nNumberOfPeriodsINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

cPrimeLoadCodePILCcharNONENONE

A code that determines if a work center is machine or labor intensive. The system also uses prime load codes in Resource Requirements 
Planning and Capacity Requirements Planning calculations to develop load profiles. Valid codes are:    L Run labor hours only    M Machine 
hours only    B Run labor plus setup labor hours    C Machine plus setup hours    O Other (will not generate resource units)

szForecastTypeTYPFcharNONENONE

A user defined code (34/DF) that indicates one of the following:     o The forecasting method used to calculate the numbers displayed about 
the item     o The actual historical information about the item 

szForecastType2TYPFcharNONENONE

A user defined code (34/DF) that indicates one of the following:     o The forecasting method used to calculate the numbers displayed about 
the item     o The actual historical information about the item 

szForecastType3TYPFcharNONENONE

A user defined code (34/DF) that indicates one of the following:     o The forecasting method used to calculate the numbers displayed about 
the item     o The actual historical information about the item 

szForecastType4TYPFcharNONENONE

A user defined code (34/DF) that indicates one of the following:     o The forecasting method used to calculate the numbers displayed about 
the item     o The actual historical information about the item 

szForecastType5TYPFcharNONENONE

A user defined code (34/DF) that indicates one of the following:     o The forecasting method used to calculate the numbers displayed about 
the item     o The actual historical information about the item 

idLoadedCapacityArrayPtrGENLNGIDNONENONE

General purpose ID variable.

cSuppressErrorMessageSUPPScharNONENONE

A flag indicating whether or not runtime error messaging will occur when an error message is issued from a business function.        0 = allow 
runtime error message handling.        1 = suppress runtime error message handling.

szErrorMessageIDDTAIcharNONENONE

A code that identifies and defines a unit of information. It is an alphanumeric code up to 8 characters long that does not allow blanks or 
special characters such as %, &, or +. You create new data items using system codes 55-59. You cannot change the alias.

mnF3312UniqueIDUKIDMATH_NUMERICOPTNONE

This field is a unique number used to identify a record in a file.

szWorkcenterBranchWMCUcharOPTNONE

This is the branch/plant to which the work center belongs and must exist in the business unit master (F0006) and branch plant constants file 
(F41001).

Related Functions

B9800420 Get Data Dictionary Definition
X0005 Get User Defined Codes

Related Tables

F3303 Capacity Resource Profile
F3312 Capacity Pegging
F3460 Forecast File