CalculateAverageSales

Update Item Sales HIstory

Major Business Rule

Object Name: XF4115

Parent DLL: COPBASE

Location: Client/Server

Language: C

Functional Description

Purpose

This function retrieves the Sales History table (F4115) for an item to calculate the total and 

average sales for the item.


Setup Notes and Prerequisites

The Item Number (ITM), Branch (MCU) and Fiscal Year (FY) are required input parameters.  


Technical Specification


This function checks to see if the Current Period is blank or is greater than or equal to 12.  If so, 

The F4115 is retrieved with ITM, MCU and FY.  The SQ01 - SQ14 fields are accumulated and returned in 

the Total Sales Amount parameter.  This number is then divided by 12 and returned in the Average Sales 

Amount parameter.  


If the current period is not blank or is less than 12, the previous year is retrieved.  If this 

record is found, the SQ01 - SQ14 fields are saved.  The fiscal year is reduced by 1 and another fetch to 

the F4115 is performed.  Again, the SQ01 - SQ14 fields are retrieved.  The 14 amounts corresponding to 

the 12 periods prior to the Current period (SQ13 and SQ14 are always included) are accumulated.  If the 

previous year does not exist, add the values SQ01 - SQ14 that werew saved from earlier to obtain 

total sales.  Decrement the current period by 1 and divide the total sales by the current period. 


For example,


FY9495


SQ0121010

SQ0222020

SQ0323030

SQ0424040

SQ0525050

SQ0626060

SQ0727070

SQ0828080

SQ0929090

SQ10300100

SQ11310110

SQ12320120

SQ13330130

SQ14340140


Totals Sales for period 7/95 are the addition of the bold cells = 2650.  Average = 2650/12 = 220.83

Data Structure

DXF4115D - Calculate Average Sales

Parameter NameData ItemData TypeReq/OptI/O/Both
szBranchPlantMCUcharNONENONE

An alphanumeric code that identifies a separate entity within a business for which you want to track costs. For example, a business unit 
might be a warehouse location, job, project, work center, branch, or plant. You can assign a business unit to a document, entity, or person for 
purposes of responsibility reporting. For example, the system provides reports of open accounts payable and accounts receivable by 
business unit to track equipment by responsible department. Business unit security might prevent you from viewing information about business units 
for which you have no authority.

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

mnFiscalYearFYMATH_NUMERICNONENONE

A number that identifies the fiscal year. Generally, you can either enter a number in this field or leave it blank to indicate the current fiscal 
year (as defined on the Company Setup form). Specify the year at the end of the first period rather than the year at the end of the fiscal period. 
For example, a fiscal year begins October 1, 1998 and ends September 30, 1999. The end of the first period is October 31, 1998. Specify the 
year 98 rather than 99.

mnCurrentPeriodPNCMATH_NUMERICNONENONE

A number (from 1 to 14) that identifies the current accounting period . The system uses this number to generate error messages, such as 
PBCO (posted before cut off) and PACO (posted after cut off).

mnTotalSalesAmountASATMATH_NUMERICNONENONE

The amount of expected sales to be entered for Batch Control purposes.

mnAverageSalesAmountASATMATH_NUMERICNONENONE

The amount of expected sales to be entered for Batch Control purposes.

mnSalesQuantityPeriod01SQ01MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod02SQ02MATH_NUMERICNONENONE

The quantity of an item, in primary units of measure, sold during a prior month. The units history is maintained for a period of 25 months.

mnSalesQuantityPeriod03SQ03MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod04SQ04MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod05SQ05MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod06SQ06MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod07SQ07MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod08SQ08MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod09SQ09MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod10SQ10MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod11SQ11MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod12SQ12MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod13SQ13MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod14SQ14MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnAverageSalesQtyASATMATH_NUMERICNONENONE

The amount of expected sales to be entered for Batch Control purposes.

jdLastInvoiceDateDLIJJDEDATENONENONE

The G/L date of the last invoice generated for the customer.

mnSalesYTDCYSMATH_NUMERICNONENONE

The dollar amount of sales for the current year.  Prints on the Buyer's Guide.

mnAmountCostofSalesCYCMATH_NUMERICNONENONE

The cost of goods sold for the year to date. This is a simple accumulation of all orders processed for that period of time.

Related Functions

B0000130 Retrieve Company From Business Unit

Related Tables

F0010 Company Constants
F4115 Item History
F4115CalculateTotalSalesAndCost

F4115CalculateTotalSalesAndCost

Update Item Sales HIstory

Major Business Rule

Object Name: XF4115

Parent DLL: COPBASE

