AR191 RPG36
The RPG program AR191.rpg36.txt
is an RPG/36 program (likely for an IBM System/36 or AS/400 environment) that handles the A/R Salesman Change Transaction Edit process, as referenced in the previously provided .OCL
file (AR190.ocl36.txt). This program generates a printed report listing salesman change transactions from the ARSLST
file, including customer and salesman details, with validation against related files. Below, I’ll explain the process steps, business rules, tables used, and external programs called based on the provided RPG code.
Process Steps of RPG Program AR191¶
The AR191
program is a batch reporting program that processes records from the ARSLST
file and produces a formatted report on a printer file (ARPRINT
). It retrieves additional data from the ARCUST
and GSTABL
files to enrich the report with customer names and salesman descriptions. Here’s a detailed breakdown of the process steps:
- File Definitions and Initialization:
- Files Defined:
ARSLST
: Primary input file (IP
) for salesman change transactions, with a 256-byte record length and an 8-byte key starting at position 2. Fields include:ASDEL
(delete code, position 1,'D'
for deleted records).ASCO
(company number, positions 2–3).ASCUST
(customer number, positions 4–9).ASSLSO
(old salesman code, positions 10–11).ASSLSN
(new salesman code, positions 12–13).ARCUST
: Input file (IF
) for customer master data, with a 384-byte record length and an 8-byte key. Fields include:ARNAME
(customer name, positions 10–39).GSTABL
: Input file (IF
) for general table data (e.g., salesman codes), with a 256-byte record length and a 12-byte key. Fields include:TBDESC
(table description, e.g., salesman name, positions 14–43).ARPRINT
: Output file (O
) for the printed report, with a 132-byte record length.
-
Initial Setup (lines 0022–0029):
- The program checks the
ONCE
variable to ensure initialization occurs only once (ONCE = 0
). - Sets
ONCE = 1
to prevent re-execution of initialization. - Captures the current time (
TIME
) intoTIMEX
(12 digits). - Formats the time into
TIMEOF
(6 characters, likely HHMMSS) and date intoDATE
(6 characters, likely MMDDYY). - This information is used in the report header.
- The program checks the
-
Record Processing Loop:
- The program implicitly processes each record in
ARSLST
sequentially, asARSLST
is defined as the primary input file (IP
), triggering a level break (L1
) on changes in the company number (ASCO
). -
For each
ARSLST
record (lines 0032–0043):- Customer Lookup:
- Builds a key (
ARKEY
) by combiningASCO
(company number) andASCUST
(customer number). - Performs a
CHAIN
operation onARCUST
to retrieve the customer name (ARNAME
). - If the customer is not found (indicator 10 on), sets
ARNAME
to'INVALID'
; otherwise, uses the retrievedARNAME
. - Salesman Lookup:
- Builds a key (
SLKEY
) by combining the literal'SLSMAN'
and the new salesman code (ASSLSN
). - Performs a
CHAIN
operation onGSTABL
to retrieve the salesman description (TBDESC
). - If the salesman code is not found (indicator 10 on), sets
TBDESC
to'INVALID'
; otherwise, uses the retrievedTBDESC
.
-
Report Generation:
- The program writes records to the
ARPRINT
printer file using output specifications (lines 0046–0089). - Header Output (lines 0046–0082):
- On a level break (
L1
, change inASCO
) or overflow (OF
), prints the report header: - Page number (
PAGE
) at position 104–108 (e.g., "PAGE 001"). - Date (
DATE
, formatted as MM/DD/YY) at position 120–129. - Report title (" SALESMAN CHANGE EDIT ") centered at position 75.
- Time (
TIMEOF
, formatted as HH.MM.SS) at position 120–129. - Decorative lines of asterisks (
* * * * * * * * * * * *
) across positions 24–131. - Column headers:
- "CO" (company number) at position 2.
- "CUSTOMER #", "NAME", "SALESMAN OLD NEW" at positions 11, 32, and 58, respectively.
- Another set of decorative asterisk lines.
- On a level break (
-
Detail Output (lines 0083–0089):
- For each
ARSLST
record (conditioned by01
, non-deleted records whereASDEL ≠ 'D'
): ASCO
(company number) at position 2.ASCUST
(customer number, zero-suppressed) at position 10.ARNAME
(customer name fromARCUST
) at position 45.ASSLSO
(old salesman code) at position 53.ASSLSN
(new salesman code) at position 58.TBDESC
(new salesman description fromGSTABL
) at position 90.
- For each
-
Program Termination:
- The program ends automatically after processing all
ARSLST
records, as is typical for primary input file processing in RPG/36. No explicit loop termination is coded, and the program closes the printer file (ARPRINT
) upon completion.
Business Rules¶
The AR191
program enforces the following business rules for generating the salesman change edit report:
- Record Selection:
- Only non-deleted records (
ASDEL ≠ 'D'
) fromARSLST
are included in the report (indicator01
in output specifications, line 0083). -
Records are grouped by company number (
ASCO
), with a level break (L1
) triggering header output when the company number changes. -
Data Validation and Enrichment:
- Customer Validation:
- Each
ARSLST
record’s customer number (ASCUST
) is validated against theARCUST
file using the keyASCO + ASCUST
. - If the customer is not found, the report displays
'INVALID'
for the customer name (ARNAME
).
- Each
-
Salesman Validation:
- The new salesman code (
ASSLSN
) is validated against theGSTABL
file using the key'SLSMAN' + ASSLSN
. - If the salesman code is not found, the report displays
'INVALID'
for the salesman description (TBDESC
).
- The new salesman code (
-
Report Formatting:
- The report includes a header with page number, date, time, and title, printed on each company change (
L1
) or page overflow (OF
). - Detail lines show:
- Company number (
ASCO
). - Customer number (
ASCUST
, zero-suppressed). - Customer name (
ARNAME
). - Old salesman code (
ASSLSO
). - New salesman code (
ASSLSN
). - New salesman description (
TBDESC
).
- Company number (
-
The report is formatted with fixed-position fields and decorative asterisk lines for readability.
-
Date and Time:
- The report includes the system date and time in the header, formatted as MM/DD/YY and HH.MM.SS, respectively.
Tables (Files) Used¶
The following files are used by the AR191
program:
1. ARSLST: Primary input file for salesman change transactions (input mode, IP
), containing:
- ASDEL
(delete code, 1 byte, 'D'
for deleted records).
- ASCO
(company number, positions 2–3).
- ASCUST
(customer number, positions 4–9).
- ASSLSO
(old salesman code, positions 10–11).
- ASSLSN
(new salesman code, positions 12–13).
2. ARCUST: Customer master file (input mode, IF
), containing:
- ARNAME
(customer name, positions 10–39).
3. GSTABL: General table file (input mode, IF
), containing:
- TBDESC
(table description, e.g., salesman name, positions 14–43).
4. ARPRINT: Printer output file (O
), used to generate the report with a 132-byte record length.
External Programs Called¶
The AR191
program does not explicitly call any external programs (e.g., via CALL
operations). It operates as a standalone batch program, processing input files and generating output directly to the printer file.
Summary¶
- Process Steps:
- Initializes the program by capturing the system date and time for the report header.
- Processes each
ARSLST
record sequentially, grouped by company number (ASCO
). - Validates customer numbers against
ARCUST
and salesman codes againstGSTABL
, marking invalid entries with'INVALID'
. - Generates a formatted report to
ARPRINT
with headers (on company change or page overflow) and detail lines for non-deleted records. -
Terminates after processing all records.
-
Business Rules:
- Includes only non-deleted
ARSLST
records (ASDEL ≠ 'D'
). - Validates customer and salesman data, displaying
'INVALID'
for missing records. - Groups records by company number, with headers printed on company changes or page overflows.
-
Formats the report with fixed-position fields, including date, time, and decorative lines.
-
Tables Used:
ARSLST
,ARCUST
,GSTABL
,ARPRINT
. -
External Programs: None.
This program complements AR190
(add/update transactions) by providing a printed edit report to verify salesman change transactions. If you have additional details (e.g., sample data or report output formats), I can provide further analysis. Let me know if you’d like me to search for related information or analyze other files!