AR490P RPGLE
The provided RPGLE program, AR490P.rpgle.txt, is an RPG IV program converted from an earlier RPG version (likely RPG/400) using the TARGET/400 tool, as indicated by the conversion comments. This program handles the user interface and validation logic for a credit limit grouping list, interacting with a workstation file and database files. It is called by the OCL program AR490P.ocl36.txt previously analyzed. Below, I explain the process steps, business rules, tables/files used, and external programs called.
Process Steps of the RPG Program¶
The program is designed to prompt the user for input via a workstation display file, validate selections for company codes and job queue options, and prepare data for a credit limit grouping report. The steps are as follows:
- Program Initialization:
- Header Specifications:
H DFTACTGRP(*NO): Runs in a non-default activation group, allowing for modern RPG IV features.H FIXNBR(*ZONED:*INPUTPACKED): Ensures zoned and packed numeric fields are handled correctly during input.H DFTNAME(AR490P): Specifies the default program name asAR490P.
- Data Structures and Variables:
COM: A compile-time array with 5 error messages (40 characters each) for validation feedback.DCO: A data structure with 10 subfields (DC01toDC10, each 35 characters) to store company numbers and names.UDS: A data structure for passing parameters (e.g.,KYALCO,KYCO1,KYCO2,KYCO3,KYJOBQ,KYCOPY,KYCANC) to/from the OCL program.
-
File Declarations:
AR490PD: A workstation file (display file) for user interaction, using thePROFOUNDUI(HANDLER)for modern UI rendering.ARCONT: A disk file (256 bytes, indexed, key at position 2) containing company data.GSCONT: Another disk file (512 bytes, indexed, key at position 2) for company validation.
-
Workstation File Processing:
- Initial Check (
QSCTL):- If
QSCTL(control field) is blank: - Set
*IN09 = '1'and*IN01 = '0'to indicate initial screen display. - Set
QSCTL = 'R'to mark the screen as ready. - Else:
- Set
*IN09 = '0'and*IN01 = '1'. - Read the
AR490S1format fromAR490PD. - If the last record is read (
LRindicator), exit the program (RETURN).
- If
-
Clear Indicators and Message:
- Reset message field
MSGto blanks. - Turn off indicators
*IN51,*IN52,*IN53,*IN54,*IN81,*IN90to clear error states.
- Reset message field
-
Handle Cancel Key (
*INKG): -
If the cancel key is pressed (
*INKG = *ON):- Turn off
*IN01and*IN09. - Set
*INLR = *ONto end the program. - Set
KYCANC = 'CANCEL'to signal cancellation to the OCL program. - This allows the user to exit the program gracefully.
- Turn off
-
Initial Setup (
*IN09): -
If
*IN09 = *ON(initial screen display):- Set
*IN81 = *ONto indicate screen output. - Execute the
ONETIMsubroutine to populate company data.
- Set
-
Screen Processing (
*IN01): -
If
*IN01 = *ON(user input received):- Execute the
SCREEN1subroutine to validate user input.
- Execute the
-
Main Loop Control:
- If
*IN81 = *OFF, set*INLR = *ONto end the program. -
If
*IN81 = *ON, write theAR490S1format to the display file to show the screen (with errors or data). -
ONETIM Subroutine:
- Purpose: Populate the company selection dropdown (
DCOarray) and initialize parameters. -
Steps:
- Clear the
DCOarray. - Initialize counter
X = 1and credit limitACLIM = 00. - Set the lower limit for
ARCONTfile usingACLIM(SETLL). - Read
ARCONTrecords in a loop until end-of-file (*IN10 = *ON) or 10 companies are loaded: - Skip records marked as deleted (
ACDEL = 'D'). - Store company number (
ACCO) and name (ACNAME) inDCO(X). - Increment
X; stop ifX = 10. - Move
DCO(1)toDCO(10)into individual fields (DCO1toDCO10) for display. - Check
GSCONTfile for a company number (GXCONO): - If found and non-zero, set
KYALCO = 'CO 'andKYCO1 = GXCONO. - Else, set
KYALCO = 'ALL'. - Set
KYJOBQ = 'N'(default job queue selection). - Set
KYCOPY = 01(default number of copies).
- Clear the
-
SCREEN1 Subroutine:
- Purpose: Validate user input for company selection and job queue.
- Steps:
- Validate Company Selection:
- Check if
KYALCOis'ALL'or'CO '; if not, set error indicators*IN81,*IN90, display error messageCOM(1)("COMPANY SELECTION MUST BE 'CO' or 'ALL'"), and exit. - If
KYALCO = 'CO'and all company fields (KYCO1,KYCO2,KYCO3) are zero, set error indicators*IN81,*IN90,*IN51, displayCOM(2)("IF CO, THEN ENTER VALID COMPANIES"), and exit. - If
KYALCO = 'ALL'and any company field is non-zero, set error indicators*IN81,*IN90,*IN51, displayCOM(3)("IF ALL, THEN DO NOT ENTER COMPANIES"), and exit. - If
KYALCO = 'CO', validate each company number (KYCO1,KYCO2,KYCO3) usingCHAINtoARCONT:- If any company number is invalid (
*IN10 = *ON), set error indicators*IN81,*IN90, and*IN51,*IN52, or*IN53(depending on the field), displayCOM(4)("INVALID COMPANY NUMBER"), and exit.
- If any company number is invalid (
- Validate Job Queue Selection:
- Check if
KYJOBQis'Y'or'N'; if not, set error indicators*IN81,*IN90,*IN54, displayCOM(5)("JOB QUEUE ENTRY MUST BE 'Y' OR 'N'"), and exit. - Validate Copies:
- If
KYCOPY = 00, set it to01to ensure at least one copy. - Exit the subroutine (
ENDS1).
Business Rules¶
The program enforces the following business rules for generating a credit limit grouping list:
- Company Selection:
- The user must select either
'ALL'(all companies) or'CO'(specific companies) viaKYALCO. - If
'CO'is selected, at least one valid company number (KYCO1,KYCO2, orKYCO3) must be provided. - If
'ALL'is selected, no company numbers should be entered. - Company numbers must exist in the
ARCONTfile and not be marked as deleted (ACDEL ≠ 'D'). -
Invalid company selections trigger error messages and prevent further processing.
-
Job Queue Selection:
- The user must specify whether the report runs in a job queue (
KYJOBQ = 'Y') or interactively (KYJOBQ = 'N'). -
Invalid job queue entries trigger an error message.
-
Number of Copies:
-
The number of report copies (
KYCOPY) must be at least 1. If zero is entered, it is set to 1. -
Cancellation:
-
If the user presses the cancel key, the program sets
KYCANC = 'CANCEL'and exits, signaling the OCL program to terminate. -
Company Data Population:
- Up to 10 active companies (non-deleted) from
ARCONTare loaded into theDCOarray for display in a dropdown. - The program checks
GSCONTto determine if a specific company number should be preselected (KYALCO = 'CO ') or if all companies are selected (KYALCO = 'ALL').
Tables/Files Used¶
The program uses the following files:
1. AR490PD:
- A workstation file (display file) for user interaction.
- Contains the AR490S1 format for input/output.
- Uses PROFOUNDUI(HANDLER) for modern UI rendering.
2. ARCONT:
- A disk file (256 bytes, indexed, key at position 2).
- Contains company data with fields:
- ACDEL (1 byte): Delete flag ('D' for deleted).
- ACCO (2 bytes, numeric): Company number.
- ACNAME (30 bytes): Company name.
- Used to validate company numbers and populate the dropdown.
3. GSCONT:
- A disk file (512 bytes, indexed, key at position 2).
- Contains company data with fields:
- GXDEL (1 byte): Delete flag.
- GXCONO (2 bytes, numeric): Company number.
- Used to determine the default company selection.
External Programs Called¶
The RPG program does not explicitly call any external programs using CALL or similar operations. However:
- It interacts with the PROFOUNDUI(HANDLER) for the AR490PD display file, which is a UI handler, not a program.
- The OCL program (AR490P.ocl36.txt) that calls this RPG program references AR490, which may be invoked based on user input (KYJOBQ), but this is handled outside the RPG program.
Summary¶
- Process Steps: The program initializes, displays a screen to prompt for company selection (
ALLor specific companies), job queue option (YorN), and number of copies. It populates a company dropdown fromARCONT, validates user input, and sets parameters for the OCL program to proceed (or cancel). TheONETIMsubroutine loads company data, andSCREEN1validates input. - Business Rules: Enforces valid company selection (
ALLorCOwith valid company numbers), job queue selection (YorN), and ensures at least one copy. Invalid inputs trigger error messages, and cancellation is supported. - Tables/Files:
AR490PD(workstation),ARCONT(company data),GSCONT(company validation). - External Programs: None explicitly called within the RPG program.
If you need further details (e.g., the display file format AR490S1 or additional context about AR490), please provide relevant files or information.