AR901 RPG36
The provided document, AR901.rpg36.txt
, is an RPG II program for the IBM System/36, called from the main OCL program (AR901P.ocl36.txt
). It generates a "Customer Master File List," a report listing customer details. Below, I’ll explain the process steps, business rules, tables (files) used, and any external programs called.
Process Steps of the RPG II Program¶
The RPG II program AR901
processes customer data from multiple files to produce a formatted printed report. It uses fixed-format specifications (F, I, C, O) typical of RPG II on System/36. Here’s a detailed breakdown of the process steps:
- Program Initialization:
- Header Specification:
H P014
: Specifies program identifierP014
forAR901
.
- File Declarations:
FARCUST IP F 384 384R I DISK
: Primary input fileARCUST
(customer master file), 384 bytes, indexed.FAR901S IR F 30 3 3IT EDISK
: Input fileAR901S
, 30 bytes, likely a selection or parameter file, externally described.FARCONT IC F 256 256R 2AI 2 DISK
: Input fileARCONT
(company master file), 256 bytes, indexed, keyed on position 2 (ARCO
, company number).FARCUSP IC F 1344 1344R 8AI 2 DISK
: Input fileARCUSP
(customer supplemental file), 1344 bytes, indexed, keyed on position 2.FGSTABL IF F 256 256 12AI 2 DISK
: Input fileGSTABL
(table file), 256 bytes, indexed, keyed on position 2.FPRINTER O F 164 164 OF PRINTER
: Output filePRINTER
, 164 bytes, for generating the printed report.
- Extension Specification:
E AR901S ARCUST
: Links the externally described fileAR901S
toARCUST
for field definitions.
-
Input Specifications:
IARCUST NS 01
: Defines fields forARCUST
:ARCOCU
(positions 2-9): Customer number.ARCO
(positions 2-3, level L1): Company number.ARCUST
(positions 4-9): Customer number (subset ofARCOCU
).ARNAME
(positions 10-39): Customer name.ARADR1-4
(positions 40-69, 70-99, 100-129, 130-159): Address lines 1-4.ARAREA
(positions 257-258, packed): Area code.ARTELE
(positions 259-262, packed): Telephone number.ARTERM
(positions 265-266): Terms code.IARCONT NS 02
: Defines fields forARCONT
:ACNAME
(positions 4-33): Company name.IARCUSP NS
: Defines fields forARCUSP
:CSCNCT
(positions 267-291): Contact name.IGSTABL NS 01
: Defines fields forGSTABL
:TBDEL
(position 1): Deletion flag ('D' for deleted).TBTYPE
(positions 2-7): Table type.TBCODE
(positions 8-13): Table code.TBDESC
(positions 14-43): Table description.
-
Main Processing Logic (Calculation Specifications):
-
Level 1 (L1) Processing:
- Triggered for each
ARCUST
record matching the company number (ARCO
, level indicator L1). - Company Lookup:
ARCO CHAIN ARCONT 99
: Chains (looks up) the company number inARCONT
.- If not found (
*in99 = *on
), setsACNAME
to blanks. - Time and Date Setup:
TIME TIME12 120
: Retrieves the system time intoTIME12
(12 digits).MOVEL TIME12 TIME 60
: Moves the time to a 6-character field.MOVE TIME12 DATE 60
: Moves the date portion to a 6-character field (formatted as YYMMDD).Z-ADD *ZEROS PAGE
: Initializes the page number to 0.- Customer Data Processing:
Z-ADD ARAREA AREA 30
: Moves the area code toAREA
(3 digits, zoned).Z-ADD ARTELE TELE 70
: Moves the telephone number toTELE
(7 digits, zoned).ARCOCU CHAIN ARCUSP 97
: Chains the customer number toARCUSP
to retrieve contact information.- If not found (
*in97 = *on
), setsCSCNCT
to blanks. - Terms Code Lookup:
MOVEL 'ARTERM' TRMKEY 12
: Sets the table key prefix to 'ARTERM'.MOVE ARTERM TRMKEY
: Appends the terms code toTRMKEY
.TRMKEY CHAIN GSTABL 99
: Chains toGSTABL
to retrieve the terms description.- If found (
*in99 = *off
), movesTBDESC
toTRMDSC
(20 characters); otherwise, setsTRMDSC
to blanks.
- Triggered for each
-
Output Processing (Output Specifications):
- Header Output (H):
OPRINTER H 103 L1
: Prints header lines at level 1 (for each company).- Outputs:
ACNAME
(company name, position 30).- Literal 'PAGE' (position 134).
PAGE
(zoned, position 138).- Literal 'DATE' (position 150).
DATE
(formatted as YY/MM/DD, position 159).H 2 L1
: Prints a title line:- Literal ' CUSTOMER MASTER LIST ' (position 77).
- Literal 'TIME' (position 150).
TIME
(formatted as HH.MM.SS, position 159).
- Detail Lines (D):
D 1 L1
: Prints decorative lines (asterisks) for formatting (positions 24, 48, 72, 96, 120, 144, 164).D 1 L1
: Prints column headers:- 'CUST#' (position 6).
- 'CUSTOMER NAME' (position 20).
- 'ADDRESS' (position 52).
- 'PHONE' (position 83).
- 'CONTACT' (position 102).
- 'PAYMENT TERMS' (position 137).
D 2 L1
: Prints additional decorative lines for formatting.D 2 01
: Prints customer details:ARCUST
(customer number, zoned, position 6).ARNAME
(customer name, position 37).ARADR1
(address line 1, position 68).AREA
(area code, zoned, blank-suppressed, position 74).TELE
(telephone, blank-suppressed, formatted as XXX-XXXX, position 83).CSCNCT
(contact name, position 121).TRMDSC
(terms description, position 144).D 1 01
: Prints additional address lines:ARADR2
(address line 2, position 68).ARADR3
(address line 3, position 68).ARADR4
(address line 4, position 68, conditional on*in10 = *off
).
Business Rules¶
The program enforces the following business rules for generating the customer master list:
- Company Validation:
- For each customer record in
ARCUST
, the company number (ARCO
) is looked up inARCONT
to retrieve the company name (ACNAME
). -
If no matching company is found, the company name is blank.
-
Customer Data Retrieval:
- Customer number (
ARCOCU
) is used to retrieve contact information (CSCNCT
) fromARCUSP
. -
If no matching record is found, the contact name is blank.
-
Terms Code Lookup:
- The terms code (
ARTERM
) is used to look up a description inGSTABL
with the key 'ARTERM' +ARTERM
. -
If found, the description (
TBDESC
) is used; otherwise, the terms description (TRMDSC
) is blank. -
Report Formatting:
- The report is grouped by company (
L1
level), with headers including company name, page number, date, and time. - Customer details include customer number, name, address (up to 4 lines), phone number (formatted as XXX-XXXX), contact name, and payment terms description.
-
Address line 4 is printed only if indicator
*in10
is off (likely controlled by parameters fromAR901P
). -
Data Formatting:
- Numeric fields like
ARAREA
andARTELE
are converted to zoned format for printing. - The telephone number is formatted with a hyphen (XXX-XXXX).
- The date is formatted as YY/MM/DD, and the time as HH.MM.SS.
Tables (Files) Used¶
- ARCUST:
- Type: Primary input file (disk, indexed).
- Record Length: 384 bytes.
- Key: Not explicitly defined in the code but implied to be
ARCO
(company number) for level processing. - Fields:
ARCOCU
(positions 2-9): Customer number (8 characters).ARCO
(positions 2-3): Company number (2 characters, level L1).ARCUST
(positions 4-9): Customer number (6 characters).ARNAME
(positions 10-39): Customer name (30 characters).ARADR1-4
(positions 40-159): Address lines (30 characters each).ARAREA
(positions 257-258, packed): Area code (3 digits).ARTELE
(positions 259-262, packed): Telephone number (7 digits).ARTERM
(positions 265-266): Terms code (2 digits).
-
Purpose: Main customer master file containing core customer data.
-
AR901S:
- Type: Input file (disk, externally described).
- Record Length: 30 bytes.
-
Purpose: Likely contains selection parameters (e.g., company or customer filters) from
AR901P
. Linked toARCUST
via the extension specification. -
ARCONT:
- Type: Input file (disk, indexed).
- Record Length: 256 bytes.
- Key: Position 2 (
ARCO
, company number). - Fields:
ACNAME
(positions 4-33): Company name (30 characters).
-
Purpose: Stores company details for the report header.
-
ARCUSP:
- Type: Input file (disk, indexed).
- Record Length: 1344 bytes.
- Key: Position 2 (likely customer number).
- Fields:
CSCNCT
(positions 267-291): Contact name (25 characters).
-
Purpose: Stores supplemental customer data, such as contact information.
-
GSTABL:
- Type: Input file (disk, indexed).
- Record Length: 256 bytes.
- Key: Position 2 (likely
TBTYPE
+TBCODE
). - Fields:
TBDEL
(position 1): Deletion flag ('D' for deleted).TBTYPE
(positions 2-7): Table type (6 characters).TBCODE
(positions 8-13): Table code (6 characters).TBDESC
(positions 14-43): Table description (30 characters).
-
Purpose: Stores lookup data for terms codes (e.g., payment terms descriptions).
-
PRINTER:
- Type: Output file (printer).
- Record Length: 164 bytes.
- Purpose: Generates the printed customer master list report.
External Programs Called¶
No external programs are explicitly called within AR901.rpg36
(e.g., via CALL
operations). The program is invoked by the OCL program (AR901P.ocl36.txt
), which loads and runs AR901
(referenced in the JOBQ
or ELSE
clause). The RPGLE program AR901P
likely passes parameters (e.g., kyalco
, kyco1-kyco3
, addlst
) that control the report’s behavior, but no direct program calls occur within AR901
.
Additional Notes¶
- Integration with OCL and RPGLE:
- The OCL program (
AR901P.ocl36.txt
) sets up the environment, loadsAR901P
, and optionally queues or runsAR901
. - The RPGLE program (
AR901P.rpgle
) collects and validates user input (e.g., company/customer selections, address list flag) and passes parameters toAR901
via shared memory or files likeAR901S
. -
AR901
processes these parameters to filter records fromARCUST
and generate the report. -
Indicator Usage:
*in99
: Indicates whether aCHAIN
toARCONT
orGSTABL
fails.*in97
: Indicates whether aCHAIN
toARCUSP
fails.*in10
: Controls whether address line 4 (ARADR4
) is printed (likely set byaddlst
fromAR901P
).-
L1
: Level indicator for processing records by company number (ARCO
). -
Report Structure:
- The report includes a header with company name, page number, date, and time, followed by a formatted customer list with columns for customer number, name, address, phone, contact, and payment terms.
-
Decorative lines (asterisks) separate sections for readability.
-
No Chart Generation:
- The query does not request a chart, and no numerical data is provided for visualization, so no chart is generated.
If you need further analysis (e.g., specific field mappings, sample report output, or deeper integration details with AR901P
), please provide additional context or files.