AR157P RPGLE
The provided document, AR157P.rpgle.txt, is an RPGLE (RPG IV) program used in IBM midrange systems (e.g., AS/400, iSeries) to handle the prompting and validation for EFT (Electronic Funds Transfer) cash receipts batch file creation. It is called from the main OCL program (AR157P.ocl36.txt) described previously. Below is a detailed explanation of the process steps, business rules, tables/files used, and external programs called, based on the RPGLE source code.
Process Steps of the RPGLE Program (AR157P)¶
The AR157P RPGLE program is responsible for validating user input for creating a cash receipts batch file, interacting with a workstation display file (AR157PFM), and performing checks on company numbers, upload dates, and file existence. The program uses a combination of file operations, user interface handling, and subroutine logic to ensure valid data before proceeding. Here’s a step-by-step breakdown of the process:
- Program Initialization:
- The program declares the default activation group (
DFTACTGRP(*NO)) and sets the default program name toAR157P(DFTNAME(AR157P)). - It defines the workstation file
AR157PFMas a combined file (CF) for input/output with a handler for Profound UI (HANDLER('PROFOUNDUI(HANDLER)')), indicating a modernized user interface. - Two input files,
ARCONTandGSCONT, are defined for validation purposes. - Data structures (
FILENM), variables (KYCO,KYSLDT,STATUS,KYUPDT,KYDELT,EXISTS), and arrays (MSG,COM) are initialized for storing user input, status flags, and error messages. - The program sets initial indicator states (
*IN50to*IN55,*IN20,*IN81,*IN21,*IN90) to*OFFto reset error and control flags. -
Screen message fields (
MSG35,MSG1,MSG2,MSG40) are cleared to blanks. -
Handle Workstation Input (Read
AR157PFM): - The program checks the value of
QSCTL(likely a control field from the workstation file):- If
QSCTLis blank, it sets*IN09to*ON(indicating initial screen display),*IN01to*OFF, and setsQSCTLto'R'(likely to indicate a read operation). - If
QSCTLis not blank, it sets*IN09to*OFF,*IN01to*ON, reads theAR157PFMworkstation file, and checks for the last record (LR). If the last record is read, the program returns immediately.
- If
-
This step manages the initial display of the prompt screen or processes user input from the screen.
-
Handle Function Key
F3(Exit): - If the
F3key (*INKG) is pressed:- The program sets
*IN01to*OFF,*INU8to*ON, and*INLRto*ON(indicating program termination). - It jumps to the
ENDtag, exiting the program.
- The program sets
-
This allows the user to exit the program without further processing.
-
Handle Function Key
F12(Delete): - If the
F12key (*INKL) is pressed:- The program sets
*IN01and*IN81to*OFF,*INLRto*ON, and setsKYDELTto'Y'(indicating a request to delete a batch file). - It jumps to the
ENDtag, exiting the program.
- The program sets
-
This allows the user to signal deletion of an existing cash receipts batch file (handled in the OCL program).
-
Initial Screen Processing (
ONETIMSubroutine): -
If
*IN09is*ON(initial screen display):- The program executes the
ONETIMsubroutine. - It chains (reads) the
GSCONTfile using key'00'to retrieve a default company number (GXCONO). - If a record is found (
*IN99is*OFF) andGXCONOis non-zero, it setsKYCOtoGXCONO. - It sets
*IN81to*ONto trigger screen output. - If
EXISTSis'Y'(indicating a cash receipts batch file already exists), it sets error messageMSG1toCOM(1)("A CASH RECEIPTS BATCH ALREADY EXISTS. PRESS F12 TO DELETE.") and sets*IN81,*IN21, and*IN90to*ONto display the error. - The program jumps to the
ENDtag after completing the subroutine.
- The program executes the
-
Validate User Input (
EDITSubroutine): -
If
*IN01is*ON(user has submitted input):- The program executes the
EDITsubroutine to validate the input. - Validate Company Number:
- Chains the
ARCONTfile usingKYCO(company number). - If no record is found (
*IN20is*ON), it sets*IN81and*IN90to*ON, setsMSG40toMSG(1)("INVALID COMPANY #"), and jumps toENDEDT. - Validate Bank Upload Date:
- Compares
KYUPDT(bank upload date) to zero. - If
KYUPDTis zero (*IN20is*ON), it sets*IN81and*IN90to*ON, setsMSG40toMSG(2)("MUST ENTER BANK UPLOAD DATE"), and jumps toENDEDT. - Check File Existence:
- Constructs a filename by moving
'GE'andKYUPDTintoFILENM. - Calls the external program
AR135TC, passingFILENMandSTATUSas parameters to check if a file with the selected date exists. - If
STATUSis'N'(file does not exist), it setsMSG40toMSG(3)("FILE WITH DATE SELECTED DOES NOT EXIST"), sets*IN81,*IN20, and*IN90to*ON, and jumps toENDEDT. - Successful Validation:
- If all checks pass, sets
STATUSto'Y'to indicate valid input. - The
ENDEDTtag ends the subroutine.
- The program executes the
-
Write to Workstation and Terminate:
- If
*IN81is*OFF, the program sets*INLRto*ONto terminate. - If
*IN81is*ON, it writes to theAR157PFMworkstation file to display errors or updated screen data. - The program then terminates at the
ENDtag.
Business Rules¶
The AR157P program enforces the following business rules for EFT cash receipts batch file creation:
- Company Number Validation:
- The user must enter a valid company number (
KYCO). -
The program checks the
ARCONTfile to ensure the company number exists. If invalid, it displays "INVALID COMPANY #". -
Bank Upload Date Requirement:
- The user must enter a non-zero bank upload date (
KYUPDT). -
If the date is missing (zero), the program displays "MUST ENTER BANK UPLOAD DATE".
-
File Existence Check:
- The program checks if a file corresponding to the selected upload date exists by calling
AR135TC. -
If the file does not exist, it displays "FILE WITH DATE SELECTED DOES NOT EXIST".
-
Existing Batch File Handling:
-
If a cash receipts batch file already exists (
EXISTS = 'Y'), the program displays "A CASH RECEIPTS BATCH ALREADY EXISTS. PRESS F12 TO DELETE." and prompts the user to pressF12to delete it. -
User Exit Options:
- Pressing
F3exits the program without further processing. -
Pressing
F12signals a request to delete an existing batch file (setsKYDELTto'Y'). -
Default Company Number:
-
On initial screen display, the program retrieves a default company number from the
GSCONTfile (key'00') and populatesKYCOif a valid record is found. -
Error Handling and Screen Updates:
- Errors are displayed on the workstation screen (
AR157PFM) with appropriate messages. - The program uses indicators (
*IN81,*IN90, etc.) to control screen output and error states.
Tables/Files Used¶
The program interacts with the following files:
- AR157PFM:
- Type: Combined workstation file (
CF) - Purpose: Handles user input/output for the prompt screen, managed by Profound UI.
-
Usage: Read for user input, written to display errors or updated data.
-
ARCONT:
- Type: Input file (
IF), disk-based, 256 bytes, keyed access (KEYLOC(2)). - Purpose: Stores Accounts Receivable control data, used to validate the company number (
KYCO). -
Key: Starts at position 2.
-
GSCONT:
- Type: Input file (
IF), disk-based, 512 bytes, keyed access (KEYLOC(2)). - Purpose: Stores general system control data, used to retrieve a default company number (
GXCONO) with key'00'. - Key: Starts at position 2.
External Programs Called¶
The program calls the following external program:
1. AR135TC:
- Purpose: Checks the existence of a file based on the constructed filename (FILENM) derived from 'GE' and KYUPDT.
- Parameters:
- FILENM: Input/output parameter containing the file name to check.
- STATUS: Output parameter indicating whether the file exists ('Y' or 'N').
Notes¶
- Conversion Details: The program was converted on 08/31/23 using TARGET/400, with 56 added lines, 7 modified lines, and 112 total RPG source lines processed. The
T4A,T4M, andT4Oprefixes indicate added, modified, and original lines, respectively. - Dynamic File Naming: The
FILENMdata structure constructs a file name using'GE'andKYUPDT, suggesting a naming convention likeGEYYYYMMfor the cash receipts file. - Profound UI Integration: The use of
HANDLER('PROFOUNDUI(HANDLER)')indicates a modernized user interface, likely replacing a traditional 5250 green-screen interface. - Link to OCL Program: The
AR157PRPGLE program is loaded and run by theAR157P.ocl36OCL program. Variables likeKYDELTandEXISTSare shared with the OCL program to handle file deletion and existence checks. - Error Messages: The program uses predefined error messages (
MSGarray) and a common message (COMarray) to communicate validation failures or batch file existence to the user.
If you need further clarification, additional details about related programs (e.g., AR135TC), or integration with the OCL program, let me know!