CRPCalculateReleasedPlannedLoad

CRP, Calculate Released And Planned Load

Major Business Rule

Object Name: B3300220

Parent DLL: CMFG

Location: Client/Server

Language: C

1.Functional Description

1.1Purpose
This function loads the Released or Planned Load and Period Summary Arrays with data from the Routing 
records for the input Work Center and Branch.  It then creates Period Summary records (F3312) for 

each Item.


1.2Setup Notes and Prerequisites

• The calling application must call B3300200 (CRP, Initialize Bucket Dates) before calling this 
function.  The Bucket Date Array pointer returned by B3300200 must be passed as input.

• During the first call to this function, memory is allocated for the Released Load and Planned Load 
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 (ReleasedLoadArrayPtr = NULL) or (PlannedLoadArrayPtr = NULL)
Allocate memory for the ReleasedLoadArray to hold NumberOfPeriods math numeric values

Allocate memory for the PlannedLoadArray to hold NumberOfPeriods math numeric values
If either allocation fails

ErrorMessageID = "4374"

Exit the function with an error return code

End

End

Declare array PeriodSummaryArray of NumberOfPeriods math numerics

If PlannedOrders <> '1'

Clear the ReleasedLoadArray
End

Clear the PeriodSummaryArray

Clear the PlannedLoadArray

SaveOrderNumber = 0

SaveOrderType = " "

SaveItem = 0

FirstPass = FALSE


// Read Routings for the Work Center

If PlannedOrders <> '1'

Select records from F3112 using key values WLMMCU = Branch, WLMCU = WorkCenter, WLOPSC = ' '
Else

Select records from T3112W using key values WLMMCU = Branch, WLMCU = WorkCenter, 
WLOPSC = ' '

End


Do while the F3112 or T3112W fetch is successful

If PlannedOrders <> '1'

Fetch the next F3112 record
Else

Fetch the next T3112 record

End

If WLDOCO <> SaveOrderNumber or WLDOCO = 0 or the last F3112/T3112W fetch failed

If FirstPass = TRUE

If PlannedOrders <> '1'

F3312 Order Type = "FO"

Else

If SaveOrderNumber = 0
F3312 Order Type = "WP"

Else

F3312 Order Type = SaveOrderType

End

End

Do X = 1 to NumberOfPeriods

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

F3312 CWDRQJ = BucketDateArray[X]

If PastDuePeriods >= X

If PastDuePeriods = 1

F3312 CWDRQJ = 0

End

If PastDuePeriods = 2

If X = 1

F3312 CWDRQJ = 1

Else

F3312 CWDRQJ = 2

End

End

End

Write a new record to F3312 using values CWCAPM = 
CapacityMode, CWDOCO = SaveOrderNumber, CWMCU = WorkCenter, CWITM = 

SaveItemNumber, 

CWMMCU = Branch, CWUM = UnitOfMeasure, CWUNTY = 'R',

CWTRQT = PeriodSummaryArray[X]

End

End

Clear the PeriodSummaryArray

End

End

FirstPass = TRUE

SaveOrderNumber = WLDOCO

SaveOrderType = WLDCTO

SaveItem = WLKIT


// Retrieve the Work Order Header and check the Inclusion Rules

If F3112/T3112W Order Number (WLDOCO) <> 0

Fetch the F4801 record for the order number WLDOCO

Call B3401300 (Cache, Process MRP Inclusion Rules) with CacheActionCode = GET 
to validate that

the inclusion rule for WADCTO and WASRST has been selected.
End


If the F4801 fetch was successful and the call to B3401300 was successful

// Calculate the remaining machine, labor, and setup hours and the quantity

RemainingQty = 0

If PlannedOrders <> '1'

RemainingQty = WLUORG - WLSOQS
End

If PrimeLoadCode = 'L' or 'B'
RemainingHours = WLRUNL - WLLABA

End

If PrimeLoadCode = 'M' or 'C'

RemainingHours = WLRUNM - WLMACA

End

If RemainingHours < 0 or RemainingQty <= 0

RemainingHours = 0

End


SetupHours = 0

If PrimeLoadCode = 'B' or 'C'

SetupHours = WLSETL - WLSETA

If RemainingQty <= 0 and PlannedOrders <> '1'

SetupHours = 0

End

End


If RemainingHours <> 0 or SetupHours <> 0

SkipFlag = FALSE
If PlannedOrders <> '1'

SaveRequestedDate = WLDRQJ
SaveStartDate = WLSTRT


// Adjust Requested Date or Quantity if the order has been 

Decreased, Deferred, Canceled,Increased, or Expedited.

Select F3411 records using key values WADOCO and WADCTO

Do while the F3411 fetch is successful

Fetch the next F3411 record

If the fetch was successful and the F3411 MMMSGT = 'L', 

