F3400GetForecastLevels

F3400 Get Forecast Levels

Major Business Rule

Object Name: B3401080

Parent DLL: CMFG

Location: Client/Server

Language: C

1.Functional Description

1.1Purpose
This function will retieve the levels of forecasting data for display.

1.2Setup Notes and Prerequisites


1.3Special Logic


2.Technical Specifications

1.If Get Next Record is equal to 1 skip to step 16
2.If the MasterLinkList is not empty 

Skip to step number 15

Else

Will need a MasterLinkList with the following:

Company, Category Codes 1-10, Address Number, Item Number, Branch,

ActualOrgQty, ActualOrgAmt, ForecastOrgQty, ForecastOrgAmt, ActualAdjQty,

ActualAdjAmt, ForecastAdjuQty, ForecastAdjAmt, PntrToChildren


Will also need for every record in the MasterLinkList a Link List that stores the children

associated with it (ChildLinkList)

ChildKey, ForecastType

End


3.Retrieve the Summary Constants for the Summary Code

4.Add up how many levels in the hierarchy there are

Find the highest level in the category code key positions

If there is a value in the Customer Level 

Add one to the highest level of the category code key positions

End

If Global is set to Y

Add one to the value

End

If Company is set to Y

Add one to the value

End

If Item Number is set

Add one to the value

End


5.Based on the Summary Constants determine the top level of the hierarchy 

If Global is equal to Y

Should be able to retrieve the records with all category code positions equal to blank,the 

address number equal to zeros, zeros in item number and the company equal to zero.

Else If the Company is equal to Y

Should be able to retrieve the records with all category code positions equal to 

blank,the address number equal to zeros, zeros in item number and the company NOT equal to zero

Else If Customer Level is equal to 01

Should be able to retrieve the records with all category code 

positions equal to blank,the address number NOT equal to zeros, zeros 

in item number and the company equal to zero.

Else If one of the category codes is position 01

retreive the records that have that code NOT equal to blanks, a zero in address 

number,zeros in item number, zeros in company and all other category codes equal to zeros

Else If Item Number Level is equal to Y

Should be able to retrieve the records with all category code positions equal to blank,the 

address number equal to zeros, the item number NOT equal to zeros and the company equal to zero.

End

End

End

End

End

6.Read all records in the F3400 equal to the key for that top level that have a requested date 

greater than or equal to the From Date and less than or equal to the Thru Date using the Actual Type. ( 

If the dates are passed in blank read all records)

If no records are found 

Skip to Number 10.

End

7.Add/Update a Record to the Master Link List for the full key off the record, with the Adjusted 

and Original Quantity in the ActualOrgQty  and ActualAdjQty and the Adjusted and Original Amounts in 

the AcutalOrgAmt and ActualAdjAmt for every record found in the date sequence

8.Write the Child Number off the record just read to the ChildLinkList along with the Actual Type 

(Store the pointer to the ChildLinkList on the MasterLinkList record)

9.If any one of the records found has the revised flag set 

Move a Y to ActualRevised

End


10.Read the Summary Forecast file with the full key off the record just found for the Actual type (if 

no record was found for the Actual Type use the top level key that the first read with the actual 

type was with) but with the ForecastType

If no records found and no Actual Type recrods were found either move 1838 to Error and end 

function


11.Add/Update the Record into the Master Link List with the full key, with the Adjusted and Original 

Quantity in the ForecastOrgQty  and ForecastAdjQty and the Adjusted and Original Amounts in the 

ForecastOrgAmt and ForecastAdjAmt for every record found in the date sequence

12.Write the Child Number off the record just read to the ChildLinkList along with the 

ForecastType(The pointer to the ChildLinkList should be on the MasterLinkList record if the Actual Type created the 

record else will need to create it here and store it on the MasterLinkList record)

13.If any one of the records found has the revised flag set Move a Y to ForecastRevised


14.Skip to Step Number 16


15.Get the record for the full key passed in from the MasterLinkList
Using the PntrToChildren off the MasterLinkList record just found read the ChildLinkList.  For 

each child, forecast type combination in the link list fetch to the F3400  with the child number in the 

parent number field.

If no record was found

Read the work file F34006 with the ChildKey out of the list and the summary code

For each record found fetch to the Detail Forecast File F3460 with the

branch and item number from the work file

Use these records to accumulate the quantity and amounts

Create records in the MasterLinkList (These records will have no children records)

If any one of the records found has the revised flag set Move a Y to ActualRevised or 

ForecastRevised based on the type

Move a '1' to DetailRecords

Else

Add/Update the Record to the Master Link List the full key, with the Adjusted 