Location: Client/Server

Language: C

Functional Description

Purpose

This function retrieves all records in the Item History table (F4115) using the Item and Branch 

passed in.  The Total Sales Amount and Total Cost Amount are returned based on the From and Thru fiscal 

years passed in.


Setup Notes and Prerequisites

The Item Number (ITM), Branch (MCU), From Period (PN), Thru Period (PN), From Fiscal Year (FY), Thru 

Fiscal Year (FY), Index (CDL) and Keys (CDL) are required input parameters.  The Index defaults to '1' 

and Keys to '3'.


Technical Specification


This function fetches the F4115 for the keys passed in.  Calculation is as follows:


If   FromFiscalYear is not Equal to ThruFiscalYear


While   FromFiscalYear <=  F4115::(IHFY)  AND

     F4115 Fiscal Year (IHFY) <= ThruFiscalYear


If    FromFiscalYear = F4115::IHFY

TotalSalesAmount = TotalSalesAmount + F4115::IHASpn..14

TotalCostAmount  = TotalCostAmount + F4115::IHCIpn..14


//  Where 'pn' is the From Period Number of the From

//   FiscalYear passed in

End


If    ThruFiscalYear = F4115::IHFY

TotalSalesAmount = TotalSalesAmount + F4115::IHAS01..pn

TotalCostAmount  = TotalCostAmount + F4115::IHCI01..pn


//  Where 'pn' is the Thru Period Number of the Thru

//   FiscalYear passed in

End

If   FromFiscalYear <  F4115::(IHFY)  AND

          F4115 Fiscal Year (IHFY) < ThruFiscalYear


TotalSalesAmount = TotalSalesAmount + 

F4115::IHAS01...14

TotalCostAmount  = TotalCostAmount + 

F4115::IHCI01...14


//  Accumulate the total sales for all the period 

End


EndWhile

Else

If    FromFiscalYear = F4115::IHFY

TotalSalesAmount = TotalSalesAmount + F4115::IHASpn..14

TotalCostAmount  = TotalCostAmount + F4115::IHCIpn..14


//  Where 'pn' is the From Period Number of the From

//   FiscalYear passed in

End

End



Data Structure

DXF4115E - F4115 Calculate Total Sales and Cost

Parameter NameData ItemData TypeReq/OptI/O/Both
szBranchPlantMCUcharNONENONE

An alphanumeric code that identifies a separate entity within a business for which you want to track costs. For example, a business unit 
might be a warehouse location, job, project, work center, branch, or plant. You can assign a business unit to a document, entity, or person for 
purposes of responsibility reporting. For example, the system provides reports of open accounts payable and accounts receivable by 
business unit to track equipment by responsible department. Business unit security might prevent you from viewing information about business units 
for which you have no authority.

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

mnFromPeriodNumberPNMATH_NUMERICNONENONE

A number indicating the current accounting period.  This number, used in conjunction with the Company Constants table (F0010) and the 
General Constants table (F0009), allows the user to define up to 14 accounting periods. See General Ledger Date.  The current period number 
is used to determine posted before and posted after cut off warning messages.  It is also used as the default accounting period in the 
preparation of financial reports.

mnThruPeriodNumberPNMATH_NUMERICNONENONE

A number indicating the current accounting period.  This number, used in conjunction with the Company Constants table (F0010) and the 
General Constants table (F0009), allows the user to define up to 14 accounting periods. See General Ledger Date.  The current period number 
is used to determine posted before and posted after cut off warning messages.  It is also used as the default accounting period in the 
preparation of financial reports.

mnFromFiscalYearFYMATH_NUMERICNONENONE

A number that identifies the fiscal year. Generally, you can either enter a number in this field or leave it blank to indicate the current fiscal 
year (as defined on the Company Setup form). Specify the year at the end of the first period rather than the year at the end of the fiscal period. 
For example, a fiscal year begins October 1, 1998 and ends September 30, 1999. The end of the first period is October 31, 1998. Specify the 
year 98 rather than 99.

mnThruFiscalYearFYMATH_NUMERICNONENONE

A number that identifies the fiscal year. Generally, you can either enter a number in this field or leave it blank to indicate the current fiscal 
year (as defined on the Company Setup form). Specify the year at the end of the first period rather than the year at the end of the fiscal period. 
For example, a fiscal year begins October 1, 1998 and ends September 30, 1999. The end of the first period is October 31, 1998. Specify the 
year 98 rather than 99.

mnTotalSalesAmountASATMATH_NUMERICNONENONE

The amount of expected sales to be entered for Batch Control purposes.

