AverageCostUpdate

Average Cost Update

Major Business Rule

Object Name: X4181

Parent DLL: COPBASE

Location: Client/Server

Language: C

Functional Description

Purpose

This function writes transactions to the Average Cost work file.  If the system constant is on for 
average cost, the item is calculated and updated.


Setup Notes and Prerequisites

The Item Number fields (ITM, LITM, AITM), Branch (MCU), Extended Cost (PAID), Costing Level (CLEV), 

Update Average Cost flag (AVGC) and Margin Maintenance (MMPC) fields are required input parameters.


If you have the Update Average Cost flag from the System Constants table (F4009) prior to calling 

this function, please pass it in.  Also, the Margin Maintenance flag needs to be retrieved from the Item 

Branch table (F4102).


Specical Logic

None

Technical Specification

This function retrieves the Distribution Constants if the Average Cost Update flag is blank.  If the 
flag is an 'N', a record is written to the Average Cost table (F41051).   If the flag is a 'Y', all 

location records (F41021) for the Item, Branch, Location and Lot passed in are retrieved.  The quantity 

on hand is accumulated for all records read.  The average cost is retrieved from the Item Cost table 

(F4105) and the new average cost is calculated.  


Calculation is as follows:


If quantity exists for the item

If Total Qty on Hand not equal zeros


** Calculate new average cost - calculate the 

**Calculate new average cost - calculate the on 

hand quantity that was 'costed' at the old 

average cost.  This will be the original

 quantity.


Take Total Qty on Hand and subtract the

 transaction quantity, resulting in work

 field X


***Calculate the extended amount based on

 the original quantity and the current

 average cost.


Multiply Total Qty on Hand by Average Cost

 resulting in work field Y


***Calculate the total extended amount 

which is the extended cost of the passed

 transaction plus the extended cost of the

 on hand quantity and the current average

 cost.


Take Extended Cost (passed in) and add Y, resulting in work field 

TOTAL


***Calculate the new average cost


Take TOTAL and divide by Total Qty on Hand, resulting in work field 

NEW


***Retrieve the CURRENT average cost based on the costing level



Call GetItemCost(XF4105) with LEDG = '02'


If record found

Move '02' to COLEDG

Load NEW into COUNCS


Call UpdateItemCost(XF4105) to update record


else

***Determine if the Average Cost should be the costing 

method 

CallGetDefaultInventoryPurchasingCostMethod(XF4105)

Move '02' to COLEDG
Load NEW into COUNCS


Call UpdateItemCost(XF4105) to write record



***Perform Margin Maintenance

IF Margin Maintenance (MGMN) is equal 'Y'

If (Margin Percent) MMPC is null

Fetch the Item Branch (F4102) with ITM 

and MCU to retrieve it

If PLEV and/or UOM1 are null

Fetch the Item Master (F4101) to retrieve 

them


If MMPC not equal zeros

Call MarginMaintPriceUpdate (X4078)




^

Data Structure

DX4181A - Average Cost Update

Parameters:
Data Item Data Structure DescriptionI/ORequired
ITMShort Item NumberIY

LITMSecond Item NumberIY

AITMThird Item NumberIY

MCUBranch/PlantIY

LOCNLocationIN

LOTNLot NumberIN

TRQT Transaction QuantityIN

PAIDExtended CostIY

CLEVCosting LevelIY

AVGCUpdate Average CostIY

MMPCMargin MaintenanceIY

MGMNMargin Maintenance Y/N IN

PLEVSales Base Price LevelIN

UOM1Primary Unit of MeasureIN

PIDProgram IDIY

CRCDCurrencyCodeIY


^

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

szSecondItemNumberLITMcharNONENONE

A number that identifies the item. The system provides three separate item numbers plus an extensive cross-reference capability to 
alternative item numbers. The three types of item numbers are: Item Number (short) An 8-digit, computer-assigned item number. 2nd Item Number A 
25-digit, user defined, alphanumeric item number. 3rd Item Number  Another 25-digit, user defined, alphanumeric item number. In addition to 
these three basic item numbers, the system provides an extensive cross-reference search capability. You can define numerous 
cross-references to alternative part numbers. For example, you can define substitute item numbers, replacements, bar codes, customer numbers, or 
supplier numbers.

szThirdItemNumberAITMcharNONENONE

