AR291 RPG36
The AR291.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 in batch order files (BBOR01
to BBOR98
). Below is a detailed explanation of the process steps, business rules, tables/files used, and any external programs called.
Process Steps of the AR291 RPG Program¶
The AR291
RPG program updates salesman codes from an old code (ASSLSO
) to a new code (ASSLSN
) in the batch order file (BBORTR
, dynamically representing BBOR01
to BBOR98
) for records matching specific customer and company numbers. Here’s a step-by-step breakdown:
- Initialization (Lines 0034–0041):
- ONCE Routine: Executes once at program start (controlled by
ONCE
flag set to1
).- Captures the current time (
TIMEX
, 12 digits) and moves it to: TIMEOF
(6 digits, HHMMSS) for potential logging.DATE
(6 digits, likely MMDDYY or YYMMDD, depending on system format).
- Captures the current time (
-
Purpose: Sets up timestamp data, though it’s not used in output in this program (possibly for future logging or compatibility).
-
Main Processing Loop (Lines 0044–0050):
- 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
: Validates the customer in the customer master file.BBORTR
: Updates the salesman code in the batch order file (BBORTR
).
-
Condition: The
BBORTR
subroutine is executed only if the customer record is found inARCUST
(N90
condition, i.e.,ASKEY
exists). -
ARCUST Subroutine (Lines 0057–0065):
- Process:
- Chains (searches) the
ARCUST
file usingASKEY
(company and customer number fromARSLST
). - If the customer is found (
N90
), no updates are made toARCUST
in this program (unlikeAR290
). - If the old salesman code (
ASSLSO
) is zero, sets it to the current salesman code (SLMN
) fromARCUST
for tracking.
- Chains (searches) the
-
Purpose: Validates the customer and ensures the old salesman code is populated for reference, even though
ARCUST
is not updated in this program. -
BBORTR Subroutine (Lines 0068–0092):
- Process:
- Initializes a key (
KEY11
, 11 bytes) to blank and sets the lower limit (SETLL
) on theBBORTR
file to position the file pointer. - Enters a loop (
AGNBBO
tag): - Reads
BBORTR
records sequentially until no more records are found (91
indicator). - For each record:
- Checks if the company (
CO
) matchesASCO
and the customer (CUST
) matchesASCUST
fromARSLST
. - If matched, updates the salesman code (
SLSM
) to the new code (ASSLSN
) and writes the updated record (EXCPT BBO
). - Increments the counter
ASORT
to track the number of updated records.
- Checks if the company (
- Loops back to read the next record (
GOTO AGNBBO
).
- Initializes a key (
-
Purpose: Updates the salesman code in the batch order file for matching records.
-
Update ARSLST Counter (Lines 0099–0100):
- Process:
- For each
ARSLST
record processed (01N90
), updates the record (EXCPT
) with the count of updated batch order records (ASORT
).
- For each
- Purpose: Tracks the number of updates for reporting in the
AR299
program.
Business Rules¶
- Update Criteria:
- Updates are applied to
BBORTR
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 salesman code (
SLSM
) to match the old salesman code (ASSLSO
). This check was commented out, so updates now depend only on customer and company numbers. -
The new salesman code (
ASSLSN
) replaces the existing salesman code (SLSM
) in theBBORTR
file. -
File Scope:
- The program processes one batch order file at a time (
BBORTR
, representingBBOR01
toBBOR98
), as invoked by the OCL program’s loop. -
The
ARCUST
file is used for validation only, not updated. -
Error Handling:
- If a customer record is not found in
ARCUST
(90
indicator), no updates are performed inBBORTR
for that customer. -
Records in
ARSLST
marked for deletion (ASDEL
) are skipped. -
Audit and Tracking:
-
The
ASORT
counter tracks the number of records updated inBBORTR
and is stored inARSLST
for reporting. -
Data Integrity:
- The
BBORTR
file is opened in update mode (UF
) with shared access (from OCLDISP-SHRMM
), allowing concurrent access while ensuring updates are committed. - The program uses
SETLL
andREAD
for sequential processing, 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 a counter for batch order updates (ASORT
).
2. ARCUST (Input, 384 bytes, Key: 8 bytes):
- Customer master file, used to validate customers and retrieve the current salesman code (SLMN
) if ASSLSO
is zero.
3. BBORTR (Update, 512 bytes, Key: 11 bytes):
- Batch order file (represents BBOR01
to BBOR98
), updated with the new salesman code (SLSM
).
External Programs Called¶
- None: The
AR291
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:
- MG04 (09/26/2017): Removed the salesman code comparison (
SLSM IFEQ ASSLSO
), making updates based solely on customer and company numbers, aligning with the change inAR290
. - Performance Considerations:
- The program processes
BBORTR
sequentially usingSETLL
andREAD
, typical for System/36 but potentially slow for large datasets. - Shared access (
DISP-SHRMM
in OCL) ensures concurrent access but requires careful transaction management. - Legacy Context:
- This RPG III program is designed for the IBM System/36 or AS/400, using fixed-format code with cycle-based processing.
- The use of
EXCPT
for output andCHAIN
for random access is standard for RPG on this platform. - Role in OCL:
AR291
is called repeatedly by the OCL program for each batch file (BBOR01
toBBOR98
), handling one file per invocation.
This program ensures consistent salesman code updates in batch order files, validates customers against the master file, and tracks update counts for reporting, supporting the accounts receivable system’s need for accurate salesman assignments.