1.Functional Description
1.1Purpose
This function create the Summarized Forecast records (F3400) 
1.2Setup Notes and Prerequisites
1.3Special Logic
2.Technical Specifications
1.Create a LinkList with the following fields
 2   4DS$KVR
 5   6DS$TYF
 7   11DS$CO
 12  17DS$K01
 18  23DS$K02
 24  29DS$K03
 30  35DS$K04
 36  41DS$K05
 42  47DS$K06
 48  53DS$K07
 54  59DS$K08
 60  65DS$K09
 66  71DS$K10
 72  79DS$ITM
 80  85DS$DRQ
 86  93DS$AN8
 94102DS$KEY
 and make an array @DS equal postion 12 through 71 ( 10 buckets that are each 6 big)
2.Retrieve the Summary Constants Record (F4091) by chaining to the file with SummaryCode Store 
the record in an array (@KC, 40 positions each 3 big)
3.Place the SoldTo passed in into the sgan8
4.If SoldTo is not equal to zeros
 And RetreiveCatCodes= 1
 Retrieve the Address Book record (F0101) with SoldTo as the key
 Else
 Chain to the Cost Center Master file (F0006) with the Branch 
 and get the address book number associated with that branch
 (MCAN8)
 If MCAN8 is not 0
 Retrieve the Address Book record (F0101) with MCAN8
 End
5.Store the 20 Category Codes from the Address Book record (abac01-20) in the first 20 poistions 
of @CC 
 ( @CC is 40 positions each 6 big)
 Store the 20 Category Codes from the Item Branch record (ibsrp1-5 , ibprp1-9,0 and ibsrp6-9,0) 
after the address book codes in the same @CC array Load the key fields :
6.If the Customer Level (KFCSLV) from the summary constants record (F4091) is not equal to blanks
 
 If SoldTo is equal to zeros 
 Move -99999999 into SGAN8
 Else
 Move SoldTo into SGAN8
 End
 Convert KFCSLV to an integer and save in $$CSLV
 Else
 Move zeros to SGAN8
 End
7.If Item Summary Y/N (KFITSM) is equal to Y
 Move ShortItemNumber to SGITM
 Else
 Move zeros to SGITM
 End
8.If Company Summary Y/N (KFCOSM)from F4091 is equal to Y
 Chain to the Cost Center Master (F0006) with Branch
 and move the company number off the record to SGCO
 Else
 Move zeros to SGCO
 End
9.Move CompareDate to SGDRQJ
 Move ForecastType to SGTYPF
 Move SummaryCode to SGKVER
10.Load the Category Code pieces for the key from the array
 Look up the values '01' - '10' in the constants array (@KC)
 What ever position in the array you get a hit on for each of the values
 go to that position in the category codes array (@CC)and if there is a
 value there load it into the corresponding key field SGKV01-
 SGKV10.  If there is not a value there move '*BLANK' to the
 key field
 Save how many hits there are (ie. if 01 through 04 are found count = 4)
11.Move the SG fields into their corresponding values in the Link List
 Move zeros to $Key
 Move '1' to first pass 34006 flag
12.Back the key values off the structures one at a time and write Summary records to F3400
 If Item Summary Y/N (KFITSM)from F4091 is equal to Y
 Move zeroes to DS$ITM
 If Company is not equal to Y
 And Count equals zero
 And Customer Level equals zero
 And Global is equal to Y
 Move YYYYY to DS$CO
 End
 Link List Routine (see below)
 Write and Update Summary Forecast Records (see below)
 If Company is not equal to Y
 And Count equals zero
 And Customer Level equals zero
 And Global is equal to Y
 Move Blanks to DS$CO
 End
 Copy the key values from the DS to the SG fields
 End
 Move count to $C
 Do $C
 If $$CSLV > $C
 Move zeroes to DS$AN8
 Move zeroes to $$CSLV
 Else
 If $C equals 1
 And $CSLV equals 0
 And Company equals N
 And Global equals Y
 Move XXXXXX to DS,$C
 Else
 Move Blanks to DS,$C
 End
 Subtract 1 from $C
 End
 Move SGSFKY to $Key
 Link List Routine (see below)
 Write and Update Summary Forecast Records (see below)
 If $C equals 1
 And $CSLV equals 0
 And Company equals N
 And Global equals Y
 Move Blanks to DS,$C
 End
 Copy the key values from the DS to the SG fields
 End
 If $$CSLV is greater than zero
 Move zeroes to DS$AN8
 If CompanySummary is not equal to Y
 And Global = Y
 Move  YYYYY   DS$CO
 End
 Link List Routine (see below)
 Write and Update Summary Forecast Records (see below)
 If CompanySummary is not equal to Y
 And Global = Y
 Move Blanks to DS$CO
 End
 Copy the key values from the DS to the SG fields
 Move zeroes to $$CSLV
 End
 If Company Summary Y/N (KFCOSM)from F4091 is equal to Y
 Move XXXXX to DS$CO
 Link List Routine (see below)
 Write and Update Summary Forecast Records (see below)
 Move blanks to DS$CO
 Copy the key values from the DS to the SG fields
 End
 If Global Summary Y/N (KFGLSM)from F4091 is equal to Y
 Link List Routine (see below)
 Write and Update Summary Forecast Records (see below)
 End
