AR901P RPGLE
The provided document, AR901P.rpgle.txt, is an RPGLE (RPG IV) program for IBM System/36 or AS/400 (IBM i) that generates a "Customer Master Listing." It is called from the previously analyzed OCL program (AR901P.ocl36.txt). Below, I’ll explain the process steps, business rules, tables (files) used, and external programs called.
Process Steps of the RPGLE Program¶
The RPGLE program AR901P is designed to prompt for user input, validate parameters, and prepare data for generating a customer master listing. It interacts with a workstation display file (ar901pd) and processes data from customer master files (arcont and gscont). Here’s a detailed breakdown of the process steps:
- Program Initialization:
- Header Specifications:
H DFTACTGRP(*NO): Runs in a named activation group, ensuring modern RPG IV behavior.H FIXNBR(*ZONED:*INPUTPACKED): Ensures numeric fields are handled as zoned or packed decimal during input.H DFTNAME(AR901P): Sets the default program name toAR901P.
- File Declarations:
far901pd cf e workstn Handler('PROFOUNDUI(HANDLER)'): Defines a workstation file for interactive display, using a Profound UI handler for modern UI support.farcont if f 256 2aidisk keyloc(2): Defines the customer master fileARCONTas input, with a record length of 256 bytes, indexed (keyed) on field position 2 (acco, company number).fgscont if f 512 2aidisk keyloc(2): Defines another fileGSCONT, likely a global or system control file, also keyed on position 2 (gxcono, company number).
-
Data Structures and Variables:
dco: Array of 35-character fields to store company data (up to 3 companies).msg: Array of 25-character messages for user feedback (e.g., "ENTER ALL OR CO", "INVALID COMPANY #").uds: User data structure defining input fields likekyalco(all/company selection),kyco1-kyco3(company numbers),kyalcs(all/select customer selection),kycs01-kycs10(customer numbers),addlst(address list flag),dollst(dollar list flag),kyjobq(job queue flag), andkycopy(number of copies).
-
Workstation File Processing:
- Initial Screen Check:
- If
qsctl(control field) is blank, set indicator*in01to '1' andqsctlto 'R' to display the input screen (ar901pfm). - Otherwise, read the workstation file (
ar901pfm). If the last record is read (lr), the program terminates (return).
- If
-
Cancel Key Check:
- If
*inkg(cancel key, e.g., F3) is pressed, set*inu1and*inlrto*on, clear*in01, and jump to theendtag to exit the program.
- If
-
Main Processing Logic:
- Conditional Subroutine Calls:
- If
*in10is*on(indicating prior initialization), call theeditsubroutine if*in11is*off. - If
*in10is*off(first run), call theonetimsubroutine if*in11is*off.
- If
-
Screen Output:
- If
*in11is*off, write to the workstation file (ar901pfm) to display the input screen. - If
*in11is*on, set*inlrto*onto end the program.
- If
-
Edit Subroutine (
edit): - Validates user input parameters for generating the customer master listing.
-
Steps:
- Clear error indicators (
*in31to*in38) and message output (msgout). - Validate
kyalco(All/Company Selection): - If
kyalcois neither 'ALL' nor 'CO ', set*in31and display message "ENTER ALL OR CO". - Validate Company Numbers (
kyco1,kyco2,kyco3): - If
kyalcois 'CO ' and all company numbers are zero, set*in31and display "ENTER COMPANY #". - For each non-zero
kyco1,kyco2,kyco3:- Position the file pointer (
setll) onarcontusing the company number. - Read the record. If no record exists (
*in20is*on) or the record is deleted (acdel = 'D') or the company number doesn’t match, set*in32,*in33, or*in34and display "INVALID COMPANY #".
- Position the file pointer (
- Validate
kyalcs(All/Select Customer Selection): - If
kyalcsis neither 'ALL' nor 'SEL', set*in35and display "ENTER ALL OR SEL". - If
kyalcsis 'SEL' and all customer numbers (kycs01tokycs10) are zero, set*in39and display "ENTER CUSTOMER #". - Validate
addlst(Address List Flag): - If
addlstis not 'Y', 'N', or blank, set*in36and display "ENTER Y, N OR BLANK". - Validate
dollst(Dollar List Flag): - If
dollstis not 'Y', 'N', or blank, set*in37and display "ENTER Y, N OR BLANK". - Validate
kyjobq(Job Queue Flag): - If
kyjobqis not 'Y', 'N', or blank, set*in38and display "ENTER Y, N OR BLANK". - Set Default for
kycopy: - If
kycopy(number of copies) is zero, set it to 1. - Set Default for
addlstanddollst: - If both
addlstanddollstare not 'Y', setaddlstto 'Y'. - End of Validation:
- Set
*in11to*onto indicate validation is complete and return to the main loop.
- Clear error indicators (
-
One-Time Subroutine (
onetim): - Performs initial setup for the program.
-
Steps:
- Clear the
dcoarray and initialize variables (x = 1,arlim = 00). - Position the file pointer (
setll) onarcontusingarlim(likely to read from the start). - Read
arcontrecords in a loop (agnco): - Skip deleted records (
acdel = 'D'). - Store company number (
acco) and name (acname) in thedcoarray. - Increment
xuntil 3 records are processed or end of file (*in20is*on). - Move
dco(1),dco(2), anddco(3)to output fieldsdco1,dco2, anddco3for display. - Check
gscontFile: - Chain (lookup) to
gscontusing key '00'. - If found (
*in99is*off) andgxconois non-zero, setkyalcoto 'CO ' andkyco1togxcono. - Otherwise, set
kyalcoto 'ALL'. - Set Defaults:
- Set
kyalcsto 'ALL',addlstto 'Y',dollstto blank,kyjobqto 'N', andkycopyto 1. - Set
*in10to*onto indicate initialization is complete and clear*in20.
- Clear the
-
Output Specifications:
- Write to
ar901pfm(workstation file) if*in11is*off, outputting fields likekyalco,kyco1-kyco3,dco,kyalcs,kycs01-kycs10,addlst,dollst,kyjobq,kycopy, andmsgout.
Business Rules¶
The program enforces the following business rules for generating the customer master listing:
- Company Selection (
kyalco): - Must be 'ALL' (all companies) or 'CO ' (specific companies).
-
If 'CO ', at least one valid company number (
kyco1,kyco2, orkyco3) must be provided and must exist inarcontwithout being deleted (acdel ≠ 'D'). -
Customer Selection (
kyalcs): - Must be 'ALL' (all customers) or 'SEL' (selected customers).
-
If 'SEL', at least one customer number (
kycs01tokycs10) must be non-zero. -
Address and Dollar List Flags (
addlst,dollst): - Must be 'Y' (yes), 'N' (no), or blank.
-
If both are not 'Y',
addlstdefaults to 'Y' to ensure at least one report type is generated. -
Job Queue Flag (
kyjobq): -
Must be 'Y' (queue the job), 'N' (run interactively), or blank.
-
Number of Copies (
kycopy): -
Defaults to 1 if zero is entered.
-
Data Validation:
- Company numbers must exist in
arcontand not be marked as deleted. -
Invalid inputs result in error messages displayed to the user, prompting correction.
-
Initialization:
- The
onetimsubroutine populates default values and retrieves up to three company records fromarcontfor display. - The
gscontfile provides a default company number if available; otherwise, 'ALL' is used.
Tables (Files) Used¶
- AR901PD:
- Type: Workstation file (display file).
- Purpose: Handles interactive user input/output via the
ar901pfmformat. -
Handler: Uses Profound UI (
PROFOUNDUI(HANDLER)) for modern UI rendering. -
ARCONT:
- Type: Input file (disk, indexed).
- Record Length: 256 bytes.
- Key:
acco(company number, position 2). - Fields:
acdel(position 1, 1 byte): Deletion flag ('D' for deleted).acco(position 2-3, 2 bytes, numeric): Company number.acname(position 4-33, 30 bytes): Company name.
-
Purpose: Stores customer master data (company details).
-
GSCONT:
- Type: Input file (disk, indexed).
- Record Length: 512 bytes.
- Key: Position 2 (likely
gxcono, company number). - Fields:
gxdel(position 1, 1 byte): Deletion flag.gxcono(position 77-78, 2 bytes, numeric): Company number.
- Purpose: Likely a system control file storing default or global company settings.
External Programs Called¶
No external RPG programs are explicitly called (e.g., via CALL operation) within AR901P.rpgle. The program interacts with the OCL program (AR901P.ocl36.txt) that loads and runs it, and it uses the Profound UI handler (PROFOUNDUI(HANDLER)) for workstation file processing, but this is a system-level interface, not a program call.
Additional Notes¶
- Conversion Notes:
- The program was converted on 04/08/23 using TARGET/400, with 161 lines added (
T4A), 5 modified (T4M), and original lines (T4O) retained from an older RPG source. -
Conversion likely modernized the program from RPG II/III to RPGLE, adding features like
EVALand modern file handling. -
Indicators:
- Uses indicators (
*in01,*in10,*in11,*in20,*in31to*in39, etc.) for flow control and error handling, typical in legacy RPG. -
Modernized with
EVALfor setting indicators (e.g.,eval *in31 = *oninstead ofSETON 31). -
OCL Integration:
- The OCL program (
AR901P.ocl36.txt) sets up the environment, loadsAR901P, and passes parameters via memory locations (e.g.,kyjobqat position 120). -
The RPGLE program uses these parameters (e.g.,
kyjobq,kycopy) to control job execution (interactive or queued). -
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 details (e.g., specific field mappings, sample output format, or integration with other programs), please provide additional context or files.