AR200P RPGLE
The provided document, AR200P.rpgle.txt
, is an RPGLE (RPG IV) program used in an IBM AS/400 or iSeries environment, called from the OCL script AR201P.ocl36.txt
. It handles the journal date prompt for accounts receivable (A/R) transaction posting, interacting with a workstation display file to collect and validate user input. Below, I’ll explain the process steps, business rules, tables used, and external programs called.
Process Steps of the RPG Program (AR200P)¶
The program AR200P
is designed to prompt the user for a journal date, validate it, and confirm the input before allowing A/R transaction posting to proceed. Here’s a step-by-step breakdown of the process:
- Program Initialization:
- The program defines a workstation display file
AR200PD
(renamed fromSCREEN
during conversion) as aCF
(combined file) with a handler for a graphical interface (PROFOUNDUI(HANDLER)
). - Data structures and variables are initialized, including
kyjrdt
(journal date),y2kcen
(century),y2kcmp
(comparison year), andmsg
(error message array). -
The program uses an information data structure (
@infds
) to capture screen status, such as function keys (@vkey
). -
Main Loop (Screen Processing):
- The program enters a
DO
loop (dow @sfnex <> 'EJ'
) that continues until the exit condition (EJ
) is met, indicating the user has completed or canceled the process. -
The loop processes user interactions with two screen formats:
AR200PS1
(for entering the journal date) andAR200PS2
(for confirming the date). -
Screen Selection Logic:
-
The program uses a
CASEQ
structure to determine which screen to process based on@sfid
(screen format identifier):@sfid = *blank
: Calls subroutine$sblk
(initial blank screen setup).@sfid = 'S1'
: Calls subroutine$s1
(processes journal date input screen).@sfid = 'S2'
: Calls subroutine$s2
(processes confirmation screen).
-
Initial Screen Setup (
$sblk
): - Clears variables (
kyjrdt
,kyyn
,msgout
) to initialize the process. -
Sets
@sfnex
to'S1'
, indicating the next screen to display isAR200PS1
(journal date input). -
Display and Read Screen (
$xcpt
and Main Loop): - The
$xcpt
subroutine displays the next screen based on@sfnex
:- If
@sfnex = 'S1'
, writesAR200PS1
. - If
@sfnex = 'S2'
, writesAR200PS2
. - Increments
@ccnt
(screen counter) and sets indicator*in98
if the same screen is redisplayed (error condition).
- If
-
The main loop reads the screen:
- For
AR200PS1
, reads the journal date (jrdate
) and sets@sfid = 'S1'
. - For
AR200PS2
, reads the confirmation flag (yn
) and sets@sfid = 'S2'
.
- For
-
Process Screen
AR200PS1
($s1
): - Checks the function key (
@vkey
):- If
0
(Enter key), calls$s1ent
to validate the journal date. - If
2
(command key, e.g., F3), calls$s1ck
to handle exit.
- If
$s1ent
(Enter key processing):- Moves
kyjrdt
tommddyy
and calls@dtedt
to validate the date. - If date is invalid (
*in79 = *on
), displays error message (msgout = 'INVALID DATE'
) and redisplaysAR200PS1
(*in50 = *on
). - If valid, clears indicators (
clrind
), sets@sfnex = 'S2'
, and moves to the confirmation screen.
- Moves
-
$s1ck
(Command key processing):- If F3 (
*inkg = *on
), sets exit indicators (*inu1
,*inlr
) and@sfnex = 'EJ'
to terminate the program.
- If F3 (
-
Process Screen
AR200PS2
($s2
): - Checks the function key (
@vkey
):- If
0
(Enter key), calls$s2ent
to process confirmation. - If
2
(command key), calls$s2ck
to handle navigation or exit.
- If
$s2ent
(Enter key processing):- If
kyyn <> 'Y'
, clears fields (clrfld
) and returns toAR200PS1
(@sfnex = 'S1'
). - If
kyyn = 'Y'
, sets@sfnex = 'EJ'
to exit the program, indicating confirmation.
- If
-
$s2ck
(Command key processing):- If F3 (
*inkg = *on
), sets exit indicators and@sfnex = 'EJ'
. - If another command key (e.g., F12,
ka
), returns toAR200PS1
(@sfnex = 'S1'
).
- If F3 (
-
Date Validation (
@dtedt
): -
Validates the journal date (
mmddyy
) in MMDDYY format:- Breaks down the date into month (
$month
), day ($day
), and year ($yr
). - Validates month (1–12).
- For February, checks leap year:
- Non-zero year: Divides year by 4 (multiply by 0.25) to check leap year.
- Century year: Combines century (
y2kcen
) and year, divides by 400 (multiply by 0.0025). - Leap year allows up to 29 days; non-leap year allows 28.
- For other months, checks 30 or 31 days based on month (e.g., April, June, September, November = 30; others = 31).
- Sets
*in79
if the date is invalid.
- Breaks down the date into month (
-
Clear Fields and Indicators:
clrfld
: Resetskyjrdt
,kyyn
, andmsgout
, and sets@sfnex = 'S1'
for redisplay.-
clrind
: Clears error and display indicators (*in50
,*in81
–*in86
,*in59
). -
Program Termination:
- When
@sfnex = 'EJ'
, the program exits the main loop, sets*inlr = *on
(last record indicator), and terminates, returning control to the calling OCL script.
- When
Business Rules¶
- Journal Date Validation:
- The user must enter a valid journal date in MMDDYY format.
- The date is validated for:
- Valid month (1–12).
- Valid day based on month (30 or 31 days) and leap year for February (28 or 29 days).
- Leap year logic accounts for century (Y2K compliance using
y2kcen
andy2kcmp
).
-
Invalid dates trigger an error message (
INVALID DATE
) and prompt redisplay. -
Two-Step Input Process:
- Screen
AR200PS1
collects the journal date. - Screen
AR200PS2
requires confirmation (yn = 'Y'
) to proceed. -
If confirmation is not
Y
, the user is returned toAR200PS1
. -
Exit Conditions:
- Pressing F3 (
*inkg
) on either screen exits the program, setting*inu1
and*inlr
. -
Other command keys (e.g., F12,
ka
) onAR200PS2
return toAR200PS1
. -
Error Handling:
- Invalid dates set
*in79
and display an error message. - Indicators (
*in50
,*in81
–*in86
,*in59
) control error display and screen behavior.
Tables Used¶
The program uses no database files (physical or logical files) directly. Instead, it interacts with:
- Workstation Display File: AR200PD
(originally SCREEN
), defined as a CF
(combined file) with formats AR200PS1
and AR200PS2
. This file handles user input/output via the screen.
- Compile-Time Data: A single message array (msg
) with one entry (INVALID DATE
) defined in the CTDATA
section.
No traditional database tables (e.g., A/R master file or journal file) are referenced, suggesting this program’s sole purpose is to collect and validate the journal date, passing it to subsequent programs (e.g., AR201
) for actual transaction posting.
External Programs Called¶
The program does not explicitly call external programs using CALL
operations. All processing is internal, with subroutines handling specific tasks:
- $sblk
: Initializes the blank screen.
- $s1
, $s1ent
, $s1ck
: Process the journal date input screen.
- $s2
, $s2ent
, $s2ck
: Process the confirmation screen.
- $xcpt
: Manages screen display.
- clrind
, clrfld
: Clear indicators and fields.
- @dtedt
: Validates the journal date.
The program is called by the OCL script (AR201P.ocl36.txt
) and likely passes the validated journal date (kyjrdt
) to subsequent programs (e.g., AR201
) via parameters or data areas.
Notes¶
- Y2K Compliance: The program includes logic for century handling (
y2kcen
,y2kcmp
) to ensure proper date validation, reflecting its conversion date (04/11/23) and Y2K considerations. - Conversion Notes: The
T4
prefixes indicate a TARGET/400 source conversion, with 33 added lines, 8 modified lines, and 279 total lines processed. Changes include modernized syntax (e.g.,EVAL
instead ofMOVE
,READ
instead ofREAD SCREEN
). - Screen Formats:
AR200PS1
: Capturesjrdate
(journal date, positions 3–8) and displaysmsgout
(error message, position 41).AR200PS2
: Displaysjrdate
(position 6), capturesyn
(confirmation, position 7), and displaysmsgout
(position 42).- Parameters: The program receives the journal date as a parameter (likely
?9?
from the OCL) and stores it inkyjrdt
(data area, positions 100–105).
If you have additional details (e.g., the source for AR201
or related database files), I can provide further analysis. Let me know if you need clarification or additional information!