and Original Quantity in the ActualOrgQty and ActualAdjQty if the type is the Actual Type Else 

put them in the ForecastOrgQty and castAdjQty.  Put the Adjusted and Original Amounts in the 

AcutalOrgAmt and ActualAdjAmt if the type is the Actual Type Else put them in the

ForecastOrgAmt and ForecastAdjAmt

Write the Child Number off each record read into a ChildLinkList along 

with the ActualType (Store the pointer to the ChildLinkList on the MasterLinkList 

record)


If any one of the records found has the revised flag set Move a Y to 

ActualRevised orForecastReviesed based on the type

End


After all child records have been written to the link list, Free the memory for the child list and

remove the parent record from the MasterLinkList


16.Return the records in the MasterLinkList.
  
*/ Return the first record for this key if  NextRecord is equal to blanks else return the 

following records*/

If there are no more records after this one

Return a '1' in NoMoreRecords. 

Return the full key


*/ Load the Current Level */

If CurrentLevel is blank return a 1 in CurrentLevel else return CurrentLevel plus 1


*/ Load the LevelDescription and Value */

If this is the global level being returned move GlobalLevelText into LevelDescription and 

GlobalValue

into the Value

If this is the company level being returned retrieve the description for the company

from the F0010 and return it in LevelDescription.  Move the Company Number into

Value

If $CURLEVEL > the NumberOfLevels then we are returning a Branch value.  Retrieve the description 

from F0006 for the Branch value being returned.

If this is the item number level being returned retrieve the primary item number and description 

from X4101.  Move the description into LevelDescription.  Move ShortItemNumber intoValue.  Move the 

primary item number into PrimaryItem


If not one of the above cases

Fetch the Summary Constants Record F4091 for the Summary Code

$CURLEVEL = CurrentLevel

If KFGLSM from Summary Constants = 'Y'

$CURLEVEL = $CURLEVEL - 1

End

If KFCOSM from Summary Constants = 'Y'

$CURLEVEL = $CURLEVEL - 1

End

If $CURLEVEL equals CustomerLevel off the constants record

Retrieve the description for the address from the F0101 and return it in

LevelDescription.  Move the Address Book number into Value

If the address book number was not found move BlankValueText to Value and 

move blanks to LevelDescription

Else

Place KC01-KC40 from the constants record in an list

If $CURLEVEL is less than the Customer Level

Look for $CURLEVEL in the list

Else

Look for $CURLEVEL minus one

End

Use the position of the CurrentLevel found in the list to create KCXX (where XX 

is the position)

Retrieve the row description for the KCXX data item out of the dictionary and 

return it in LevelDescription.  Move the value of the Category Code into Value

If the Value of the Category Code is *Blanks move BlankValueText to Value 

instead and move blanks to LevelDescription instead

 End



*/ Load the PlusMinus field*/

If DetailRecord is not equal to 1

If this is the last level (If NumberOfLevels equals CurrentLevel)

Chain to the F34006 using the Child key off the record. 

If a record is found use the data in it to chain to the F3460.

If a record is found 

Move a '+' to PlusMinus.

Else

Move a '-' to PlusMinus

End

Else

Move '1' PlusMinus

End

Else

Move '+' PlusMinus

End

Else

Move '-' PlusMinus

End



^

Data Structure

D3401080 - F3400 Get Forecast Levels

Parameter NameData ItemData TypeReq/OptI/O/Both
szSummaryCodeKVERcharNONENONE

A user defined code (40/KY) that indicates the type of summary forecast.

jdFromDateDRQJJDEDATENONENONE

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

jdThruDateDRQJJDEDATENONENONE

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

szForecastTypeTYPFcharNONENONE

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 

szActualTypeTYPFcharNONENONE

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 

szCompanyCOcharNONENONE

A code that identifies a specific organization, fund, or other reporting entity. The company code must already exist in the Company 
Constants table (F0010) and must identify a reporting entity that has a complete balance sheet. At this level, you can have intercompany 
transactions. Note: You can use company 00000 for default values such as dates and automatic accounting instructions. You cannot use company 00000 
for transaction entries.

szCatCode1KV01charNONENONE

The first key postion of the forecasting hierarchy.  The value in this field relates to the first level chosen in the forecasting constants.

szCatCode2KV02charNONENONE

The second key postion of the forecasting hierarchy.  The value in this field relates to the second level chosen in the forecasting constants.

szCatCode3KV03charNONENONE

The third key postion of the forecasting hierarchy.  The value in this field relates to the third level chosen in the forecasting constants.

szCatCode4KV04charNONENONE

The forth key postion of the forecasting hierarchy.  The value in this field relates to the fourth level chosen in the forecasting constants.

