AR820 RPG36
The provided RPG program, AR820.rpg36.txt
, is written in RPG/36 (used on IBM System/36 or AS/400 systems) and supports an Alpha Customer Search for pricing inquiries, as called from the AR820.ocl36.txt
OCL program. It handles customer searches based on customer number, product code, container code, and a partial customer name, displaying results interactively on a workstation screen. Below is a detailed explanation of the process steps, business rules, tables/files used, and external programs called.
Process Steps of the RPG Program¶
The RPG program is structured to handle user input, validate data, retrieve customer and product information, and display results on a screen. It uses subroutines to manage input processing, scrolling (roll forward/backward), and data validation. Here’s a step-by-step breakdown of the process:
- File and Program Definitions (Lines 0013–0192):
- File Definitions:
SCREEN
: A workstation file for interactive display (100 bytes, with subfiles for scrolling).ARCONT
: Input file for company control data (256 bytes, keyed by company number).ARCUSX
: Input file for customer cross-reference data (384 bytes, keyed by company and customer).ARCUST
: Input file for customer master data (384 bytes, keyed by customer number).GSPROD
: Input file for product master data (512 bytes, keyed by product code).GSCNTR1
: Input file for container data (512 bytes, keyed by container code).
-
Array and Data Structure Definitions:
SNM
: Array for keyed search name (10 elements, 1 character each).CXNM
: Array for customer cross-reference name (10 elements, 1 character each).MSG
: Array for error messages (6 elements, 40 characters each).INFDS
: Information data structure for workstation status (e.g.,STATUS
for function key detection).UDS
: User data structure for local data area (LDA) fields likeICO
(company),ICUST
(customer),IPROD
(product),ICNTR
(container),EOJ
(end-of-job flag), andFIRST
(first screen flag).
-
Initialization (Lines 0068–0070):
- Resets indicators
81
,82
,83
,60
,61
,62
, and84
to0
. - Sets default message to
MSG,2
("MORE ITEMS EXIST") in theMORE
field. -
Initializes
PRDKEY
to'PRODCD'
for product code lookups. -
Function Key Handling (Lines 0072–0081, 0257–0261):
- KA (F3): Sets indicator
81
(rekey, no add/update) and resets01
,02
,09
(Lines 0075–0076). - KG (F12): Sets
LR
(last record), setsEOJ
to'E'
, resets01
,02
,09
, and jumps toEND
(Lines 0078–0081). - 18 (Roll Up): Calls
ROLLFW
subroutine for forward scrolling (Line 0072). - 19 (Roll Down): Calls
ROLLBW
subroutine for backward scrolling (Line 0073). -
The
ROLLKY
subroutine (Lines 0257–0261) detects function keys by checkingSTATUS
(01122 for Roll Up, 01123 for Roll Down). -
First Screen Processing (Subroutine S1, Lines 0101, 0111–0144):
- Input Validation (Screen NS 01, Lines 0024–0028):
- Reads input fields:
CONO
(company number),HCUST
(customer number),HPROD
(product code),HCNTR
(container code),SNM
(search name). - If
FIRST
is blank (first execution), setsFIRST
to'N'
and indicator81
(Line 0083–0086). - If
CONO
is zero, chains toARCONT
to validate company number; if invalid, sets error messageMSG,6
("INVALID COMPANY NUMBER ENTERED"), indicator81
, and jumps toENDCHK
(Lines 0090–0091). - If
HCUST
is non-zero: - Chains to
ARCONT
to validate company (Lines 0096–0098). - Constructs
CUSKEY
(company + customer) and chains toARCUST
to validate customer; if invalid, setsMSG,3
("INVALID CUSTOMER NUMBER ENTERED") and indicator81
(Lines 0096–0098). - If
HPROD
is non-blank, chains toGSPROD
to validate product code; if invalid, setsMSG,4
("INVALID PRODUCT CODE ENTERED") and indicator81
(Lines 0096–0098, JB02). - If
HCNTR
is non-blank, chains toGSCNTR1
to validate container code; if invalid, setsMSG,5
("INVALID CONTAINER ENTERED") and indicator81
(Lines 0096–0098, JB03). - Stores valid inputs (
CONO
,HCUST
,HPROD
,HCNTR
) in LDA fields (ICO
,ICUST
,IPROD
,ICNTR
).
- Reads input fields:
-
Search Name Processing:
- Counts non-blank characters in
SNM
(search name) up to the first blank or 10 characters, storing count inSCNT
(Lines 0128–0136). - Replaces asterisks (
*
) inSNM
with blanks (Lines 0132–0133). - Builds
VXLIM1
(company + search name) and sets lower limit forARCUSX
file usingSETLL
(Lines 0139–0142). - Calls
SETUP2
subroutine to process search results (Line 0143).
- Counts non-blank characters in
-
Second Screen Processing (Subroutine S2, Lines 0106, 0203–0210):
- Reads input fields:
ICO
(company),ICUST
(customer),IPROD
(product),ICNTR
(container) (Lines 0031–0033). - If
ICUST
is zero orIPROD
is blank, setsLR
and jumps toEND
(Lines 0103–0105). - Otherwise, calls
SETUP2
to display results (Line 0106). -
Resets roll indicators
18
and19
(Line 0107). -
SETUP2 Subroutine (Lines 0146–0187):
- Initializes line counter (
LIN
) to 6 and resets indicators (Line 0149). - If
HPROD
orHCNTR
is non-blank, updates LDA fieldsIPROD
andICNTR
(Lines 0148–JB03). - Reads
ARCUSX
records sequentially (Line 0152):- Skips records where
CXDEL
is'D'
(deleted) orCXCONO
does not matchCONO
(Lines 0155–0157). - Calls
CK
subroutine to compare search name (SNM
) with customer cross-reference name (CXNM
) (Line 0159). - If no match (
30
indicator off), skips to next record (Lines 0160–0161). - Chains to
ARCUST
usingCSKEY
(company + customer) to retrieve customer details (Line 0166). - Checks if
ARTOTD
(total due) is non-zero, settingOPENYN
to'Y'
or blank (Lines 0167–0169). - Outputs record to screen (indicator
83
, Lines 0171–0172). - Increments
LIN
; ifLIN
reaches 21, sets indicator20
(more records exist) and jumps toMORE
(Lines 0174–0176).
- Skips records where
-
If no more records, reads previous
ARCUSX
record, updatesMORE
toMSG,1
("END OF ITEMS"), and outputs final screen (Lines 0181–0186). -
CK Subroutine (Lines 0189–0201):
- If
SCNT
(search name length) is zero, displays all customers (indicator30
, Line 0190). - Otherwise, compares each character of
CXNM
(customer name) withSNM
(search name) up toSCNT
characters (Lines 0194–0199). -
Sets indicator
30
if all characters match (Line 0196). -
ROLLFW Subroutine (Lines 0263–0265):
-
Sets indicator
02
to trigger forward scrolling (Line 0264). -
ROLLBW Subroutine (Lines 0267–0303):
- Sets lower limit on
ARCUSX
usingSVBEG
(saved key, Line 0268). - Reads previous
ARCUSX
records (Line 0274):- Skips deleted records (
CXDEL = 'D'
) or non-matching company records (Lines 0277–0278). - Calls
CK
to validate search name (Line 0279). - Chains to
ARCUST
, updatesOPENYN
, and outputs to screen (Lines 0283–0290). - Decrements
LIN
until it reaches 6 or no more records (Lines 0292–0294).
- Skips deleted records (
-
Updates
MORE
toMSG,1
("END OF ITEMS") and outputs final screen (Lines 0298–0300). -
Output Specifications (Lines 0305–0323):
- Outputs to
SCREEN
using subfile records (AR820S1
,AR820S2
,AR820S3
,AR820S4
): AR820S1
(indicator81
): Displays input fields (CONO
,HCUST
,HPROD
,HCNTR
,SNM
) and error messages (MSG40
).AR820S2
(indicator82
): Displays company, customer, product, and container fields.AR820S3
(indicator83
): Displays customer details (OPENYN
,CCUSXT
,ARNM24
,ARAD1
,ARAD2
).AR820S4
(indicator84
): DisplaysMORE
message ("MORE ITEMS EXIST" or "END OF ITEMS").
- Outputs to
-
Termination (Lines 0099–0109):
- Sets
LR
(last record) and jumps toEND
tag when processing completes or conditions are met (e.g., invalid input, KG key, or end of file).
- Sets
Business Rules¶
- Input Validation:
- Validates
CONO
(company number) againstARCONT
. If invalid, displays "INVALID COMPANY NUMBER ENTERED". - Validates
HCUST
(customer number) againstARCUST
. If invalid, displays "INVALID CUSTOMER NUMBER ENTERED". - Validates
HPROD
(product code) againstGSPROD
. If invalid, displays "INVALID PRODUCT CODE ENTERED". - Validates
HCNTR
(container code) againstGSCNTR1
. If invalid, displays "INVALID CONTAINER ENTERED". -
Stores valid inputs in the LDA for reuse.
-
Search Logic:
- Supports partial customer name search using
SNM
(up to 10 characters). - Matches
SNM
againstCXNM
(customer cross-reference name) inARCUSX
. - If
SCNT
is zero, displays all non-deleted customers for the company. -
Skips deleted records (
CXDEL = 'D'
) and records with non-matching company numbers. -
Display Logic:
- Displays up to 15 customer records per screen (
LIN
from 6 to 21). - Shows customer details: customer number (
CCUSXT
), name (ARNM24
), address (ARAD1
,ARAD2
), and open balance indicator (OPENYN
='Y'
ifARTOTD
> 0). -
Indicates if more records exist (
MORE
= "MORE ITEMS EXIST") or not ("END OF ITEMS"). -
Function Key Behavior:
- KA (F3): Resets input screen for rekeying.
- KG (F12): Ends the job, setting
EOJ
to'E'
. - Roll Up (F18): Scrolls forward to the next set of records.
-
Roll Down (F19): Scrolls backward to the previous set of records.
-
Data Modifications (Historical Changes):
- 04/15/08: Changed product code (
HPROD
,IPROD
) from numeric to alphanumeric (JB02). - 10/11/14: Changed container code (
HCNTR
,ICNTR
) from numeric to alphanumeric (JB03). - 04/13/16: Replaced container code lookup in
GSTABL
withGSCNTR1
(alphanumeric key, JK01). - 12/31/22: Replaced product code lookup in
GSTABL
withGSPROD
(JK02).
Tables/Files Used¶
The RPG program uses the following files (all defined with shared access, as per the OCL):
- SCREEN: Workstation file for interactive input/output (subfile for scrolling).
- ARCONT: Company control file (256 bytes, keyed by company number).
- ARCUSX: Customer cross-reference file (384 bytes, keyed by company and customer).
- ARCUST: Customer master file (384 bytes, keyed by customer number).
- GSPROD: Product master file (512 bytes, keyed by product code).
- GSCNTR1: Container master file (512 bytes, keyed by container code).
Note: GSTABL
is commented out (Lines JK02), replaced by GSPROD
and GSCNTR1
in later updates.
External Programs Called¶
- None: The RPG program
AR820
does not explicitly call any external RPG programs. It is called by the OCL program (AR820.ocl36.txt
) and relies on internal subroutines (S1
,S2
,SETUP2
,CK
,ROLLFW
,ROLLBW
,ROLLKY
) for its logic. The OCL program callsAR822R
, butAR820
itself does not.
Summary¶
The AR820.rpg36.txt
program is an interactive customer search tool for pricing inquiries, processing user inputs (company, customer, product, container, and partial name) and displaying matching customer records from ARCUSX
and ARCUST
. It validates inputs against ARCONT
, GSPROD
, and GSCNTR1
, supports scrolling, and handles errors with appropriate messages. The program uses subroutines to modularize logic and relies on the LDA for data persistence. No external programs are called directly, and the listed files support the customer and product data required for the inquiry.