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)
^
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 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
| ||||
szSecondItemNumber | LITM | char | NONE | NONE |
A number that identifies the item. The system provides three separate item numbers plus an extensive cross-reference capability to
| ||||
szThirdItemNumber | AITM | char | NONE | NONE |
The system provides three separate item numbers plus an extensive cross-reference capability to alternate item numbers. These item
| ||||
szBranchPlant | 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
| ||||
szLocation | LOCN | char | NONE | NONE |
The storage location from which goods will be moved. | ||||
szLotNumber | LOTN | char | NONE | NONE |
A number that identifies a lot or a serial number. A lot is a group of items with similar characteristics. | ||||
mnTransactionQuantity | TRQT | MATH_NUMERIC | NONE | NONE |
A value that represents the available quantity, which might consist of the on-hand balance minus commitments, reservations, and
| ||||
mnExtendedCost | PAID | MATH_NUMERIC | NONE | NONE |
The extended cost or price value of an inventory transaction for an inventory item. | ||||
cCostingLevel | CLEV | char | NONE | NONE |
A code that indicates whether the system maintains one overall inventory cost for the item, a different cost for each branch/plant, or a
| ||||
cUpdateAverageCost | AVGC | char | NONE | NONE |
A code that indicates when the system calculates the new average cost for an item. Valid values are:
Y The system calculates a new
| ||||
mnMarginMaintenance | MMPC | MATH_NUMERIC | NONE | NONE |
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
| ||||
cMarginMaintenanceFlag | MGMN | char | NONE | NONE |
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
| ||||
cSalesBasePriceLevel | PLEV | char | NONE | NONE |
A code that indicates whether the system maintains standard sales prices for an item, different sales prices for each branch/plant, or
| ||||
szPrimaryUOM | UOM1 | char | NONE | NONE |
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
| ||||
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
| ||||
szCurrencyCode | CRCD | char | NONE | NONE |
A code that identifies the currency of a transaction. | ||||
mnUnitCostInPrimary | UNCS | MATH_NUMERIC | OPT | NONE |
The amount per unit, derived by dividing the total cost by the unit quantity. | ||||
cUseUnitCost | EV01 | char | OPT | NONE |
An option that specifies the type of processing for an event. |
B4000530 Get Distribution Constants | ||||
X4078 Margin Maint Price Update | ||||
XF4105 Item Cost I/O |
F4102 Item Branch File | ||||
F41021 Item Location File | ||||
F4105 Item Cost File | ||||
F41051 Average Cost Work file |