szCatCode5KV05charNONENONE

The fifth key postion of the forecasting hierarchy.  The value in this field relates to the fifth level chosen in the forecasting constants.

szCatCode6KV06charNONENONE

The sixth key postion of the forecasting hierarchy.  The value in this field relates to the sixth level chosen in the forecasting constants.

szCatCode7KV07charNONENONE

The seventh key postion of the forecasting hierarchy.  The value in this field relates to the seventh level chosen in the forecasting constants.

szCatCode8KV08charNONENONE

The eighth key postion of the forecasting hierarchy.  The value in this field relates to the eighth level chosen in the forecasting constants.

szCatCode9KV09charNONENONE

The ninth key postion of the forecasting hierarchy.  The value in this field relates to the ninth level chosen in the forecasting constants.

szCatCode10KV10charNONENONE

The tenth key postion of the forecasting hierarchy.  The value in this field relates to the tenth level chosen in the forecasting constants.

mnAddressNumberAN8MATH_NUMERICNONENONE

A number that identifies an entry in the Address Book system, such as employee, applicant, participant, customer, supplier, tenant, or 
location.

mnShortItemNumberITMMATH_NUMERICNONENONE

An inventory item number. The system provides three separate item numbers plus an extensive cross-reference capability to other item 
numbers (see data item XRT) to accommodate substitute item numbers, replacements, bar codes, customer numbers, supplier numbers, and 
so forth. The item numbers are as follows:   o Item Number (short) - An eight-digit, computer-assigned item number     o 2nd Item Number - The 
25-digit, free-form, user defined alphanumeric item number     o 3rd Item Number - Another 25-digit, free-form, user defined alphanumeric item 
number

szGlobalLevelTextDL01charNONENONE

A user defined name or remark.

szGlobalValueTextKV01charNONENONE

The first key postion of the forecasting hierarchy.  The value in this field relates to the first level chosen in the forecasting constants.

szBlankValueTextKV01charNONENONE

The first key postion of the forecasting hierarchy.  The value in this field relates to the first level chosen in the forecasting constants.

mnActualOrgQtyUORGMATH_NUMERICNONENONE

The quantity of units affected by this transaction.

mnActualOrgAmtAEXPMATH_NUMERICNONENONE

The number of units multiplied by the unit price.

mnForecastOrgQtyFQTMATH_NUMERICNONENONE

The quantity of units forecasted for production during a planning period.

mnForecastOrgAmtFAMMATH_NUMERICNONENONE

The current amount of the forecasted units for a planning period.

mnActualAdjQtyUORGMATH_NUMERICNONENONE

The quantity of units affected by this transaction.

mnActualAdjAmtAEXPMATH_NUMERICNONENONE

The number of units multiplied by the unit price.

mnForecastAdjQtyFQTMATH_NUMERICNONENONE

The quantity of units forecasted for production during a planning period.

mnForecastAdjAmtFAMMATH_NUMERICNONENONE

The current amount of the forecasted units for a planning period.

mnNumberOfLevelsMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

mnCurrentLevelMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

cPlusMinusEV01charNONENONE

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

cActualRevisedRVIScharNONENONE

A code indicating that the forecasted amount and/or quantity has been manually revised and that the revisions have not been forced to the 
other levels.    0   Not Revised    1   Amount Revised    2   Quantity Revised    3   Amount and Quantity Revised 

cForecastRevisedRVIScharNONENONE

A code indicating that the forecasted amount and/or quantity has been manually revised and that the revisions have not been forced to the 
other levels.    0   Not Revised    1   Amount Revised    2   Quantity Revised    3   Amount and Quantity Revised 

cNoMoreRecordsEV02charNONENONE

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

szPrimaryItemUITMcharNONENONE

A number that the system assigns to an item. It can be in short, long, or third item number format.

idMasterLinkedListGENLNGIDNONENONE

General purpose ID variable.

cDetailRecordEV03charNONENONE

A radio button that specifies the level at which trace/track result is to be displayed.  Select the Detail to display all transactions except IB, IX, 
and IZ types.  Or, select Derivative Lots Only to display only those transactions that may have created new derivative lot. 

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.

cGetNextRecordEV01charNONENONE

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

szValueKV11charNONENONE

The value for the current position of the forecast hierarchy.

szLevelDescriptionDS01charNONENONE

A free-form, 80-character text field.

Related Functions

X4101 Validate and Retrieve Item Master

Related Tables

F0006 Business Unit Master
F0010 Company Constants
F0101 Address Book Master
F3400 Forecast Summary File
F34006 Forecast Summary Work File
F3460 Forecast File
F4091 Category Code Key Position File