AR200P RPGLE
The provided document is an RPGLE program named AR200P.rpgle.txt, which is called by the OCL program AR200P.ocl36.txt (as seen in the previous query). This RPG program is designed to prompt the user for a journal date for cash receipts posting in an accounts receivable (AR) module, likely on an IBM System/36 or AS/400 system. Below, I’ll explain the process steps, business rules, tables used, and external programs called.
Process Steps of the RPG Program¶
The RPGLE program AR200P is responsible for displaying screens to prompt the user for a journal date, validating the input, and confirming the date before proceeding. The program uses two screen formats (AR200PS1 and AR200PS2) and includes date validation logic. Here’s a step-by-step breakdown of the process:
- Program Initialization:
- Header Specifications:
H DFTACTGRP(*NO): Runs in a non-default activation group, typical for ILE RPG.H fixnbr(*zoned:*inputpacked): Ensures zoned and packed numeric fields are handled correctly.H dftname(ar200p): Sets the default program name toAR200P.
- File Declarations:
far200pd cf e workstn Handler('PROFOUNDUI(HANDLER)') infds(@infds): Defines a workstation file (AR200PD) for interactive screen handling, using a Profound UI handler for modernized display. Theinfds(information data structure) captures screen status, including the virtual key pressed (@vkey).
- Data Definitions:
msg: A 35-character array with one predefined message ("INVALID DATE") for error handling.uds: A user data structure containing:kyjrdt(positions 100-105, numeric): Stores the journal date.y2kcen(positions 509-510, numeric): Century for Year 2000 compliance.y2kcmp(positions 511-512, numeric): Comparison value for century.@infds: Captures screen status, including@vkeyfor the function key pressed.
-
Input Specifications:
- Defines two screen formats:
AR200PS1(S1) andAR200PS2(S2). AR200PS1: Containsjrdate(journal date, positions 3-8, MMDDYY format), broken intomm(month, positions 3-4) anddd(day, positions 5-6).AR200PS2: Containsjrdate(display-only, positions 3-8) andyn(Y/N confirmation, position 3).@sfid: Screen format identifier (S1, S2, or blank for initial state).
- Defines two screen formats:
-
Main Processing Loop (
dow @sfnex <> 'EJ'): - The program runs in a loop until the screen format next (
@sfnex) is set to'EJ'(end job). - Processes the current screen based on
@sfid(screen format identifier):- If
@sfidis blank, calls$sblk(initial blank screen). - If
@sfidis'S1', calls$s1(process date entry screen). - If
@sfidis'S2', calls$s2(process confirmation screen).
- If
- Checks if
@sfnex = 'EJ'(set by user cancellation or program completion), and if so, sets*inlr(last record indicator) to*onand jumps to theendittag to terminate. - Calls
$xcptto display the next screen. -
Reads the next screen input:
- If
@sfnex = 'S1', readsAR200PS1(date entry screen). - Otherwise, reads
AR200PS2(confirmation screen). - Sets
@sfidto match the screen read (S1orS2).
- If
-
Subroutine
$sblk(Blank Screen, First Time Only): -
Initializes variables:
kyjrdt = *zero: Clears the journal date.kyyn = *blanks: Clears the confirmation field.msgout = *blanks: Clears the error message.@sfnex = 'S1': Sets the next screen toAR200PS1(date entry).
-
Subroutine
$s1(Process Date Entry Screen): - Handles input from
AR200PS1(date entry screen). -
Checks the virtual key (
@vkey):- If
@vkey = 0(Enter key), calls$s1entto validate the date. - If
@vkey = 2(Command key), calls$s1ckto handle function keys.
- If
-
Subroutine
$s1ent(Edit Date Fields): -
Validates the journal date (
jrdate):- Moves
kyjrdt(journal date) tommddyyfor validation. - Calls
@dtedtto validate the date format and correctness. - If
*in79 = *on(date invalid): - Sets
msgout = "INVALID DATE". - Sets
*in50 = *onto display the error on the screen. - Jumps to
ends1eto redisplayAR200PS1. - If valid:
- Clears
msgout. - Calls
clrindto reset indicators. - Sets
@sfnex = 'S2'to display the confirmation screen (AR200PS2).
- Moves
-
Subroutine
$s1ck(Command Key Functions for S1): - Handles function key presses (e.g., F10 or F11, mapped to
*inkg). - If
*inkg = *on(cancel key):- Sets
*inu1 = *on(likely sets switch bit U1 for the OCL program). - Sets
*inlr = *onto end the program. - Sets
@sfnex = 'EJ'to exit the loop.
- Sets
-
Resets indicators
*in10and*in11. -
Subroutine
$s2(Process Confirmation Screen): - Handles input from
AR200PS2(confirmation screen). -
Checks the virtual key (
@vkey):- If
@vkey = 0(Enter key), calls$s2entto process the confirmation. - If
@vkey = 2(Command key), calls$s2ckto handle function keys.
- If
-
Subroutine
$s2ent(Edit Confirmation Fields): -
Checks the confirmation field (
kyyn):- If
kyyn <> 'Y', callsclrfldto reset fields and sets@sfnex = 'S1'to return to the date entry screen. - If
kyyn = 'Y', sets@sfnex = 'EJ'to end the program, indicating the date is confirmed.
- If
-
Subroutine
$s2ck(Command Key Functions for S2): -
Handles function key presses:
- If
*inka(likely a "back" key), sets@sfnex = 'S1'to return to the date entry screen. - If
*inkg(cancel key), sets*inu1 = *on,*inlr = *on, and@sfnex = 'EJ'to exit.
- If
-
Subroutine
$xcpt(Display Next Screen):- Increments
@ccnt(screen counter). - If
@sfnex = @sfid, sets*in98to indicate no screen change is needed. - Writes the appropriate screen:
- If
@sfnex = 'S1', writesAR200PS1. - If
@sfnex = 'S2', writesAR200PS2.
- Increments
-
Subroutine
clrind(Clear Indicators):- Resets error and display indicators (
*in50,*in81–*in86,*in59) to*off.
- Resets error and display indicators (
-
Subroutine
clrfld(Clear Fields):- Resets fields for redisplay:
kyjrdt = *zero.kyyn = *blank.msgout = *blanks.@sfnex = 'S1'.
-
Subroutine
@dtedt(Date Edit Routine):- Validates the date in
mmddyy(MMDDYY format): - Extracts month (
$month), day ($day), and year ($yr). - Checks:
- Month must be ≤ 12.
- For February:
- If year is not 00, checks for leap year by dividing year by 4.
- If leap year, day must be ≤ 29; otherwise, ≤ 28.
- If year is 00, combines century (
y2kcen) and year, checks for leap year by dividing by 400. - For other months:
- Months with 30 days (April, June, September, November) must have day ≤ 30.
- Other months must have day ≤ 31.
- Sets
*in79 = *onif any validation fails, indicating an invalid date.
- Validates the date in
-
Program Termination:
- When
@sfnex = 'EJ', the program sets*inlr = *onand exits. - The
U1indicator (set via*inu1) likely corresponds to theSWITCH1-1check in the OCL program, signaling cancellation.
- When
Business Rules¶
The program enforces the following business rules for cash receipts journal date entry:
1. Date Entry and Validation:
- The user must enter a journal date in MMDDYY format on the AR200PS1 screen.
- The date is validated for:
- Valid month (1–12).
- Valid day based on the month (e.g., ≤ 30 for April, ≤ 28 or 29 for February depending on leap year).
- Leap year calculation for February, accounting for century (Year 2000 compliance).
- If the date is invalid, an "INVALID DATE" message is displayed, and the user must re-enter the date.
- Confirmation:
- After a valid date is entered, the
AR200PS2screen displays the date and prompts for a Y/N confirmation. - If the user enters
Y, the program accepts the date and exits (@sfnex = 'EJ'). -
If the user enters anything other than
Y, the program returns to the date entry screen (AR200PS1). -
Cancellation:
- The user can cancel at either screen using a function key (e.g.,
*inkg, likely F3 or F12). -
Cancellation sets
*inu1 = *on(likely setting switch bit U1) and exits the program, signaling the OCL program to cancel further processing. -
Screen Flow:
- The program starts with a blank state, displays
AR200PS1for date entry, thenAR200PS2for confirmation. -
The user can navigate back from
AR200PS2toAR200PS1using a function key (e.g.,*inka). -
Error Handling:
- Invalid dates trigger an error message and keep the user on
AR200PS1. - Indicators are used to control screen display and error states (e.g.,
*in50for error display,*in79for date validation failure).
Tables Used¶
In RPGLE, "tables" typically refer to database files or display files. The program uses:
1. Display File: AR200PD:
- A workstation file for interactive screen handling.
- Contains two formats:
- AR200PS1: Date entry screen with fields jrdate (MMDDYY), mm (month), dd (day), and msgout (error message).
- AR200PS2: Confirmation screen with fields jrdate (display-only), yn (Y/N), and msgout.
- Uses the Profound UI handler for modernized display.
- No Database Files:
- The program does not directly reference any physical or logical files (tables) for data storage or retrieval.
- The journal date (
kyjrdt) is stored in a data area (uds), not a database file. - It’s likely that the validated date is passed to subsequent programs (e.g.,
AR200in the OCL) for updating AR-related tables, but these are not accessed here.
External Programs Called¶
The RPG program does not explicitly call any external programs using CALL or similar operations. All processing is handled within subroutines:
- Subroutines (internal): $sblk, $s1, $s1ent, $s1ck, $s2, $s2ent, $s2ck, $xcpt, clrind, clrfld, @dtedt.
- No External Program Calls: Unlike the OCL program, which calls GSGENIEC, SCPROCP, GSY2K, and AR200, this RPG program is self-contained.
Integration with OCL Program¶
- The OCL program (
AR200P.ocl36.txt) loads and runsAR200Pafter setting up the environment and checking conditions. - The
U1indicator (*inu1) inAR200Plikely sets the first switch bit checked by the OCL’sIF SWITCH1-1 CANCEL, allowing cancellation to propagate back to the OCL. - The
kyjrdtvalue (journal date) is likely stored in the data area (uds) and used by the subsequentAR200program called in the OCL for actual cash receipts posting. - The
?9?parameter in the OCL’sAR200 ,,,,,,,,?9?may relate tokyjrdtor another value set byAR200P.
Notes¶
- Modernization: The use of
Handler('PROFOUNDUI(HANDLER)')indicates the program has been modernized for a web or graphical interface using Profound UI, despite being rooted in System/36 or AS/400 conventions. - Year 2000 Compliance: The
y2kcenandy2kcmpfields and leap year logic reflect Y2K compliance, critical for legacy systems handling dates. - Limitations: The program only handles date input and validation, not the actual posting of cash receipts, which is likely handled by
AR200or other programs in the OCL flow. - Source Conversion: The
T4prefixes (e.g.,T4A,T4M) indicate the program was converted using a tool (TARGET/400), with 33 lines added, 8 modified, and 279 processed, suggesting migration from RPG II or III to RPGLE.
If you have additional context (e.g., the AR200 program, the AR200PD display file definition, or database file structures), I can provide a deeper analysis of the end-to-end process or data flow. Let me know if you need further clarification or specific details!