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 (DC01
toDC10
, 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
AR490S1
format fromAR490PD
. - If the last record is read (
LR
indicator), exit the program (RETURN
).
- If
-
Clear Indicators and Message:
- Reset message field
MSG
to blanks. - Turn off indicators
*IN51
,*IN52
,*IN53
,*IN54
,*IN81
,*IN90
to clear error states.
- Reset message field
-
Handle Cancel Key (
*INKG
): -
If the cancel key is pressed (
*INKG = *ON
):- Turn off
*IN01
and*IN09
. - Set
*INLR = *ON
to 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 = *ON
to indicate screen output. - Execute the
ONETIM
subroutine to populate company data.
- Set
-
Screen Processing (
*IN01
): -
If
*IN01 = *ON
(user input received):- Execute the
SCREEN1
subroutine to validate user input.
- Execute the
-
Main Loop Control:
- If
*IN81 = *OFF
, set*INLR = *ON
to end the program. -
If
*IN81 = *ON
, write theAR490S1
format to the display file to show the screen (with errors or data). -
ONETIM Subroutine:
- Purpose: Populate the company selection dropdown (
DCO
array) and initialize parameters. -
Steps:
- Clear the
DCO
array. - Initialize counter
X = 1
and credit limitACLIM = 00
. - Set the lower limit for
ARCONT
file usingACLIM
(SETLL
). - Read
ARCONT
records 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 (DCO1
toDCO10
) for display. - Check
GSCONT
file 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
KYALCO
is'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
) usingCHAIN
toARCONT
:- 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
KYJOBQ
is'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 to01
to 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
ARCONT
file 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
ARCONT
are loaded into theDCO
array for display in a dropdown. - The program checks
GSCONT
to 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 (
ALL
or specific companies), job queue option (Y
orN
), and number of copies. It populates a company dropdown fromARCONT
, validates user input, and sets parameters for the OCL program to proceed (or cancel). TheONETIM
subroutine loads company data, andSCREEN1
validates input. - Business Rules: Enforces valid company selection (
ALL
orCO
with valid company numbers), job queue selection (Y
orN
), 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.