mnTotalCostAmountECSTMATH_NUMERICNONENONE

For accounts receivable and accounts payable, the invoice (gross) amount. For sales orders and purchase orders, the unit cost times the 
number of units.

mnIndexCDLMATH_NUMERICNONENONE

The length of the user defined code. It cannot be greater than 10 characters.

mnKeysCDLMATH_NUMERICNONENONE

The length of the user defined code. It cannot be greater than 10 characters.

cSuppressErrorMessageEV01charNONENONE

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

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

B0000130 Retrieve Company From Business Unit

Related Tables

F0010 Company Constants
F4115 Item History
GetItemHistory

GetItemHistory

Update Item Sales HIstory

Major Business Rule

Object Name: XF4115

Parent DLL: COPBASE

Location: Client/Server

Language: C

Functional Description

Purpose

This function retrieves values for an Item History record (F4115) for the pointer passed in.


Setup Notes and Prerequisites

The pointer to the Item History record (GENLNG) is a required input parameter.


Technical Specification


This function uses the pointer passed in to retrieve the F4115.  The Sales Quantity Periods (SQ01 - 

SQ14) and the Last Invoice Date (DLIJ) are returned.


Data Structure

DXF4115B - Get Item History

Parameter NameData ItemData TypeReq/OptI/O/Both
idPointerToF4115DSGENLNGIDNONENONE

General purpose ID variable.

mnSalesQuantityPeriod01SQ01MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod02SQ02MATH_NUMERICNONENONE

The quantity of an item, in primary units of measure, sold during a prior month. The units history is maintained for a period of 25 months.

mnSalesQuantityPeriod03SQ03MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod04SQ04MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod05SQ05MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod06SQ06MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod07SQ07MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod08SQ08MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod09SQ09MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod10SQ10MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod11SQ11MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod12SQ12MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod13SQ13MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

mnSalesQuantityPeriod14SQ14MATH_NUMERICNONENONE

The number of units, in primary units of measure, sold during a prior month. The units history is maintained for a period of twenty-five months.

Related Functions

B0000130 Retrieve Company From Business Unit

Related Tables

F0010 Company Constants
F4115 Item History
UpdateItemSalesHistory

UpdateItemSalesHistory

Update Item Sales HIstory

Major Business Rule

Object Name: XF4115

Parent DLL: COPBASE

Location: Client/Server

Language: C

Functional Description

Purpose

This function updates or adds a record to the Item History table (F4115).


Setup Notes and Prerequisites

The Item Number (ITM), Branch (MCU), Fiscal Year (FY) and Period Number (PN) are required input 

parameters.


Technical Specification


This function retrieves the F4115 for the keys passed in (ITM, MCU, FY).  If a record is found, the 

Extended Price(AEXP) is added to CMS and CYS.  The Extended Cost (ECST) is added to CMC and CYC.  GMTD 

is calculated by subtracting CYC from CYS.  The AEXP and ECST fields are added to the corresponding 

ASxx and CIxx fields where xx equals the Period Number (PN) passed in.  AEXP - ECST equals MAxx where xx 

equals the period number.  TRQT is added to SQxx where xx equals the period number.  The record is 

updated.


If a record is not found, ITM, MCU and FY are loaded with the input parameters.  CRTY is loaded with 

the data dictionary default value.  FQ is loaded with blanks.  LT is loaded with 'U'.  PYES, PYEC, 

LRCJ, LDAY, INVV, AV01 - AV14, PQ01 - PQ14, AE01 - AE14, CW01 - CW14 are loaded with zeros.  SM01 - SM14, 

C101 - c114, C201 - C214 and C301 - C314 are loaded with blanks.  SQ01 - SQ14 are loaded with zeros.  

AEXP is added to ASxx where  xx is the period number.  ECST is added to CIxx where xx is the period 

number.  AEXP - ECST is loaded to MAxx.  TRQT to added to SQxx.  AEXP is added to CMS and CYS.  ECST is 

added to CMC and CYC.  CYS - CYC is loaded to GMTD.  DLIG is loaded to TRDJ.  A new record is added.

Data Structure

DXF4115C - Update Item Sales History

Parameter NameData ItemData TypeReq/OptI/O/Both
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

szBranchPlantMCUcharNONENONE

An alphanumeric code that identifies a separate entity within a business for which you want to track costs. For example, a business unit 
might be a warehouse location, job, project, work center, branch, or plant. You can assign a business unit to a document, entity, or person for 
purposes of responsibility reporting. For example, the system provides reports of open accounts payable and accounts receivable by 
business unit to track equipment by responsible department. Business unit security might prevent you from viewing information about business units 
for which you have no authority.

