AR290 RPG36
The provided AR290.rpg36.txt
is an RPG (Report Program Generator) program for IBM System/36, invoked by the AR290.ocl36.txt
OCL program to update salesman codes for selected customers across multiple files. Below is a detailed explanation of the process steps, business rules, tables/files used, and any external programs called.
Process Steps of the AR290 RPG Program¶
The AR290
RPG program updates salesman codes from an old code (ASSLSO
) to a new code (ASSLSN
) in various files based on customer and company numbers. It processes records sequentially, updates relevant fields, and tracks the number of updates for reporting. Here’s a step-by-step breakdown:
- Initialization (Lines 0107–0114):
- ONCE Routine: Executes only once at program start (controlled by
ONCE
flag).- Captures the current time (
TIMEX
) and date. - Formats the date into a
DATE8
field (YYYYMMDD) for use in the customer history file (ARCUSHS
). - Stores the time in
TIMEOF
for history records.
- Captures the current time (
-
Purpose: Sets up timestamp data for logging changes in the customer history file.
-
Main Processing Loop (Lines 0117–0129):
- Loop Control: Processes each record in the
ARSLST
file (salesman change transaction file) where the delete flag (ASDEL
) is not set (NCD
condition, record type01
). - Subroutines Called:
ARCUST
: Updates the customer master file.ARCUSH
: Updates the customer history file (added in MG05 change, 05/06/2022).BBORDH
: Updates the order header file.BBBOLX
: Updates the bill of lading file.S5FILD
: Updates the sales analysis fixed data file (SA5FIXD
).S5FILM
: Updates the sales analysis fixed master file (SA5FIXM
).S5DBBD
: Updates the sales analysis database data file (SA5DBDX
).S5DBBM
: Updates the sales analysis database master file (SA5DBMX
).S5BCMD
: Updates the sales analysis billing control data file (SA5BCDX
).S5BCMM
: Updates the sales analysis billing control master file (SA5BCMX
).S5COPD
: Updates the sales analysis customer order data file (SA5CODX
, added in JB02, 05/13/2009).S5COPM
: Updates the sales analysis customer order master file (SA5COMX
, added in JB02).FRBINH
: Updates the freight bill history file (FRBINH2
, added in LT03, 10/13/2011).SA5SHP
: Updates the shipping unit file (SA5SHU
, added in LT03).
-
Condition: Subroutines for files other than
ARCUST
andARCUSH
are executed only if the customer record is found (N90
condition, i.e.,ASKEY
exists inARCUST
). -
ARCUST Subroutine (Lines 0136–0155):
- Process:
- Chains (searches) the
ARCUST
file usingASKEY
(company and customer number fromARSLST
). - If found (
N90
), updates the salesman code (SLMN
) to the new code (ASSLSN
) and writes the updated record (EXCPT ARCU
). - If the old salesman code (
ASSLSO
) is zero, sets it to the current salesman code (SLMN
) fromARCUST
for tracking. - Initializes counters (
ASBBO
,ASBBB
,ASSAF
,ASS4F
,ASS5F
,ASS5D
,ASS5B
,ASORT
,ASBBT
,ASS5C
,ASS5S
,ASSFR
) to zero for tracking updates in other files.
- Chains (searches) the
-
Purpose: Updates the customer master file and prepares counters for subsequent file updates.
-
ARCUSH Subroutine (Lines MG05, ~0157):
- Process:
- Writes a new record to the
ARCUSHS
file (EXCPT ARCUH
) with: - Customer data (
CUSRC1
,CUSRC2
fromARCUST
). - New salesman code (
ASSLSN
). - Date (
DATE8
) and time (TIMEOF
) of the change. - Hardcoded fields: user ID (
'GAIL '
) and change type ('DSPM2'
).
- Writes a new record to the
-
Purpose: Logs the salesman change in the customer history file for audit purposes (added in MG05, 05/06/2022).
-
File-Specific Subroutines (e.g., BBORDH, BBBOLX, S5FILD, etc.):
- Common Logic (e.g.,
BBORDH
, Lines 0158–0183):- Initializes a key (
KEY11
,KEY21
,KEY39
, orKEY8
) with the company and customer number (ASKEY
). - Sets the lower limit (
SETLL
) to position the file pointer at the first matching record. - Reads records sequentially (
READ
) until no more records are found (91
indicator). - For each record:
- Checks if the company (
CO
) and customer (CUST
) match theARSLST
record (ASCO
,ASCUST
). - If matched, updates the salesman code (
SLSM
) to the new code (ASSLSN
) and writes the updated record (EXCPT
). - Increments the corresponding counter (e.g.,
ASBBO
forBBORDH
,ASBBB
forBBBOLX
, etc.). - Loops back to read the next record (
GOTO
).
- Initializes a key (
- Note: The salesman code comparison (
SLSM IFEQ ASSLSO
) is commented out (MG04, 09/26/2017), meaning updates are based solely on customer and company number, not the old salesman code. -
Files Processed:
BBORDH
: Order header records.BBBOLX
: Bill of lading records.SA5FIXD
,SA5FIXM
: Sales analysis fixed data and master records.SA5DBDX
,SA5DBMX
: Sales analysis database data and master records.SA5BCDX
,SA5BCMX
: Sales analysis billing control data and master records.SA5CODX
,SA5COMX
: Sales analysis customer order data and master records.FRBINH2
: Freight bill history records.SA5SHU
: Shipping unit records.
-
Update ARSLST Counters (Lines 0368–0377):
- Process:
- For each
ARSLST
record processed (01N90
), updates the record (EXCPT
) with the counts of updated records in each file (ASBBO
,ASBBB
,ASS5F
,ASS5D
,ASS5B
,ASS5C
,ASS5S
,ASSFR
, etc.).
- For each
- Purpose: Tracks the number of updates for reporting in the
AR299
program.
Business Rules¶
- Update Criteria:
- Updates are applied to records where the company number (
CO
) and customer number (CUST
) match theARSLST
record’sASCO
andASCUST
. - Prior to the MG04 change (09/26/2017), updates also required the old salesman code (
SLSM
) to matchASSLSO
. This check was removed, so updates now depend only on customer and company numbers. -
The new salesman code (
ASSLSN
) replaces the existing salesman code in all relevant files. -
File Scope:
- The program updates multiple files to ensure consistency across customer-related data: customer master, order headers, bills of lading, sales analysis files, freight bills, and shipping units.
-
The customer history file (
ARCUSHS
) logs each change with a timestamp and user ID for audit purposes. -
Error Handling:
- If a customer record is not found in
ARCUST
(90
indicator), no updates are performed for that customer in other files, except for the history file (ARCUSH
). -
The program skips records in
ARSLST
marked for deletion (ASDEL
). -
Audit and Tracking:
- Counters (
ASBBO
,ASBBB
, etc.) track the number of records updated in each file, stored inARSLST
for reporting. -
The
ARCUSHS
file records each salesman change with metadata (date, time, user, change type). -
Data Integrity:
- Files are opened in update mode (
UF
) with shared access, allowing concurrent access while ensuring updates are committed. - The program uses
SETLL
andREAD
to process records sequentially, ensuring all matching records are updated.
Tables/Files Used¶
The program interacts with the following files, as defined in the File Specification (F-spec) and used in processing:
1. ARSLST (Input/Update, 256 bytes, Key: 8 bytes):
- Salesman change transaction file containing company number (ASCO
), customer number (ASCUST
), old salesman code (ASSLSO
), new salesman code (ASSLSN
), and counters for updated records.
2. ARCUST (Update, 384 bytes, Key: 8 bytes):
- Customer master file, updated with the new salesman code (SLMN
).
3. ARCUSHS (Output, 411 bytes, Key: 26 bytes):
- Customer history file, records salesman change details (added in MG05).
4. BBORDH (Update, 512 bytes, Key: 11 bytes):
- Order header file, updates salesman code (SLSM
).
5. BBBOLX (Update, 512 bytes, Key: 21 bytes):
- Bill of lading file, updates salesman code (SLSM
).
6. SA5FIXD (Update, 1024 bytes, Key: 39 bytes):
- Sales analysis fixed data file, updates salesman code (SLSM
).
7. SA5FIXM (Update, 1024 bytes, Key: 39 bytes):
- Sales analysis fixed master file, updates salesman code (SLSM
).
8. SA5DBDX (Update, 1024 bytes, Key: 39 bytes):
- Sales analysis database data file, updates salesman code (SLSM
).
9. SA5DBMX (Update, 1024 bytes, Key: 39 bytes):
- Sales analysis database master file, updates salesman code (SLSM
).
10. SA5BCDX (Update, 1024 bytes, Key: 39 bytes):
- Sales analysis billing control data file, updates salesman code (SLSM
).
11. SA5BCMX (Update, 1024 bytes, Key: 39 bytes):
- Sales analysis billing control master file, updates salesman code (SLSM
).
12. SA5CODX (Update, 1024 bytes, Key: 39 bytes):
- Sales analysis customer order data file, updates salesman code (SLSM
) (added in JB02).
13. SA5COMX (Update, 1024 bytes, Key: 39 bytes):
- Sales analysis customer order master file, updates salesman code (SLSM
) (added in JB02).
14. FRBINH2 (Update, 2176 bytes, Key: 8 bytes):
- Freight bill history file, updates salesman code (SLSM
) (added in LT03).
15. SA5SHU (Update, 1500 bytes, Key: 11 bytes):
- Shipping unit file, updates salesman code (SLSM
) (added in LT03).
External Programs Called¶
- None: The
AR290
RPG program does not call any external programs. It is a standalone program invoked by theAR290.ocl36.txt
OCL program and performs all processing internally through its subroutines.
Additional Notes¶
- File Modifications:
- The program has been modified over time:
- JB02 (05/13/2009): Added support for
SA5CODX
andSA5COMX
. - LT03 (10/13/2011): Added support for
FRBINH2
andSA5SHU
, and fieldsASS5S
andASSFR
toARSLST
. - MG04 (09/26/2017): Removed salesman code comparison, making updates based solely on customer and company numbers.
- MG05 (05/06/2022): Added output to
ARCUSHS
for audit logging.
- JB02 (05/13/2009): Added support for
- Performance Considerations:
- The program processes files sequentially using
SETLL
andREAD
, which is typical for System/36 but may be inefficient for large datasets. - Shared access (
DISP-SHRMM
in OCL) ensures concurrent access but requires careful transaction management. - Legacy Context:
- This RPG program is designed for the IBM System/36, a legacy platform, and uses fixed-format RPG III code with cycle-based processing.
- The use of
EXCPT
for output andCHAIN
for random access is characteristic of RPG programming on this system.
This program ensures consistent salesman code updates across multiple related files, maintains audit trails, and tracks update counts for reporting, adhering to the business need for accurate customer-salesman associations in an accounts receivable system.