AR500P RPGLE
The provided document is an RPGLE (Report Program Generator Language Extended) program, AR500P.rpgle.txt
, which is called by the OCL program AR500P.ocl36.txt
to generate an Accounts Receivable (A/R) Aged Trial Balance report. This program handles user input, validates parameters, and prepares data for the report. Below, I’ll explain the process steps, business rules, tables used, and external programs called.
Process Steps of the RPGLE Program¶
The AR500P
RPGLE program is an interactive program that prompts users for input via a workstation display file, validates the input, and sets up parameters for generating the A/R Aged Trial Balance report. Here’s a detailed breakdown of the process steps:
- Program Initialization:
- Header Specifications:
H DFTACTGRP(*NO)
: Runs in a named activation group, allowing better resource management.H FIXNBR(*ZONED:*INPUTPACKED)
: Ensures zoned and packed numeric fields are handled correctly during input.H DFTNAME(AR500P)
: Sets the default program name.
-
Data Structures:
msg
: A 40-character array with 19 predefined error messages (loaded viaCTDATA
).dco
: A 35-character array to store company names (up to 3 companies).uds
: A data structure defining user input fields (e.g.,kydate
,kyalco
,kyco1
, etc.) for report parameters like date, company selection, and report options.y2kcen
andy2kcmp
: Variables for Y2K date handling (century and comparison year).
-
File Declarations:
- AR500PD (Workstation File):
- Defined as
CF E WORKSTN
with a handler (PROFOUNDUI(HANDLER)
), indicating a modernized display file for user interaction, likely using a web-based interface.
- Defined as
- ARCONT (Accounts Receivable Control File):
- Defined as
UF F 256 2AIDISK KEYLOC(2)
: A 256-byte file with a 2-byte key (company numberacco
), used for update (UF
) and accessed by key.
- Defined as
-
GSCONT (General System Control File):
- Defined as
IF F 512 2AIDISK KEYLOC(2)
: A 512-byte input file with a 2-byte key (company numbergxcono
), likely used for system-wide settings.
- Defined as
-
Main Processing Logic:
- Initial Workstation File Read:
- Checks
qsctl
(control flag). If blank, sets indicators*IN09
(initial screen) and*IN01
(display screen), and setsqsctl
to'R'
. - Otherwise, reads the display file
ar500pfm
and returns if the last record indicator (*INLR
) is on.
- Checks
- Indicator and Message Initialization:
- Clears
msg40
(error message field) and resets indicators50-62
,81
, and90
to*OFF
.
- Clears
- Cancel Check:
- If
*INKG
(cancel key) is on, setskycanc
to'CANCEL'
, turns off*IN01
and*IN09
, sets*INLR
to*ON
, and exits.
- If
- One-Time Setup (Subroutine
onetim
):- Executed if
*IN09
is on (initial run). - Captures current time and date, stores in
kydate
. - Reads
ARCONT
to populatedco
array with up to three company numbers (acco
) and names (acname
), skipping deleted records (acdel = 'D'
). - Initializes default parameters:
kyds = 'D'
(detail report).kyalco = 'ALL'
or'CO '
(based onGSCONT
company numbergxcono
).kyalcs = 'ALL'
(all customers).kyalsl = 'ALL'
(all salesmen).kyjobq = 'N'
(no job queue).kycopy = 01
(one copy).kyouts = 'O'
(outstanding invoices).kynod = 'N'
(no NOD report).kyslcy = 'N'
(no salesman copies).kyrept = 'C'
(customer sequence).kyclyn = 'N'
(no credit limit).- Releases any locked
ARCONT
records using a blank key (nulkey
).
- Executed if
- Screen Processing (Subroutine
screen1
):- Executed if
*IN01
is on and*IN15
is off. - Validates user input parameters:
- Date Validation: Calls
@dtedt
to validatekydate
(MMDDYY format). - Company Selection:
- Ensures
kyalco
is'ALL'
or'CO '
. - If
'CO '
, validateskyco1
,kyco2
,kyco3
againstARCONT
(non-zero, non-deleted records). - If
'ALL'
, ensures no company numbers are entered.
- Ensures
- Customer Selection:
- Ensures
kyalcs
is'ALL'
or'SEL'
. - If
'SEL'
, requires non-zerokycs01
,kycs02
, orkycs03
.
- Ensures
- Outstanding Invoices:
- Ensures
kyouts
is'O'
or blank.
- Ensures
- Report Sequence:
- Ensures
kyrept
is'C'
,'N'
, or'S'
. - If
kyslcy = 'Y'
, requireskyrept = 'S'
.
- Ensures
- Salesmen Selection:
- Ensures
kyalsl
is'ALL'
or'SEL'
. - If
'SEL'
, requireskyrept = 'S'
and validkyfmsl
/kytosl
(from/to salesman, wherekytosl > kyfmsl
).
- Ensures
- Job Queue:
- Ensures
kyjobq
is'Y'
or'N'
.
- Ensures
- Credit Limit:
- Ensures
kyclyn
is'Y'
or'N'
.
- Ensures
- NOD Report:
- Ensures
kynod
is'Y'
or'N'
. - If
kynod = 'Y'
, requireskyds = 'D'
.
- Ensures
- Salesman Copies:
- Ensures
kyslcy
is'Y'
or'N'
.
- Ensures
- Copy Count:
- Ensures
kycopy
is non-zero (defaults to 1 if zero).
- Ensures
- Displays error messages (
msg40
) from themsg
array if validation fails, setting*IN81
and appropriate error indicators (50-62
,90
). - Updates
ARCONT
withkydate
for non-deleted records if validations pass. - Releases locked records using
nulkey
.
- Executed if
-
Date Validation (Subroutine
@dtedt
):- Validates
kydate
(MMDDYY format): - Breaks down into month (
$month
), day ($day
), and year ($yr
). - Checks month (1-12).
- Validates day based on month:
- February: 29 days for leap years, 28 otherwise.
- Months 4, 6, 9, 11: 30 days.
- Others: 31 days.
- Handles leap year calculations using
y2kcen
andy2kcmp
for century and year checks. - Sets
*IN79
if the date is invalid.
- Validates
-
Output and Termination:
- Writes to the display file (
ar500pfm
) if*IN81
is on, displaying errors or updated parameters. - Sets
*INLR
to*ON
to end the program if no further processing is needed. - Updates
ARCONT
with the ageing date (kydate
) for all records.
Business Rules¶
The program enforces the following business rules for generating the A/R Aged Trial Balance report:
1. Date Validation:
- The ageing date (kydate
) must be a valid date in MMDDYY format, with proper month, day, and leap year checks.
2. Company Selection:
- Must be 'ALL'
(all companies) or 'CO '
(specific companies).
- If 'CO '
, at least one valid company number (kyco1
, kyco2
, or kyco3
) must exist in ARCONT
and not be deleted (acdel ≠ 'D'
).
- If 'ALL'
, no company numbers should be specified.
3. Customer Selection:
- Must be 'ALL'
(all customers) or 'SEL'
(selected customers).
- If 'SEL'
, at least one customer number (kycs01
, kycs02
, or kycs03
) must be non-zero.
4. Outstanding Invoices:
- Must be 'O'
(outstanding invoices only) or blank.
5. Report Sequence:
- Must be 'C'
(customer sequence), 'N'
(name sequence), or 'S'
(salesman sequence).
- If salesman copies (kyslcy = 'Y'
), report sequence must be 'S'
.
6. Salesmen Selection:
- Must be 'ALL'
(all salesmen) or 'SEL'
(selected salesmen).
- If 'SEL'
, report sequence must be 'S'
, and valid from/to salesman numbers (kyfmsl
, kytosl
) must be provided, with kytosl > kyfmsl
.
7. Job Queue:
- Must be 'Y'
(run in batch) or 'N'
(run interactively).
8. Credit Limit:
- Must be 'Y'
(print credit limit) or 'N'
(don’t print).
9. NOD Report:
- Must be 'Y'
(include NOD report) or 'N'
(exclude).
- If 'Y'
, report type must be detail (kyds = 'D'
).
10. Salesman Copies:
- Must be 'Y'
(print salesman copies) or 'N'
(don’t print).
11. Copy Count:
- Must be non-zero; defaults to 1 if zero.
12. Report Type:
- Must be 'D'
(detail) or 'S'
(summary); defaults to 'D'
if blank.
Tables (Files) Used¶
- AR500PD:
- Type: Workstation file (
CF E WORKSTN
). - Purpose: Display file for user interaction, likely a modernized interface using Profound UI.
- Fields: Outputs fields like
kydate
,kyds
,kyalco
,kyco1-3
,dco
,kyalcs
,kycs01-03
,kyouts
,kyrept
,kyjobq
,kycopy
,msg40
,kyclyn
,kyalsl
,kyfmsl
,kytosl
,kynod
,kyslcy
,kycucl
. - ARCONT:
- Type: Disk file (
UF F 256 2AIDISK KEYLOC(2)
). - Purpose: Accounts Receivable control file, storing company and customer data.
- Key:
acco
(company number, 2 bytes). - Fields:
acdel
(1 byte): Deletion flag ('D'
for deleted).acco
(2 bytes): Company number.acname
(30 bytes): Company name.acdate
(6 bytes): Ageing date.
- GSCONT:
- Type: Disk file (
IF F 512 2AIDISK KEYLOC(2)
). - Purpose: General system control file, likely for system-wide settings like default company number.
- Key:
gxcono
(2 bytes). - Fields:
gxdel
(1 byte): Deletion flag.gxcono
(2 bytes): Company number.
External Programs Called¶
The RPGLE program does not explicitly call external programs (e.g., via CALL
operation). However, it interacts with:
- Profound UI Handler (PROFOUNDUI(HANDLER)
): Used by the AR500PD
workstation file for rendering the user interface, indicating a modernized front-end.
- The OCL program (AR500P.ocl36.txt
) that calls this RPGLE program, passing parameters like ?9?
and ?11?
.
Additional Notes¶
- Y2K Compliance:
- The program includes Y2K date handling (
y2kcen
,y2kcmp
) to ensure correct century calculations for leap years. - Error Handling:
- Uses a predefined
msg
array for user-friendly error messages displayed viamsg40
. - Indicators (
50-62
,79
,81
,90
) control error display and program flow. - Record Locking:
- The program releases locked
ARCONT
records using a blank key (nulkey
) to prevent deadlocks. - Conversion Notes:
- The program was converted using TARGET/400 on 04/11/23, with 221 lines added, 5 modified, and 441 processed, indicating modernization from older RPG/36 or RPG III code.
- Integration with OCL:
- The OCL program (
AR500P.ocl36.txt
) loads and runsAR500P
, passing parameters (?9?
,?11?
) that likely correspond to fields likekyalco
,kyco1-3
, orkyjobq
.
This program sets up and validates parameters for the A/R Aged Trial Balance report, ensuring data integrity before report generation. If you need further analysis (e.g., specific field mappings, report output format, or additional files), please provide more details or related files!