mnFiscalYearFYMATH_NUMERICNONENONE

A number that identifies the fiscal year. Generally, you can either enter a number in this field or leave it blank to indicate the current fiscal 
year (as defined on the Company Setup form). Specify the year at the end of the first period rather than the year at the end of the fiscal period. 
For example, a fiscal year begins October 1, 1998 and ends September 30, 1999. The end of the first period is October 31, 1998. Specify the 
year 98 rather than 99.

mnExtendedPriceAEXPMATH_NUMERICNONENONE

The number of units multiplied by the unit price.

mnExtendedCostECSTMATH_NUMERICNONENONE

For accounts receivable and accounts payable, the invoice (gross) amount. For sales orders and purchase orders, the unit cost times the 
number of units.

jdTransactionDateTRDJJDEDATENONENONE

The date that an order was entered into the system. This date determines which effective level the system uses for inventory pricing.

mnTransactionQuantityTRQTMATH_NUMERICNONENONE

A value that represents the available quantity, which might consist of the on-hand balance minus commitments, reservations, and 
backorders. You enter this value in the Branch/Plant Constants program (P41001).

mnGLPeriodNumberPNMATH_NUMERICNONENONE

A number indicating the current accounting period.  This number, used in conjunction with the Company Constants table (F0010) and the 
General Constants table (F0009), allows the user to define up to 14 accounting periods. See General Ledger Date.  The current period number 
is used to determine posted before and posted after cut off warning messages.  It is also used as the default accounting period in the 
preparation of financial reports.

mnCenturyCTRYMATH_NUMERICOPTNONE

The calendar century associated with the year. Enter is the first two digits of the year. For example, 19 indicates any year beginning with 19 
(1998, 1999), 20 indicates any year beginning with 20 (2000, 2001), and so on.

Related Functions

B0000130 Retrieve Company From Business Unit

Related Tables

F0010 Company Constants
F4115 Item History
VerifyAndGetItemHistory

VerifyAndGetItemHistory

Update Item Sales HIstory

Major Business Rule

Object Name: XF4115

Parent DLL: COPBASE

Location: Client/Server

Language: C

Functional Description

Purpose

This function verifies the existence of an Item History record (F4115).


Setup Notes and Prerequisites

The Item Number (ITM), Branch (MCU) and Fiscal Year (FY) are required input parameters.


The only valid option for Index is '1'.  

The only valid option for Keys is '3'.


If the Call Type = '1', the existence of a row in the table is verified.  If the Call Type = '2', the 

non existence of a row is verified.

 

Technical Specification


This function retrieves the F4115 for the Item, Branch and Fiscal Year passed in.  If the Call Type = 

'1' and a record is not found, an error is issued.  If the Return Pointer parameter = '1', the 

pointer to the F4115 is returned.  If the Call Type = '2' and a record is found, an error is issued.   


Data Structure

DXF4115A - Verify And Get Item History

Parameter NameData ItemData TypeReq/OptI/O/Both
szBranchPlantMCUcharNONENONE

An alphanumeric code that identifies a separate entity within a business for which you want to track costs. For example, a business unit 
might be a warehouse location, job, project, work center, branch, or plant. You can assign a business unit to a document, entity, or person for 
purposes of responsibility reporting. For example, the system provides reports of open accounts payable and accounts receivable by 
business unit to track equipment by responsible department. Business unit security might prevent you from viewing information about business units 
for which you have no authority.

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

mnFiscalYearFYMATH_NUMERICNONENONE

A number that identifies the fiscal year. Generally, you can either enter a number in this field or leave it blank to indicate the current fiscal 
year (as defined on the Company Setup form). Specify the year at the end of the first period rather than the year at the end of the fiscal period. 
For example, a fiscal year begins October 1, 1998 and ends September 30, 1999. The end of the first period is October 31, 1998. Specify the 
year 98 rather than 99.

idPointerToF4115DSGENLNGIDNONENONE

General purpose ID variable.

cReturnF4115RowPointerEV01charNONENONE

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

mnIndexCDLMATH_NUMERICNONENONE

The length of the user defined code. It cannot be greater than 10 characters.

mnKeysCDLMATH_NUMERICNONENONE

The length of the user defined code. It cannot be greater than 10 characters.

cSuppressErrorMessagesEV02charNONENONE

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

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.

cCallTypeEV02charNONENONE

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

Related Functions

B0000130 Retrieve Company From Business Unit

Related Tables

F0010 Company Constants
F4115 Item History