AR300P RPGLE
The provided document is an RPGLE (RPG IV) program, AR300P.rpgle.txt
, which is called from the OCL program AR300P.ocl36.txt
. This RPG program is designed to prompt users for input parameters to generate monthly statements for accounts receivable (AR). It validates user input, checks data against files, and displays error messages if validation fails. Below, I’ll explain the process steps, business rules, tables/files used, and any external programs called.
Process Steps of the AR300P RPGLE Program¶
- Program Initialization:
- Header Specifications:
H DFTACTGRP(*NO)
: Runs in a named activation group (not the default), allowing better control over resources.H DFTNAME(AR300P)
: Specifies the default program name asAR300P
.H FIXNBR(*ZONED:*INPUTPACKED)
: Handles numeric fields with zoned or packed decimal formats during conversion.
- File Declarations:
AR300PD CF E WORKSTN
: Defines a workstation file (AR300PD
) for interactive screen input/output, using Profound UI (Handler('PROFOUNDUI(HANDLER)')
) for the user interface.ARCONT IF F 256 2AIDISK KEYLOC(2)
: Defines an input file (ARCONT
) with a record length of 256 bytes, keyed on position 2 (company number,acco
), used for accounts receivable control data.GSCONT IF F 512 2AIDISK KEYLOC(2)
: Defines another input file (GSCONT
) with a record length of 512 bytes, also keyed on position 2 (company number,gxcono
), likely for global system control data.
- Data Structures and Variables:
dco
: A 35-character array (10 elements) to store company numbers and names.com
: A 40-character array (7 elements) initialized with compile-time data (CTDATA
) for error messages (e.g., "INVALID STATEMENT DATE").uds
: A data structure for job parameters, including:kyalco
(ALL/CO selection),kyco1
,kyco2
,kyco3
(company numbers),kydate
(statement date),kycmtd
(month-to-date flag),kycytd
(year-to-date flag),kycopy
(number of copies),y2kcen
(Y2K century),y2kcmp
(Y2K comparison year).
-
Indicators: Used extensively for controlling program flow and screen output (e.g.,
*IN01
,*IN09
,*IN81
,*IN90
). -
Main Processing Logic:
- Workstation File Read:
- Checks
qsctl
(a control field, likely from the screen or job). - If
qsctl
is blank, sets*IN09
(initial screen display) andqsctl
to 'R', then proceeds. - Otherwise, sets
*IN01
(process input), reads the screen file (AR300PD
), and returns if the last record indicator (LR
) is set.
- Checks
- Indicator Setup:
- Resets indicators (
*IN20
,*IN81
,*IN90
,*IN30
–*IN37
) to ensure a clean state. - Clears the
msg
field (40 characters) for error messages.
- Resets indicators (
- F3 Key Handling:
- If
*INKG
(F3 key) is pressed, sets*INU1
and*INLR
(program termination), clears*IN01
and*IN09
, and jumps to theend
tag to exit.
- If
- Initial Screen Display:
- If
*IN09
is on, sets*IN81
(write screen) and executes theonetim
subroutine for one-time initialization.
- If
- Input Processing:
- If
*IN01
is on, executes theedit
subroutine to validate user input.
- If
-
Screen Output:
- If
*IN81
is off, sets*INLR
to terminate the program. - Writes to the
AR300PD
screen file if*IN81
is on, displaying the input prompt or error messages.
- If
-
Edit Subroutine (
edit
): - Security Code Validation:
- Chains to
ARCONT
using key01
(company number). - Compares
kysec
(input security code) withacsecr
(security code inARCONT
). - If mismatched, sets
*IN30
,*IN81
,*IN90
, and displays error messagecom(7)
("INVALID SECURITY CODE").
- Chains to
- Date Validation:
- Moves
kydate
tommddyy
and calls@dtedt
to validate the date. - If
*IN79
(date error) is set, displayscom(1)
("INVALID STATEMENT DATE") and sets*IN31
,*IN81
,*IN90
.
- Moves
- ALL/CO Selection Validation:
- Checks if
kyalco
is 'ALL' or 'CO '. - If
kyalco
is 'ALL' or 'CO ', validates further: - If
kyalco
is neither 'ALL' nor 'CO', displayscom(2)
("ENTER ALL OR CO") and sets*IN32
,*IN81
,*IN90
.
- Checks if
- Company Number Validation:
- If
kyalco
is 'CO', checkskyco1
,kyco2
,kyco3
: - If all are zero, displays
com(3)
("IF CO, THEN ENTER VALID COMPANIES") and sets*IN32
,*IN81
,*IN90
. - If
kyalco
is 'ALL' and any company numbers are non-zero, displayscom(4)
("IF ALL, THEN DO NOT ENTER COMPANIES") and sets*IN32
,*IN81
,*IN90
. - For each non-zero
kyco1
,kyco2
,kyco3
: - Positions the
ARCONT
file usingSETLL
. - Reads the record and checks if it’s deleted (
acdel = 'D'
) or if the company number (acco
) matches. - If no valid record is found, displays
com(5)
("INVALID COMPANY NUMBER") and sets*IN33
,*IN34
, or*IN35
(forkyco1
,kyco2
,kyco3
) plus*IN81
,*IN90
.
- If
- Month-to-Date/Year-to-Date Flags:
- Validates
kycmtd
andkycytd
(must be 'Y', 'N', or blank). - If invalid, displays
com(6)
("INVALID PARAMETER") and sets*IN81
,*IN90
.
- Validates
- Number of Copies:
- If
kycopy
is zero, sets it to 1.
- If
-
Final Setup:
- Sets
*IN11
to indicate successful validation.
- Sets
-
One-Time Subroutine (
onetim
): - Initialize Company Array:
- Clears the
dco
array and sets indexx
to 1. - Positions
ARCONT
at the beginning (aclim = 00
). - Reads
ARCONT
records, skipping deleted records (acdel = 'D'
). - Stores company number (
acco
) and name (acname
) indco(x)
until 10 companies are loaded or end of file is reached. - Moves
dco
elements to individual fields (DCO1
–DCO10
) for screen display.
- Clears the
-
Default Parameters:
- Chains to
GSCONT
with key00
. - If a record is found and
gxcono
is non-zero, setskyalco
to 'CO ' andkyco1
togxcono
. - Otherwise, sets
kyalco
to 'ALL'. - Sets defaults:
kycmtd = 'Y'
,kycytd = 'N'
,kycopy = 01
,kyco1
,kyco2
,kyco3 = 0
. - Sets
*IN10
to indicate completion.
- Chains to
-
Date Edit Subroutine (
@dtedt
): -
Validates the input date (
mmddyy
):- Breaks down into month (
$month
), day ($day
), and year ($yr
). - Checks if month is valid (1–12).
- For February, validates days (28 or 29 for leap years) using century (
y2kcen
) and year calculations. - For other months, checks days (30 or 31 based on month).
- Sets
*IN79
if any validation fails.
- Breaks down into month (
-
Output Specifications:
- Writes to
AR300PD
if*IN81
is on, outputting fields likekysec
,kydate
,kyalco
,kyco1
,kyco2
,kyco3
,dco
,kycmtd
,kycytd
,kycopy
, andmsg
.
Business Rules¶
- Security Code:
- The input security code (
kysec
) must match the security code (acsecr
) in theARCONT
file for the company. - Statement Date:
- The date (
kydate
) must be valid (checked via@dtedt
for month, day, and leap year). - ALL/CO Selection:
kyalco
must be 'ALL' (process all companies) or 'CO ' (specific companies).- If 'CO ', at least one of
kyco1
,kyco2
,kyco3
must be non-zero. - If 'ALL',
kyco1
,kyco2
,kyco3
must be zero. - Company Numbers:
- Each non-zero
kyco1
,kyco2
,kyco3
must exist inARCONT
, not be deleted (acdel ≠ 'D'
), and match the company number (acco
). - Month-to-Date/Year-to-Date:
kycmtd
andkycytd
must be 'Y', 'N', or blank.- Number of Copies:
kycopy
defaults to 1 if zero.- Error Handling:
- Displays specific error messages (
com(1)
–com(7)
) for validation failures. - Returns to the screen for correction if errors occur.
- Initialization:
- Defaults are set based on
GSCONT
(company number or 'ALL') and hardcoded values (kycmtd
,kycytd
,kycopy
). - Up to 10 companies are loaded for display.
Tables/Files Used¶
- AR300PD:
- Workstation file (display file) for user interaction via Profound UI.
- Contains fields like
kysec
,kydate
,kyalco
,kyco1
,kyco2
,kyco3
,dco
,kycmtd
,kycytd
,kycopy
,msg
. - ARCONT:
- Accounts receivable control file (256 bytes, keyed on company number at position 2).
- Fields:
acdel
(1): Delete flag ('D' for deleted).acco
(2–3): Company number.acname
(4–33): Company name.acsecr
(84–91): Security code for statements.
- GSCONT:
- Global system control file (512 bytes, keyed on company number at position 2).
- Fields:
gxdel
(1): Delete flag.gxcono
(77–78): Company number.
External Programs Called¶
- None:
- The RPG program does not explicitly call external programs (e.g., via
CALL
orQCMDEXC
). - It interacts with the Profound UI handler (
PROFOUNDUI(HANDLER)
) for screen processing, but this is a runtime environment, not a program call. - The OCL program (
AR300P.ocl36.txt
) callsAR300P
, but withinAR300P.rpgle
, no further programs are invoked.
Additional Notes¶
- Conversion Context: The program was converted on 04/07/23 using TARGET/400, with 161 lines added, 5 modified, and 297 processed. Prefixes (
T4A
,T4M
,T4O
) indicate added, modified, or original lines. - Y2K Handling: The
@dtedt
subroutine and fields likey2kcen
,y2kcmp
address Year 2000 date issues, ensuring correct leap year calculations. - Profound UI: The use of
Handler('PROFOUNDUI(HANDLER)')
indicates a modernized user interface, likely a web-based front-end for the AS/400. - Error Messages: The
com
array provides clear, user-friendly error messages, enhancing usability. - Integration with OCL: The OCL program loads
AR300P
and provides theARCONT
file with a dynamic label (?9?ARCONT
). The RPG program uses this file for validation.
If you need further details, such as a deeper dive into specific validations or integration with other system components, let me know!