AR489 RPGLE
The provided RPGLE program (AR489.rpgle.txt
) is an RPG IV program, converted from an earlier RPG version (likely RPG/400 or RPG III) for IBM midrange systems (e.g., AS/400 or IBM i). It is invoked by the OCL program (AR489.ocl36.txt
) and handles the Credit Limit Grouping Maintenance functionality. 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 manages a workstation (interactive screen) application for maintaining credit limit groupings, allowing users to add, update, or delete customer records associated with credit limit groups. Here’s a step-by-step breakdown of the process:
- Program Initialization (
*inzsr
Subroutine): - Code:
1 2 3 4
c *inzsr begsr c z-add 0 cono c z-add 0 cust c endsr
-
Description:
- The initialization subroutine (
*inzsr
) sets the company number (cono
) and customer number (cust
) to zero. - This ensures a clean state for variables used in the program.
- The initialization subroutine (
-
Main Routine Execution:
- Code:
1 2 3 4 5 6 7 8 9
c if qsctl = ' ' c move '1' *in09 c move 'R' qsctl 1 c else c move '0' *in09 c move '0' *in01 c move '0' *in02 c lr return c end
-
Description:
- Checks the control variable
qsctl
(likely a system or session control flag). - If
qsctl
is blank, sets indicator*in09
to'1'
(on) andqsctl
to'R'
, indicating the program is ready to process. - If
qsctl
is not blank, clears indicators*in09
,*in01
,*in02
, and sets*inlr
(last record) to terminate the program. - Indicators
*in01
and*in02
control screen formats (AR489S1
andAR489S2
).
- Checks the control variable
-
Read Workstation File:
- Code:
1 2 3 4
c 81 read ar489s1 lr c 82 read ar489s2 lr c 81 move *on *in01 c 82 move *on *in02
-
Description:
- Reads the workstation file formats
AR489S1
(first screen) andAR489S2
(second screen) based on indicators*in81
and*in82
. - Sets
*in01
and*in02
to control which screen format is active for display or input. - Clears message fields (
msg1
,msg2
) and indicators (*in81
,*in82
,*in90
) to prepare for user interaction.
- Reads the workstation file formats
-
Handle Function Keys:
- Code:
1 2 3 4 5 6 7 8 9 10
c if (*inka = *on) c eval *in01 = *off c eval *in02 = *off c eval *in81 = *on c endif c if (*inkg = *on) c eval *inlr = *on c eval *in01 = *off c eval *in02 = *off c endif
-
Description:
- If function key F10 (
*inka
) is pressed, clears*in01
and*in02
(disables screen formats) and sets*in81
to display the first screen (AR489S1
). - If function key F3 or F12 (
*inkg
) is pressed, sets*inlr
to terminate the program and clears*in01
and*in02
.
- If function key F10 (
-
Validate Company Number:
- Code:
1 2 3 4 5 6
c 09 do c '00' chain gscont 99 c n99gxcono ifne *zeros c n99 z-add gxcono cono c endif c end
-
Description:
- When indicator
*in09
is on (initial program entry), the program reads theGSCONT
file using key'00'
to retrieve a company number (gxcono
). - If found (
*in99
off) andgxcono
is non-zero, it sets thecono
variable togxcono
. - This validates or sets the company number for subsequent processing.
- When indicator
-
Screen Processing:
- Code:
1 2 3 4 5 6 7 8
c n09 if (*in01 = *on) c exsr s1 c endif c if (*in02 = *on) c exsr s2 c endif c 81 write ar489s1 c 82 write ar489s2
-
Description:
- If
*inchelle01
is on, executes subroutines1
(processes first screen for company/customer validation). - If
*in02
is on, executes subroutines2
(processes second screen for group maintenance). - Writes the appropriate screen formats (
AR489S1
orAR489S2
) to the workstation based on indicators*in81
and*in82
.
- If
-
Subroutine
s1
(First Screen Processing): - Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
csr s1 begsr c cono chain arcont 99 c if (*in99 = *on) c movel msg(1) msg2 c eval *in81 = *on c eval *in90 = *on c goto ends1 c endif c if cust = *zero c movel msg(2) msg2 c eval *in81 = *on c eval *in90 = *on c goto ends1 c end c clgrky chain arclgr 99 c move cgdel del c movea arc ars c eval *in82 = *on csr ends1 endsr
-
Description:
- Validate Company: Uses
cono
to chain (read) theARCONT
file. If not found (*in99
on), sets error messagemsg(1)
("INVALID COMPANY NUMBER ENTERED") inmsg2
, sets*in81
and*in90
(error indicator), and exits the subroutine. - Validate Customer: Checks if
cust
is zero. If true, sets error messagemsg(2)
("INVALID CUSTOMER") inmsg2
, sets*in81
and*in90
, and exits. - Retrieve Group Data: Uses the key
clgrky
(concatenation ofcono
andcust
) to chain theARCLGR
file. If found, moves the delete code (cgdel
) todel
and the customer array (arc
) toars
. Sets*in82
to display the second screen. - This subroutine validates input and retrieves existing group data for editing.
- Validate Company: Uses
-
Subroutine
s2
(Second Screen Processing): - Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
csr s2 begsr c z-add 0 y 2 0 c dou y = 25 c add 1 y c clgrky chain arclgr 99 c if (*in99 = *on) c except addclg c else c except updclg c endif c end c eval *in81 = *on csr ends2 endsr
-
Description:
- Iterates through the
ars
array (25 elements) to process customer group assignments. - For each iteration, uses
clgrky
to chain theARCLGR
file: - If not found (
*in99
on), executes theaddclg
exception to add a new record toARCLGR
withdel = 'A'
,cono
,cust
, andars
values. - If found, executes the
updclg
exception to update the existingARCLGR
record withdel
andars
values. - Sets
*in81
to return to the first screen after processing.
- Iterates through the
-
Exception Outputs:
- Code:
1 2 3 4 5 6 7 8
oarclgr e updclg o del 1 o ars 159 oarclgr eadd addclg o 1 'A' o cono 3 o cust 9 o ars 159
- Description:
updclg
: Updates an existingARCLGR
record with the delete code (del
) and customer array (ars
).addclg
: Adds a newARCLGR
record withdel = 'A'
(active),cono
,cust
, andars
.
Business Rules¶
The program enforces the following business rules for credit limit grouping maintenance:
1. Company Number Validation:
- The company number (cono
) must exist in the ARCONT
file. If not, an "INVALID COMPANY NUMBER ENTERED" error is displayed, and the user is prompted to correct the input.
2. Customer Number Validation:
- The customer number (cust
) must be non-zero. If zero, an "INVALID CUSTOMER" error is displayed.
3. Credit Limit Group Management:
- A group is identified by a composite key (clgrky
, combining cono
and cust
).
- The program allows adding new group records (if not found in ARCLGR
) or updating existing ones.
- The ars
array stores up to 25 customer numbers associated with a group.
- The del
field indicates the record’s status (e.g., 'A'
for active, or other codes for deletion).
4. Interactive Processing:
- The first screen (AR489S1
) accepts cono
and cust
for validation and retrieves group data.
- The second screen (AR489S2
) displays group details (arname
, ars
, del
) for editing or adding customers.
- Function keys (F10, F3/F12) control navigation and program termination.
5. Error Handling:
- Errors (invalid company or customer) are displayed via msg1
and msg2
fields, with indicator *in90
enabling error highlighting.
6. Data Persistence:
- Changes to group assignments are saved to the ARCLGR
file via addclg
(add) or updclg
(update) operations.
Tables (Files) Used¶
The program uses the following files (equivalent to tables in modern database terminology):
1. ARCLGR:
- Description: Stores credit limit grouping data.
- Attributes: Update file (uf
), 240 bytes, keyed on position 2 (likely clgrky
, a composite of cgcono
and cgcust
).
- Fields:
- cgdel
(1 byte): Delete code (e.g., 'A' for active).
- cgcono
(2 bytes): Company number.
- cgcust
(6 bytes): Customer number.
- arc
(150 bytes): Array of customer numbers in the group.
2. ARCONT:
- Description: Accounts receivable control file, storing company information.
- Attributes: Input file (if
), 256 bytes, keyed on position 2.
- Fields:
- arname
(30 bytes): Company name.
3. GSCONT:
- Description: General system control file, likely for system-wide settings or defaults.
- Attributes: Input file (if
), 512 bytes, keyed on position 2.
- Fields:
- gxdel
(1 byte): Delete code.
- gxcono
(2 bytes): Company number.
4. AR489D (Workstation File):
- Description: Display file for the interactive screens (AR489S1
and AR489S2
), handled by PROFOUNDUI(HANDLER)
.
- Formats:
- AR489S1
: Accepts cono
, cust
, and displays messages (msg1
, msg2
).
- AR489S2
: Displays cono
, arname
, cust
, ars
(group customers), del
, and messages.
External Programs Called¶
The RPGLE program does not explicitly call any external programs via CALL
operations. All processing is handled within the program, using subroutines (s1
, s2
, *inzsr
) and file I/O operations. However, the program is invoked by the OCL program (AR489.ocl36.txt
), which calls GSGENIEC
, SCPROCP
, and GSY2K
before loading AR489
.
Summary¶
The AR489
RPGLE program manages credit limit groupings through an interactive workstation interface:
- Process Steps: Initializes variables, validates company and customer inputs, retrieves group data, and allows users to add or update group assignments via two screens.
- Business Rules: Enforces valid company and customer numbers, manages up to 25 customers per group, and handles add/update/delete operations with error messaging.
- Files Used: ARCLGR
(group data), ARCONT
(company data), GSCONT
(system control), and AR489D
(display file).
- External Programs: None called directly within the RPGLE code, but the OCL program invokes GSGENIEC
, SCPROCP
, GSY2K
, and AR489
.
If you need further details, such as specific field mappings, screen layouts, or additional context about the OCL integration, please let me know!