RRPInitializeBucketDates

RRP, Initialize Bucket Dates

Major Business Rule

Object Name: B3300140

Parent DLL: CMFG

Location: Client/Server

Language: C

1.Functional Description

1.1Purpose
This function allocates memory and initializes an array of bucket dates based on the input start 
date, number of past due periods, and the number of planning weeks and months.


1.2Setup Notes and Prerequisites

• The calling application must call business function B4000460, FreePtrToDataStructure, to free the 
memory allocated by this function for the date array.


1.3Special Logic


2.Technical Specifications

// Determine the size of the date array and allocate memory
BucketDateArrayPtr = 0

StartDate = GenerationStartDate

NumberOfPeriods = PlanningWeeks + PlanningMonths + 1

If NumberPastDuePeriods = 2

NumberOfPeriods = NumberOfPeriods + 1

End

If NumberOfPeriods > 56

NumberOfPeriods = 56

End

Allocate memory for the BucketDateArray to hold NumberOfPeriods dates

If the memory allocation fails

Exit the function with an error return code

End


// Initialize the Bucket Date array with the generation start date and past due dates

// The generation start date is the last day of the week or month based on the input // date

Initialize the array to zeroes 

If PlanningWeeks > 0

PlanningWeeks = PlanningWeeks - 1

Set StartDate to the last day of the week

$G = 2

If NumberPastDuePeriods = 2

$G = $G + 1

End

BucketDateArray[$G] = StartDate

BucketDate = StartDate

Subtract 7 days from StartDate

$G = $G - 1

BucketDateArray[$G] = StartDate

If NumberPastDuePeriods = 2

Subtract 7 days from StartDate

BucketDateArray[1] = StartDate

End

Else

MonthlyFlag = TRUE

PlanningMonths = PlanningMonths - 1

Set StartDate to the last day of the month

$G = 2

If NumberPastDuePeriods = 2

$G = $G + 1

End

BucketDateArray[$G] = StartDate

BucketDate = StartDate

Set StartDate to the last day of the previous month

$G = $G - 1

BucketDateArray[$G] = StartDate

If NumberPastDuePeriods = 2

Set StartDate to the last day of the previous month

BucketDateArray[1] = StartDate

End

End


// Add the dates for the rest of the planning period to the Bucket Date Array

StartDate = BucketDate

If NumberPastDuePeriods = 2

$G = 4

Else

$G = 3

End

Do $X = $G to NumberOfPeriods

If PlanningWeeks > 0

PlanningWeeks = PlanningWeeks - 1

Add 7 days to StartDate

BucketDateArray[$X] = StartDate

Else

PlanningMonths = PlanningMonths - 1

If MonthlyFlag <> TRUE or StartDate is the last day of the month

Advance StartDate by 1 month

End

Set StartDate to the last day of the month

MonthlyFlag = TRUE

BucketDateArray[$X] = StartDate

End

End


^

Data Structure

D3300140 - RRP, Initialize Bucket Dates


Data Item Data Structure DescriptionI/ORequiredNotes

STRT            Generation Start Date            IY

INT01            Planning Weeks                  IY

INT02            Planning Months                  IY

INT03            Number Past Due Periods            IY

INT04            Number Of Periods                  O

GENLNG      Bucket Date Array Ptr            O

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

message                                                                               handling 

                                                                        ' ' = Allow runtime error 

message                                                                               handling

DTAI            Error Message                       IDO" " = success 

                                                                        "4374" = memory allocation 

failed

^

Parameter NameData ItemData TypeReq/OptI/O/Both
jdGenerationStartDateSTRTJDEDATENONENONE

The start date for the order. You can enter this date manually, or have the system calculate it using a backscheduling routine. The routine 
starts with the required date and offsets the total leadtime to calculate the appropriate start date.

iPlanningWeeksINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

iPlanningMonthsINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

iPastDuePeriodsINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

iNumberOfPeriodsINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

idBucketDateArrayPtrGENLNGIDNONENONE

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.

Related Functions

None

Related Tables

None