The system provides three separate item numbers plus an extensive cross-reference capability to alternate item numbers. These item 
numbers are as follows: 1.  Item Number (short) - An 8-digit, computer-assigned item number. 2.  2nd Item Number - The 25-digit, free-form, user 
defined alphanumeric item number. 3.  3rd Item Number - Another 25-digit, free-form, user defined alphanumeric item number.  In addition to 
these three basic item numbers, an extensive cross-reference search capability has been provided (see XRT). Numerous cross references to 
alternate part numbers can be user defined, such as substitute item numbers, replacements, bar codes, customer numbers, or supplier 
numbers.

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.

szLocationLOCNcharNONENONE

The storage location from which goods will be moved.

szLotNumberLOTNcharNONENONE

A number that identifies a lot or a serial number. A lot is a group of items with similar characteristics.

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).

mnExtendedCostPAIDMATH_NUMERICNONENONE

The extended cost or price value of an inventory transaction for an inventory item.

cCostingLevelCLEVcharNONENONE

A code that indicates whether the system maintains one overall inventory cost for the item, a different cost for each branch/plant, or a 
different cost for each location and lot within a branch/plant. The system maintains inventory costs in the Inventory Cost table (F4105). Valid codes 
are:    1   Item level    2   Item/Branch level    3   Item/Branch/Location level

cUpdateAverageCostAVGCcharNONENONE

A code that indicates when the system calculates the new average cost for an item. Valid values are:    Y The system calculates a new 
average cost immediately after any transaction occurs that affects the average cost of an item.    N All processes that affect average cost create 
transactions to the Average Cost Work table (F41051). The system calculates a new average cost when you run the Average Cost Update 
program.

mnMarginMaintenanceMMPCMATH_NUMERICNONENONE

This field is used as a method to automatically maintain a desired margin. If a value is entered in this field, every purchase order receipt will 
add the margin percentage to the item's cost, if the costing method is 1, 2, or 6, in order to generate a new list price. For example:  Item cost = 
56.00, and Margin Maintenance % = 20, then the new list price will be as follows: 56 * ( 1 + .20 ) = 67.20

cMarginMaintenanceFlagMGMNcharNONENONE

The Margin Maintenance Y/N code is a system set work field used by Average Cost Update to determine whether or not to recalculate the 
unit price based on Margin Maintenance (%).

cSalesBasePriceLevelPLEVcharNONENONE

A code that indicates whether the system maintains standard sales prices for an item, different sales prices for each branch/plant, or 
different sales prices for each location and lot within a branch/plant. The system maintains sales prices in the Base Price file (F4106). Valid codes 
are:    1   Item level    2   Item/Branch level    3   Item/Branch/Location level 

szPrimaryUOMUOM1charNONENONE

A user defined code (00/UM) that identifies the unit of measure that the system uses to express the quantity of an item, for example, EA 
(each) or KG (kilogram).

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.

szCurrencyCodeCRCDcharNONENONE

A code that identifies the currency of a transaction. 

mnUnitCostInPrimaryUNCSMATH_NUMERICOPTNONE

The amount per unit, derived by dividing the total cost by the unit quantity.

cUseUnitCostEV01charOPTNONE

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

Related Functions

B4000530 Get Distribution Constants
X4078 Margin Maint Price Update
XF4105 Item Cost I/O

Related Tables

F4102 Item Branch File
F41021 Item Location File
F4105 Item Cost File
F41051 Average Cost Work file
DeleteAverageCostRecord

DeleteAverageCostRecord

Average Cost Update

Major Business Rule

Object Name: X4181

Parent DLL: COPBASE

Location: Client/Server

Language: C

Functional Description

Purpose

This function deletes records from the Aveage Cost table (F41051).

Setup Notes and Prerequisites

The Unique Id (UKID) is a required input parameter.


Special Logic

None


Technical Specification

This function deletes the record from the F41051 for the key passed in.


^

Data Structure

DX4181B - Delete Average Cost Record

Parameters:
Data Item Data Structure DescriptionI/ORequired

UKIDUniqueIdIY


^

Parameter NameData ItemData TypeReq/OptI/O/Both
mnUniqueIDUKIDMATH_NUMERICNONENONE

This field is a unique number used to identify a record in a file.

Related Functions

B4000530 Get Distribution Constants
X4078 Margin Maint Price Update
XF4105 Item Cost I/O

Related Tables

F4102 Item Branch File
F41021 Item Location File
F4105 Item Cost File
F41051 Average Cost Work file