ForecastCalculateDates

Forecast Calculate Dates

Major Business Rule

Object Name: B3400810

Parent DLL: CMFG

Location: Client/Server

Language: C

1.Functional Description

1.1Purpose
This function will determine the Begin Date, End Date, Last Date needed for actuals, First Date 
needed for actuals, and create the link list of date pattern dates by calling B3400730.


1.2Setup Notes and Prerequisites

• 

1.3Special Logic



2.Technical Specifications

1.If the BeginDate is blank 
Move todays date to it.

End

Move the BeginDate to an array that breaks it down by MM/DD/YY


2.Load date pattern link list

If the DatePattern to be used for creating the actuals is blank 

Call  B0000059  to retrieve the Company Constants record for 00000 and use it's date 

pattern

End


Call BuildDatePatternLinkList B3400730  

If error is returned set error flag and stop processing

Move 1 to $DTERR

Set on ER_ERROR

End

If the BeginDate is less than the first date in the PntrToDates list

Or if no date was found greater than or equal to the BeginDate

Move 2 to $DTERR

set on ER_ERROR and stop processing

End


3.Calculate End Date

Find date greater than or equal to BeginDate in the PntrToDates list

Go NumberOfPeriods minus 1 beyond that date to get EndDate


If EndDate is zero

Move 3 to $DTERR

Set on ER_ERROR and Stop Processing

End


4.Calculate Last Date Needed for Actuals

Look in the PntrToDates list for the date that is greater than or equal to BeginDate and use the 

date just before it as LastDateForActulas


5.Calculate First Date Needed for Actuals

Move 01 to DD

Save MM in $MTH

Save YY in $YR


If MonthlyWeekly is equal to 1

Divide each of the methods months by 4 to approximate the number of months they represent

Round up results

End


Move MonthsBestFit to MM

If Method1 is not blank or Method3 is not blank

Add 12 to MM

End

If Method2 is not blank and MM is less than 12 + MonthsBestFit + NumberMonthsMethod2

Move 12 + MonthsBestFit + NumberMonthsMethod2 to MM

End

If Method4 is not blank and MM is less than MonthsBestFit + MoveAvgNumberMonths

Move MonthsBestFit + MoveAvgNumberMonths to MM

End

If Method5 is not blank and MM is less than MonthsBestFit + LinearApproxNoMonths

Move MonthsBestFit + LinearApproxNoMonths to MM

End

If Method6 is not blank and MM is less than MonthsBestFit + LSRNumberMonths

Move MonthsBestFit + LSRNumberMonths to MM

End

If Method7 is not blank and MM is less than MonthsBestFit + 3 * 2ndDegreeApproxNoMonths

Move MonthsBestFit + 3 * 2ndDegreeApproxNoMonths to MM

End

If Method8 is not blank and MM is less than MonthsBestFit + 

FlexibleNumberOfMonthsMove FlexibleNumberOfMonths + MonthsBestFit to 

MM

End

If Method9 is not blank and MM is less than MonthsBestFit + WeightedAvgNoMonths then

Move MonthsBestFit + WeightedAvgNoMonths to MM

End

If Method10 is not blank and MM is less than MonthsBestFit + LinearSmoothingNoMonths then

Move MonthsBestFit + LinearSmoothingNoMonths to MM

End

If Method11 is not blank and MM is less than MonthsBestFit + ExponNumberOfMonths

Move the ExponNumberOfMonths + MonthsBestFit to MM

End

If Method12 is not blank and MM is less than 24 + MonthsBestFit

Move 24 + MonthsBestFit to MM

End


Divide MM by 12 to get YY

Move the remainder of the above divide to MM


Subtract MM from $MTH to get $M

If $M < 1

Add 1 to YY

Add 12 to $M to get MM

Else

Move $M to MM

End

Subtract YY from $YR to get a new YY


Move the new MM into $MTH

Move the new YY into YearOffFirstDate

Scrub MMDDYY and put it in FirstDateForActuals


If FirstDateForActuals is not in DatePattern link list

Move 4 to $DTERR

Set on ER_ERROR and Stop Processing