'G', 'E', 'D', or 'C'

If F3411 MMMSGT = 'L'     // decrease message
Fetch the F4101 record for item number WAITM

Call B4000520 to convert WAUORG from WAUOM to 
IMUOM1 passing WAMMCU.

If WAUORG <> 0

Factor = RemainingHours / WAUORG

End

RemainingHours = F3411 MMTRQT * Factor

End

If MMMSGT = 'D'      // defer message

SaveStartDate = MMRSTJ

SaveRequestedDate = MMRRQJ

End

If MMMSGT = 'C'

SkipFlag = TRUE
End


If F3411 MMMSGT = 'G'     // increase message

Fetch the F4101 record for item number WAITM

Call B4000520 to convert WAUORG from WAUOM to 
IMUOM1 passing WAMMCU.

If WAUORG <> 0

Factor = RemainingHours / WAUORG
End
RemainingHours = F3411 MMTRQT * Factor

End

If MMMSGT = 'E'    // expedite message

SaveStartDate = MMRSTJ

SaveRequestedDate = MMRRQJ

End

End
End

WLSTRT = SaveStartDate

WLDRQJ = SaveRequestedDate

End

If SkipFlag = FALSE

Call B3300230 to spread the RemainingHours and SetupHours over the 

period between

WLSTRT and WLDRQJ.  Pass the following parameters:

       WorkCenter = WorkCenter

          Branch = Branch

        Unit Of Measure = UnitOfMeasure

        Requested Date = WLDRQJ

       Start Date = WLSTRT

       Load Hours = RemainingHours

       Setup Hours = SetupHours

       Bucket Date Array Ptr = BucketDateArrayPtr

       Number Of Periods = NumberOfPeriods

       Period Summary Array Ptr = PeriodSummaryArrayPtr

If PlannedOrders and WADOCO = 0

Load Array Ptr= PlannedLoadArrayPtr

Else

Load Array Ptr= ReleasedLoadArrayPtr

   End

End

End

End


^

Data Structure

D3300220 - CRP, Calculate Released And Planned Load


Data Item Data Structure DescriptionI/ORequiredNotes

MCU            Work Center                        IY

MMCU            Branch                        IY

UM            Unit Of Measure                  IY

CAPM            Capacity Mode                  IY

PILC            Prime Load Code                  IY

GENLNG      Bucket Date Array Ptr            IY      From B3300140 or B3300200

INT01            Past Due Periods                  IY

INT01            Number Of Periods                  IY

GENLNG      Released Load Array Ptr            I/O      Used if PlannedOrders = ' '

GENLNG      Planned Load Array Ptr            I/O      Used if PlannedOrders = '1'

EV01            Planned Orders                  IY      '1' = Read routing info from 

T3112W 

                                                                        ' ' = Read routing info from 

F3112

JOBN            Job Number                        IY      Used when calling B3401300 to 

                                                                        validate against inclusion 

rules                                                                         cache

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

message                                                                                                

                                                             handling 

                                                                        ' ' = Allow runtime error 

message                                                                                                   

                                                          handling

DTAI            Error Message                       IDO' ' = Success 

                                                                        '3143' = Table access error 

                                                                        '4374' = Memory allocation 

failed 

                                                                        '017E' = Insert unsuccessful


^

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.

cCapacityModeCAPMcharNONENONE

A code indicating which planning is being used. Valid values are:     1    Resource Requirements Planning     2    Rough Cut Capacity 
Planning     3    Capacity Requirements Planning

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)

idBucketDateArrayPtrGENLNGIDNONENONE

General purpose ID variable.

iPastDuePeriodsINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

iNumberOfPeriodsINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

idReleasedLoadArrayPtrGENLNGIDNONENONE

General purpose ID variable.

cPlannedOrdersEV01charNONENONE

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

szJobNumberJOBNcharNONENONE

The code that identifies the work station ID that executed a particular job.

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.

idPlannedLoadArrayPtrGENLNGIDNONENONE

General purpose ID variable.

szComputerIDCTIDcharOPTINPUT

mnJobNumberJOBSMATH_NUMERICOPTINPUT

The job number (work station ID) which executed the particular job.

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).

szOperationStatusCodeWoOPSTcharOPTNONE

User defined code system 31, type OS. The operation status code that identifies the current status of a work order or engineering change 
order as the operation steps in the routing are completed.

Related Functions

B3300230 CRP, Spread Hours Over WO Period
B3401300 Cache, Process MRP Inclusion Rules
B4000520 Get Item UoM Conversion Factor
B9800420 Get Data Dictionary Definition

Related Tables

F3112 Work Order Routing
F3312 Capacity Pegging
F33UI001 Shop Floor Control Routing Instructions
F3411 MPS/MRP/DRP Message File
F4801 Work Order Master File