AR137P RPGLE
The provided AR137P.rpgle.txt is an RPGLE (RPG IV) program used in IBM i (AS/400) systems, invoked by the AR137P.ocl36.txt OCL script for EFT (Electronic Funds Transfer) email selection by customer or all. This program handles user input validation for EFT posting table date selection, ensuring that company numbers, customer numbers, and selection criteria are valid before proceeding. Below, I’ll explain the process steps, business rules, tables used, and external programs called, providing a clear and concise analysis.
Process Steps of the RPGLE Program¶
The AR137P program is designed to validate user input from a workstation (display file) and set up parameters for EFT processing. It uses a display file for user interaction and validates data against database files. Here’s a step-by-step breakdown of the program’s execution:
- Program Initialization:
- Header Specifications:
H DFTACTGRP(*NO): Runs in a named activation group, allowing better control over program resources.H FIXNBR(*ZONED:*INPUTPACKED): Ensures zoned and packed decimal fields are handled correctly during input.H DFTNAME(AR137P): Sets the default program name toAR137P.
- File Definitions:
AR137PD: A workstation file (display file) for user interaction, using the Profound UI handler for modern UI support.ARCUST: Input file (384 bytes, key starting at position 2) for customer data.ARCONT: Input file (256 bytes, key starting at position 2) for accounts receivable control data.GSCONT: Input file (512 bytes, key starting at position 2) for system control data.
- Data Structures and Variables:
MSG: A 40-character array of 6 error messages loaded viaCTDATA.FILENM: A data structure with an 8-characterFILEfield for constructing a file name.UDS: A data area structure for Local Data Area (LDA) fields, including:KYCO(company number, positions 101-102).KYSLDT(selection date, positions 103-108).STATUS(status flag, position 109).KYUPDT(update date, positions 110-115).KYALSL(selection type, ‘ALL’ or ‘SEL’, positions 121-123).KYCS01toKYCS10(customer numbers, positions 124-183).Y2KCENandY2KCMP(positions 509-512) for Y2K date handling.
-
Indicators: Uses indicators (e.g.,
*IN01,*IN09,*IN20, etc.) to control program flow and screen output. -
Initial Workstation File Read:
- Checks if
QSCTL(control field) is blank:- If blank, sets
*IN09on (initial run),*IN01off, andQSCTLto ‘R’ (read mode). - If not blank, sets
*IN09off,*IN01on, reads theAR137PDdisplay file, and returns if the last record is read (LRindicator).
- If blank, sets
-
Initializes indicators (
*IN50to*IN55,*IN20,*IN81) to off and clearsMSG35(message field). -
Cancel Check:
-
If
*INKG(cancel key, typically F3) is on:- Sets
*IN01off,*INU8on (user-controlled indicator),*INLRon (last record, program end). - Jumps to the
ENDtag to terminate the program.
- Sets
-
One-Time Setup (
ONETIMSubroutine): -
If
*IN09is on (initial run):- Executes the
ONETIMsubroutine: - Chains to
GSCONTwith key ‘00’ to retrieve the company number (GXCONO). - If found (
*IN99off) andGXCONOis non-zero, setsKYCOtoGXCONO. - Sets
KYALSLto ‘ALL’ (default selection type). - Sets
*IN81on (display update flag) and clearsMSG40(message field). - Jumps to the
ENDtag, skipping further processing for the initial run.
- Executes the
-
Input Validation (
EDITSubroutine): -
If
*IN01is on (user submitted input):- Executes the
EDITsubroutine to validate input fields: - Initialize Indicators: Clears indicators
*IN20,*IN30to*IN41, and*IN90to ensure a clean validation state. - Validate Company:
- Chains to
ARCONTusingKYCO(company number). - If not found (
*IN20on), sets*IN81and*IN90on, moves error message 1 (“INVALID COMPANY #”) toMSG40, and jumps toENDEDT.
- Chains to
- Validate Selection Type:
- If
KYALSLis ‘ALL’ andKYCS01(first customer number) is non-zero, sets*IN81,*IN90,*IN41on, moves error message 5 (“CANNOT SELECT CUSTOMERS WITH ‘ALL’”) toMSG40, and jumps toENDEDT. - If
KYALSLis ‘SEL’ andKYCS01is zero, sets*IN81,*IN90,*IN31on, moves error message 6 (“MUST ENTER CUSTOMER WITH ‘SEL’”) toMSG40, and jumps toENDEDT.
- If
- Validate Customers:
- If
KYALSLis ‘SEL’, validates up to 10 customer numbers (KYCS01toKYCS10): - For each non-zero customer number, constructs a key (
KYCOCU) by combiningKYCOand the customer number. - Chains to
ARCUSTusingKYCOCU. - If not found, sets
*IN81,*IN90, and the corresponding indicator (*IN31to*IN40), moves error message 4 (“INVALID CUSTOMER # ENTERED”) toMSG40, and jumps toENDEDT.
- If
- Validate Update Date:
- If
KYUPDT(update date) is zero, sets*IN81,*IN90on, moves error message 2 (“MUST ENTER BATCH CREATE DATE”) toMSG40, and jumps toENDEDT.
- If
- Check File Existence:
- Constructs a file name in
FILENMby combining ‘GE’ andKYUPDT. - Calls the
AR135TCprogram, passingFILENMandSTATUS. - If
STATUSis ‘N’ (file does not exist), sets*IN81,*IN20,*IN90on, moves error message 3 (“FILE WITH DATE SELECTED DOES NOT EXIST”) toMSG40, and jumps toENDEDT.
- Constructs a file name in
- Successful Validation:
- If all validations pass, sets
STATUSto ‘Y’ (valid input).
- If all validations pass, sets
- Jumps to
ENDEDTto end the subroutine.
- Executes the
-
Program Termination:
- At the
ENDtag:- If
*IN81is off (no errors), sets*INLRon to end the program. - If
*IN81is on (errors), writes to theAR137PDdisplay file to show error messages (e.g.,MSG40) to the user.
- If
Business Rules¶
The program enforces the following business rules for EFT email selection:
- Company Validation:
-
The company number (
KYCO) must exist in theARCONTfile. If invalid, error message “INVALID COMPANY #” is displayed. -
Selection Type Consistency:
- If
KYALSLis ‘ALL’ (process all customers), no customer numbers (KYCS01toKYCS10) can be specified. Violation triggers “CANNOT SELECT CUSTOMERS WITH ‘ALL’”. -
If
KYALSLis ‘SEL’ (selective customers), at least one customer number (KYCS01) must be provided. If not, “MUST ENTER CUSTOMER WITH ‘SEL’” is displayed. -
Customer Validation:
-
For
KYALSL= ‘SEL’, each provided customer number (KYCS01toKYCS10) must exist in theARCUSTfile for the specified company (KYCO). Invalid customers trigger “INVALID CUSTOMER # ENTERED”. -
Update Date Requirement:
-
The update date (
KYUPDT) must be non-zero. If zero, “MUST ENTER BATCH CREATE DATE” is displayed. -
File Existence Check:
-
The EFT posting table file (named with prefix ‘GE’ and
KYUPDT) must exist. If not, “FILE WITH DATE SELECTED DOES NOT EXIST” is displayed. -
Default Setup:
-
On initial run, the company number is retrieved from
GSCONT(key ‘00’), andKYALSLdefaults to ‘ALL’. -
Error Handling:
- Any validation failure sets error indicators (
*IN81,*IN90) and displays an error message via theAR137PDdisplay file, prompting the user to correct input.
Tables (Files) Used¶
The program uses the following files:
- AR137PD:
- Type: Workstation (display) file.
-
Purpose: Handles user input/output for the EFT selection screen, using Profound UI for modern interface rendering.
-
ARCUST:
- Type: Input file (384 bytes, key at position 2).
- Fields:
ARDEL(delete code),ARCO(company number),QQARCU(customer number),ARNAME(customer name),ARADR1toARADR3(address lines). -
Purpose: Stores customer data for validation of customer numbers.
-
ARCONT:
- Type: Input file (256 bytes, key at position 2).
-
Purpose: Stores accounts receivable control data for validating company numbers.
-
GSCONT:
- Type: Input file (512 bytes, key at position 2).
- Fields:
GXDEL(delete code),GXCONO(company number). - Purpose: Stores system control data, used to retrieve the default company number.
External Programs Called¶
The program calls the following external program:
- AR135TC:
- Called in the
EDITsubroutine to check if the EFT posting table file (constructed from ‘GE’ andKYUPDT) exists. - Parameters:
FILENM(input, file name),STATUS(output, ‘Y’ or ‘N’).
Integration with OCL Script¶
The AR137P RPGLE program is invoked by the AR137P.ocl36.txt OCL script via // LOAD AR137P and // RUN. The OCL script:
- Defines the ARCONT and ARCUST files, matching the RPGLE file definitions.
- Calls AR137 (likely another program or procedure) after AR137P completes, passing parameters including the validated KYALSL and customer numbers.
- Uses the STATUS field (position 109) to determine whether to proceed with AR137 (// IFF ?L'109,1'?/Y GOTO END).
The RPGLE program sets STATUS to ‘Y’ if validations pass, allowing the OCL script to proceed with AR137. If validations fail, STATUS remains unset or is ‘N’, causing the OCL script to skip AR137.
Summary¶
The AR137P RPGLE program validates user input for EFT email selection, ensuring valid company numbers, customer numbers, selection type, and update date. It interacts with the user via the AR137PD display file, checks data against ARCUST, ARCONT, and GSCONT files, and verifies file existence via AR135TC. The program enforces strict business rules to ensure data integrity before passing control back to the OCL script for further processing.
Tables Used: AR137PD (display), ARCUST (customer), ARCONT (control), GSCONT (system control).
External Programs Called: AR135TC.