Documentation >
MAC-PAC Technical Library >
Distribution >
Sales Analysis >
Programs >
Sales Analysis Async Update - Purpose >
Sales Analysis Async Update - Calculations
Sales Analysis Async Update - Calculations
SA130E
A. Housekeeping
1. See the Common Processing Routines - Housekeeping section of this manual for a general discussion of the Housekeeping subroutine. Processing specific to this program is described below.
2. The default Company Name is retrieved from the System Control file (CT100M). If this record is not found, a default message is used.
3. The following information is retrieved from the Reference file (REFERP):
a. The Sales Analysis control parameter record (category A03) is retrieved to determine last period posting type, and if month-end reports should be printed.
b. The current sales period calendar (category 407) and the last year sales period calendar (category 408) records are retrieved.
c. The default freight part (category 413) is retrieved.
4. The Sales Period Calendar Array is filled with the sales period ending dates through the sales posting period (defined on the parameter record). Remaining posting periods greater than the sales posting period are filled with the sales posting period end date for the current sales period. The data for this array is obtained from the current sales period calendar and the last sales period calendar.
B. Mainline
1. The logical Sales History by Ship Date file (OP120ML6) consists of records in which the Sales Analysis update flag is set to N (No). It is read sequentially to update the Sales Analysis file (SA100M) and the Sales History file (SA120M).
a. The shipment date on the sales history record is compared to the values in the Sales Period Calendar Array. The shipment date must be less than or equal to the posting period date of the sales period being updated.
b. The first time the sales history record is read, the key fields are saved. These fields are used to determine when all records for a given Sales Analysis record have been read.
(1) The corresponding Sales Analysis record is retrieved.
(a) If the Sales Analysis record is found, the following amounts are stored in accumulator arrays consisting of the sales periods for the current and previous years:
· Shipped order lines
· Cash sales amount
· Non-cash sales amount
· Cost of sales
· Return Lines
· Return Sales Amount
· Cost of Returns
· Other charges
(b) If the record is not found, the fields in the above accumulator arrays are set to zero and a new Sales Analysis record is created.
(2) The values from the sales history record are added to the appropriate accumulator fields in the arrays.
c. Each sales history record is compared against the saved key fields.
(1) If a break has not occurred, the values from the sales history record are added to the appropriate accumulator fields in the arrays.
(2) If a break has occurred, the accumulator arrays are used to update the sales analysis record. The key fields are resaved and the accumulator arrays are reset to zero.
d. After a sales history record has been processed, the Sales Analysis update flag is set to D (demand post).
e. Records are processed from the logical Sales History by Ship Date file until the end of file is read. The file is checked once a minute for new records to be processed.
2. If the sales period being processed is the last period of the year, further processing is performed for the Sales Analysis file. Processing continues until the file control record is read.
a. The following amounts are stored in arrays consisting of the sales periods for the current and previous years:
· Shipped order lines
· Cash sales amount
· Non-cash sales amount
· Cost of sales
· Return Lines
· Return Sales Amount
· Cost of Returns
· Other charges
b. If a record has no activity (zero quantity) in all current and previous year periods, the Sales Analysis record is deleted.
c. If a record has activity, the fields for the previous year are set to the values from the current year. The fields for the current year are set to zero.