End


^

Data Structure

D3400810 - Forecast Calculate Dates

Parameter NameData ItemData TypeReq/OptI/O/Both
jdBeginDateDRQJJDEDATENONENONE

The date that an item is scheduled to arrive or that an action is scheduled for completion.

jdEndDateDRQJJDEDATENONENONE

The date that an item is scheduled to arrive or that an action is scheduled for completion.

jdFirstDateForActualsDRQJJDEDATENONENONE

The date that an item is scheduled to arrive or that an action is scheduled for completion.

jdLastDateForActualsDRQJJDEDATENONENONE

The date that an item is scheduled to arrive or that an action is scheduled for completion.

mnYearOffFirstDateYRMATH_NUMERICNONENONE

The calendar year for this calendar.

cMonthlyVsWeeklyEV01charNONENONE

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

cDatePatternDTPNcharNONENONE

A code that identifies date patterns. You can use one of 15 codes. You must set up special codes (letters A through N) for 4-4-5, 13-period 
accounting, or any other date pattern unique to your environment. An R, the default, identifies a regular calendar pattern.

cDatePatternErrorERRcharNONENONE

The Data Field Error Code field is simply a generic data field to pass an error condition flag.  This field is one of the fields that make up the 
external parameter data structure of the Data Dictionary Server.

idPointerToDatesGENLNGIDNONENONE

General purpose ID variable.

cDateCalculationErrorERRcharNONENONE

The Data Field Error Code field is simply a generic data field to pass an error condition flag.  This field is one of the fields that make up the 
external parameter data structure of the Data Dictionary Server.

mnFlexibleNumberOfMonthsMATH05MATH_NUMERICNONENONE

Event point for Math Numeric.

mnExponNumberOfMonthsMATH06MATH_NUMERICNONENONE

Event point for Math Numeric.

mnNumberOfPeriodsMATH07MATH_NUMERICNONENONE

Event point for Math Numeric.

szProgramIDPIDcharNONENONE

The number that identifies the batch or interactive program (batch or interactive object). For example, the number of the Sales Order Entry 
interactive program is P4210, and the number of the Print Invoices batch process report is R42565. The program ID is a variable length value. 
It is assigned according to a structured syntax in the form TSSXXX, where: T The first character of the number is alphabetic and identifies the 
type, such as P for Program, R for Report, and so on. For example, the value P in the number P4210 indicates that the object is a 
program. SS The second and third characters of the number are numeric and identify the system code. For example, the value 42 in the number P4210 
indicates that this program belongs to system 42, which is the Sales Order Processing system. XXX The remaining characters of the numer are 
numeric and identify a unique program or report. For example, the value 10 in the number P4210 indicates that this is the Sales Order Entry 
program.

mnMonthsBestFitMATH08MATH_NUMERICNONENONE

Event point for Math Numeric.

mnMoveAvgNumberOfMonthsMATH09MATH_NUMERICNONENONE

Event point for Math Numeric.

szMethod2TYPFcharNONENONE

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 

szMethod4TYPFcharNONENONE

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 

szMethod5TYPFcharNONENONE

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 

szMethod6TYPFcharNONENONE

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 

szMethod1TYPFcharNONENONE

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 

szMethod3TYPFcharNONENONE

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 

szMethod7TYPFcharNONENONE

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 

szMethod8TYPFcharNONENONE

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 

szMethod9TYPFcharNONENONE

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 

szMethod10TYPFcharNONENONE

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 

szMethod11TYPFcharNONENONE

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 

szMethod12TYPFcharNONENONE

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 

mnCalcPercentNumberMonthsMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

mnLSRNumberOfMonthsMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

mnLinearApproxNoMonthsMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

mnWeightedAvgNoMonthsMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

mnLinearSmoothingNoMonthsMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

mn2ndDegreeApproxNoMonthsMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

mnMethodErrorMN2D0MATH_NUMERICNONENONE

This is a generic field used as a work field.

Related Functions

B0000059 RetrieveCoFiscalPtnCode
B3400730 Build Date Pattern Link List

Related Tables

None