13.LinkList Routine
 If $key is equal to zeros
 Save SGDRQJ
 Chain to the Summary Forecast table (F3400) with the full key except the date
 If a record is not found
 assign a component summary key number from NextNumber X0010 
 System Code 34
 Index 01
 Return NextNumber to $Key
 Else
 move SGSFKE to $Key
 End
 Replace SGDRQJ
 End
 Inquire over the index with the key minus one
 If a record is not found 
 assign a parent summary key number from a Call to NextNumber X0010
 System Code 34
 Index 01
 Return NextNumber to DS$Key
 Add record to the Link List
 Else
 Move $Key from link list item to DS$KEY
 End
 Move $Key to SGSFKE
 Move DS$KEY to SGSFKY
 If first pass 34006 flag equals '1'
 SGKVERSJKVER
 SGTYPRSJTYPF
 ShortItemNumberSJITM
 SGSFKESJSFKY
 BranchSJMCU
 
 Chain to the Forecast Summary Work file (F34006) with a full key
 If a record is not found write one
 Move a blank to first pass 34006 flag
Write and Update Summary Forecast Records
 Chain to the Summary Forecast table (F3400) with the full key
 If the record does not exist write it
 Original QuantitySGUORG
 Original AmountSGAEXP
 Forecast QuantitySGFQT
 ForecastAmountSGFAM
 'N'SGBPFC
 and audit info
 Else
 update record
 BlanksSGRVIS
 Add Original QuantitySGUORG
 Add Original AmountSGAEXP
 Add Forecast QuantitySGFQT
 Add Forecast AmountSGFAM
 and audit info
 End
^
D3400790 - Create Summary Forecasts
| Parameter Name | Data Item | Data Type | Req/Opt | I/O/Both | 
|---|---|---|---|---|
| mnShortItemNumber | ITM | MATH_NUMERIC | NONE | NONE | 
An inventory item number. The system provides three separate item numbers plus an extensive cross-reference capability to other item 
  | ||||
| szBranch | MCU | char | NONE | NONE | 
An alphanumeric code that identifies a separate entity within a business for which you want to track costs. For example, a business unit 
  | ||||
| szForecastType | TYPF | char | NONE | NONE | 
A user defined code (34/DF) that indicates one of the following:
    o The forecasting method used to calculate the numbers displayed about 
  | ||||
| mnOriginalQuantity | UORG | MATH_NUMERIC | NONE | NONE | 
The quantity of units affected by this transaction.  | ||||
| mnOriginalAmount | AEXP | MATH_NUMERIC | NONE | NONE | 
The number of units multiplied by the unit price.  | ||||
| mnSoldTo | AN8 | MATH_NUMERIC | NONE | NONE | 
A number that identifies an entry in the Address Book system, such as employee, applicant, participant, customer, supplier, tenant, or 
  | ||||
| jdCompareDate | DRQJ | JDEDATE | NONE | NONE | 
The date that an item is scheduled to arrive or that an action is scheduled for completion.  | ||||
| cRetrieveCatCodes | EV02 | char | NONE | NONE | 
An option that specifies the type of processing for an event.  | ||||
| szSummaryCode | KVER | char | NONE | NONE | 
A user defined code (40/KY) that indicates the type of summary forecast.  | ||||
| idLinkListPtr | GENLNG | ID | NONE | NONE | 
General purpose ID variable.  | ||||
| szProgramID | PID | char | NONE | NONE | 
The number that identifies the batch or interactive program (batch or interactive object). For example, the number of the Sales Order Entry 
  | ||||
| mnForecastAmount | FAM | MATH_NUMERIC | NONE | NONE | 
The current amount of the forecasted units for a planning period.  | ||||
| mnForecastQuantity | FQT | MATH_NUMERIC | NONE | NONE | 
The quantity of units forecasted for production during a planning period.  | ||||
| B9800100 Get Audit Information | 
| F0006 Business Unit Master | ||||
| F0101 Address Book Master | ||||
| F3400 Forecast Summary File | ||||
| F34006 Forecast Summary Work File | ||||
| F4091 Category Code Key Position File | ||||
| F4102 Item Branch File |