CRPCalculateRatedCapacity

CRP, Calculate Rated Capacity

Major Business Rule

Object Name: B3300150

Parent DLL: CMFG

Location: Client/Server

Language: C

1.Functional Description

1.1Purpose

This function loads the Rated and/or Gross Capacity Arrays with data from the Resource Units table 

(F3007) corresponding to the bucket dates in the Bucket Date Array.


1.2Setup Notes and Prerequisites

• The calling application must call B3300140 (RRP, Initialize Bucket Dates) or B3300200 (CRP, 
Initialize Bucket Dates) before calling this function.  The Bucket Date Array pointer returned by these 

functions must be passed as input to this function.

• During the first call to this function, memory is allocated for the Rated and/or Gross Capacity 
Arrays and is returned to the calling application so that it 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 (RatedCapacityArrayPtr is NULL) or (GrossCapacityArrayPtr = NULL and LoadGrossCapacity = '1')

Allocate memory for the RatedCapacityArray to hold NumberOfPeriods math numeric values

If LoadGrossCapacity = '1'

Allocate memory for the GrossCapacityArray to hold NumberOfPeriods math 
numeric values

End
If either allocation fails

ErrorMessageID = "4374"

Exit the function with an error return code

End

End


Declare array ResourceUnitsArray of 31 math numerics

Clear the ResourceUnitArray

Clear the RatedCapacityArray

If LoadGrossCapacity = '1'

Clear the GrossCapacityArray

End


If PastDueDates > 0

WorkDate = BucketDateArray[PastDueDates]

Else

WorkDate = BucketDateArray[1]

End


Fetch the F3007 record using key values WUMCU = WorkCenter, WUMMCU = Branch, WUUM = UnitOfMeasure, 

WUYR = year from WorkDate, WUMT = month from WorkDate.

Copy the Resource Units fields from the F3007 record into the ResourceUnitsArray

If LoadGrossCapacity = '1'

WUWORE = WUWORE / 100
WUWORU = WUWORU / 100

End


Do X = 2 to NumberOfPeriods

If BucketDateArray[X] > 0

If (month from WorkDate < month from BucketDateArray[X]) or

(month from WorkDate = 12 and month from BucketDateArray[X] = 1)

If day from BucketDateArray[X] > 14

Fetch the F3007 record using key values WorkCenter, Branch, 

UnitOfMeasure, year from 

BucketDateArray[X], month from BucketDateArray[X].
If record found

Copy the Resource Units fields from the F3007 record into 
the ResourceUnitsArray

If LoadGrossCapacity = '1'

WUWORE = WUWORE / 100
WUWORU = WUWORU / 100

End
Sum all elements of the ResourceUnitsArray to RUTotal
Round RUTotal to 9 decimals
If LoadGrossCapacity = '1'

GrossCapacityArray[X] = RUTotal

RUTotal = RUTotal * WUWORE * WUWORU

End

RatedCapacityArray[X] = RUTotal

End
Else

RUTotal = 0

If the previous F3007 fetch was successful and WorkDate is not 

the last day of the month

Add 1 day to WorkDate

Do I = day from WorkDate to 31

RUTotal = RUTotal + ResourceUnitsArray[I]

End

Round RUTotal to 9 decimals

If LoadGrossCapacity = '1'
GrossCapacityArray[X] = GrossCapacityArray[X] + 

RUTotal

RUTotal = RUTotal * WUWORE * WUWORU

End

RatedCapacityArray[X] = RatedCapacityArray[X] + RUTotal

End


Fetch the F3007 record using key values WorkCenter, Branch, 

UnitOfMeasure, year from BucketDateArray[X], month from BucketDateArray[X].

RUTotal = 0

If record found

Copy the Resource Units fields from the F3007 record into 
the ResourceUnitsArray

If LoadGrossCapacity = '1'

WUWORE = WUWORE / 100
WUWORU = WUWORU / 100

End
Do I = 1 to day from BucketDateArray[X]

RUTotal = RUTotal + ResourceUnitsArray[I]   

End

Round RUTotal to 9 decimalsIf LoadGrossCapacity = '1'

GrossCapacityArray[X] = GrossCapacityArray[X] + RUTotal

RUTotal = RUTotal * WUWORE * WUWORU

End

RatedCapacityArray[X] = RatedCapacityArray[X] + RUTotal

End

End

Else

RUTotal = 0

If the previous F3007 fetch was successful

Add 1 day to WorkDate

Do I = day from WorkDate to day from BucketDateArray[X]

RUTotal = RUTotal + ResourceUnitsArray[I]

End

Round RUTotal to 9 decimals

If LoadGrossCapacity = '1'
GrossCapacityArray[X] = GrossCapacityArray[X] + RUTotal
RUTotal = RUTotal * WUWORE * WUWORU

End
RatedCapacityArray[X] = RatedCapacityArray[X] + RUTotal

End

End

WorkDate = BucketDateArray[X]

End



Data Structure

D3300150 - CRP, Calculate Rated 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 or B3300200

INT01            Past Due Periods                  IY

INT01            Number Of Periods                  IY

GENLNG      Rated Capacity Array Ptr      I/OY      Used by R3380 and R3382

GENLNG      Gross Capacity Array Ptr      I/O      Used only by R3382

EV01            Load Gross Capacity            IY      ' ' = only load Rated 

Capacity Array                                                                         '1' = load both arrays

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

message                                                                          ' ' = Allow runtime 

error message

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.

idRatedCapacityArrayPtrGENLNGIDNONENONE

General purpose ID variable.

idGrossCapacityArrayPtrGENLNGIDNONENONE

General purpose ID variable.

cLoadGrossCapacityEV01charNONENONE

An option that specifies the type of processing for an event.

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.

iPastDuePeriodsINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

iNumberOfPeriodsINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

Related Functions

None

Related Tables

F3007 Work Center Resource Units