AR490 RPG36
The provided document, AR490.rpg36.txt
, is an RPG III (RPG/36) program used on IBM midrange systems (e.g., System/36 or AS/400) to generate a credit limit grouping list. This program is called by the OCL program AR490.ocl36.txt
after sorting data with #GSORT
. Below, I explain the process steps, business rules, tables/files used, and external programs called.
Process Steps of the RPG Program¶
The AR490
RPG program processes sorted input data from the ARCLGR
file, retrieves additional data from ARCONT
and ARCUST
, and produces a formatted report on the printer file PRINT
. The steps are as follows:
- Program Initialization:
- Header Specification:
H P064 B AR490
: Specifies program nameAR490
with a program identifierP064
and batch mode (B
).
- File Declarations:
ARCLGR
: Primary input file (240 bytes, disk, no key).ARCONT
: Input file (256 bytes, indexed, key at position 2, record length 256).ARCUST
: Input file (384 bytes, indexed, key at position 8, record length 384).PRINT
: Output printer file (165 bytes, with overflow indicatorOF
).
- Data Structures:
SEP
: Array of 82 elements (2 bytes each) for separator lines in the report.ARC
: Array of 25 elements (6 bytes each, numeric) to store credit limit group numbers (CGCL01
toCGCL25
).
-
Variables:
TIMDAT
(12 bytes): Stores system time and date.TIME
(6 bytes): Formatted time.DATE
(6 bytes): Formatted date.PAGE
(implied): Page number for the report.
-
Read Primary File (
ARCLGR
): - The program reads records from
ARCLGR
sequentially (primary file, levelL1
). - Each record contains:
CGDEL
(position 1): Delete code ('D' for deleted).CGCONO
(positions 2-3): Company number.CGCUST
(positions 4-9): Customer number.CGCL01
toCGCL25
(positions 10-159): Up to 25 credit limit group numbers.ARKEY
(positions 2-9): Composite key (company number + customer number) for chaining toARCUST
.
-
Records marked with
CGDEL = 'D'
are processed but not explicitly filtered out in the code (business rule may assume sorting excluded them). -
Retrieve Company Name (
ARCONT
): - Logic:
- At level
L1
(for eachARCLGR
record), chain toARCONT
usingCGCONO
(company number) as the key (line 0048). - If the record is not found (indicator
44
on), setACNAME
to blanks (line 0049).
- At level
-
Fields:
ACNAME
(positions 4-33): Company name retrieved fromARCONT
.
-
Retrieve Customer Name (
ARCUST
): - Logic:
- Chain to
ARCUST
usingARKEY
(company number + customer number, positions 2-9) as the key (line 0057). - If the record is not found (indicator
99
on), setARNAME
to blanks (line 0058).
- Chain to
-
Fields:
ARCO
(positions 2-3): Company number (for validation, not used here).ARNAME
(positions 10-39): Customer name.
-
Report Header Processing:
- Logic (lines 0051-0055):
- If not already processed (indicator
11
off): - Set
SEP
to'* '
(separator line). - Capture system time and date into
TIMDAT
(12 bytes). - Move
TIMDAT
toTIME
(first 6 bytes) andDATE
(last 6 bytes). - Set indicator
11
on to prevent reprocessing.
- If not already processed (indicator
-
Output (lines 0061-0083, detail lines at
L1
):- Write header lines when overflow (
OF
) or at levelL1
: - Line 1:
ACNAME
(company name, 30 characters), "PAGE", and page number (PAGE
, zero-suppressed). - Line 2: "CREDIT LIMIT GROUPING LIST", "TIME", and formatted time (
TIME
). - Line 3: Separator line (
SEP
). - Line 4: "CUSTOMER" and "GROUPING" labels.
- Line 5: Separator line (
SEP
).
- Write header lines when overflow (
-
Detail Line Processing:
- Logic (lines 0084-0104, detail lines at level
01
):- For each
ARCLGR
record: - Write detail line 1:
CGCUST
(customer number, zero-suppressed, 6 characters).ARNAME
(customer name, 40 characters, left-justified).
- Write detail line 2:
- Credit limit group numbers (
ARC,1
toARC,15
, corresponding toCGCL01
toCGCL15
, zero-suppressed, 9-character spacing).
- Credit limit group numbers (
- For each
-
Output:
- Lists customer number, name, and up to 15 credit limit group numbers per customer (though
ARCLGR
supports up to 25, only 15 are printed).
- Lists customer number, name, and up to 15 credit limit group numbers per customer (though
-
Program Termination:
- The program ends when
ARCLGR
reaches end-of-file, closing all files and terminating.
Business Rules¶
The program enforces the following business rules for generating the credit limit grouping list:
- Data Source:
- Processes sorted records from
ARCLGR
, which contains company numbers, customer numbers, and up to 25 credit limit group numbers per customer. -
Assumes
ARCLGR
is pre-sorted by company and customer number (handled by#GSORT
inAR490.ocl36.txt
). -
Company Validation:
- Retrieves company name (
ACNAME
) fromARCONT
usingCGCONO
. -
If the company is not found, prints a blank company name.
-
Customer Validation:
- Retrieves customer name (
ARNAME
) fromARCUST
usingARKEY
(company + customer number). -
If the customer is not found, prints a blank customer name.
-
Report Formatting:
- Groups output by company, printing the company name in the header.
- Lists each customer’s number, name, and up to 15 credit limit group numbers.
- Includes page number, date, and time in the header.
-
Uses separator lines (
* * *
) for readability. -
Deletion Handling:
-
Processes records with
CGDEL
(delete code), but does not explicitly filter out deleted records (CGDEL = 'D'
). The sorting step inAR490.ocl36.txt
likely excludes deleted records. -
Output Limitation:
- Prints only the first 15 credit limit groups (
CGCL01
toCGCL15
) out of 25 possible groups inARCLGR
, potentially omitting data if more than 15 groups exist.
Tables/Files Used¶
The program uses the following files:
1. ARCLGR:
- Primary input file (240 bytes, disk).
- Contains:
- CGDEL
(1 byte): Delete code.
- CGCONO
(2 bytes): Company number.
- CGCUST
(6 bytes): Customer number.
- CGCL01
to CGCL25
(6 bytes each): Credit limit group numbers.
- ARKEY
(8 bytes): Composite key (company + customer).
- Sorted by company and customer number by #GSORT
.
2. ARCONT:
- Input file (256 bytes, indexed, key at position 2).
- Contains:
- ACNAME
(30 bytes, positions 4-33): Company name.
- Used to retrieve company names.
3. ARCUST:
- Input file (384 bytes, indexed, key at position 8).
- Contains:
- ARCO
(2 bytes, positions 2-3): Company number.
- ARNAME
(30 bytes, positions 10-39): Customer name.
- Used to retrieve customer names.
4. PRINT:
- Output printer file (165 bytes).
- Used to generate the report with headers and detail lines.
External Programs Called¶
The RPG program does not explicitly call any external programs using CALL
or similar operations. It is invoked by the OCL program AR490.ocl36.txt
and relies on the sorted input from #GSORT
, but no additional programs are called within the RPG code.
Summary¶
- Process Steps: The program reads sorted records from
ARCLGR
, retrieves company names fromARCONT
and customer names fromARCUST
, and generates a printer report (PRINT
) with headers (company name, date, time, page) and detail lines (customer number, name, up to 15 credit limit group numbers). It formats the report with separator lines and handles missing data by printing blanks. - Business Rules: Processes sorted
ARCLGR
data, validates company and customer numbers, prints up to 15 credit limit groups per customer, and formats the report with headers and separators. Assumes pre-filtered data (e.g., non-deleted records) from sorting. - Tables/Files:
ARCLGR
(input data),ARCONT
(company names),ARCUST
(customer names),PRINT
(report output). - External Programs: None called within the RPG program.
If you need further details (e.g., sample report output or file record layouts), please provide additional information or requirements.