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
^
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 Name | Data Item | Data Type | Req/Opt | I/O/Both | 
|---|---|---|---|---|
| jdGenerationStartDate | STRT | JDEDATE | NONE | NONE | 
The start date for the order. You can enter this date manually, or have the system calculate it using a backscheduling routine. The routine 
  | ||||
| iPlanningWeeks | INT01 | integer | NONE | NONE | 
Number of Days in Future to Query for Responses Due.  | ||||
| iPlanningMonths | INT01 | integer | NONE | NONE | 
Number of Days in Future to Query for Responses Due.  | ||||
| iPastDuePeriods | INT01 | integer | NONE | NONE | 
Number of Days in Future to Query for Responses Due.  | ||||
| iNumberOfPeriods | INT01 | integer | NONE | NONE | 
Number of Days in Future to Query for Responses Due.  | ||||
| idBucketDateArrayPtr | GENLNG | ID | NONE | NONE | 
General purpose ID variable.  | ||||
| cSuppressErrorMessage | SUPPS | char | NONE | NONE | 
A flag indicating whether or not runtime error messaging will occur when an error message is issued from a business function.
       0 = allow 
  | ||||
| szErrorMessageID | DTAI | char | NONE | NONE | 
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 
  | ||||
| None | 
| None |