AR137E RPG36
The AR137E.rpg36.txt is an RPG III program used in IBM i (AS/400) systems, invoked by the AR137.ocl36.txt OCL script as part of the EFT (Electronic Funds Transfer) draft notice filtering process. This program counts the number of email addresses assigned to each EFT customer in the AREFTS file, using customer format data from ARCUFMX, and writes the count to the ARDTWSC file. Below, I’ll explain the process steps, business rules, tables (files) used, and external programs called, providing a clear and concise analysis.
Process Steps of the AR137E RPG Program¶
The AR137E program processes EFT summary records, checks for valid email addresses in the customer format file, and records the count of email addresses per customer for EFT draft notices. Here’s a step-by-step breakdown of its execution:
- Program Header:
H P064 B AR137E: Specifies the program identifier (P064), batch mode (B), and program name (AR137E).-
Indicates the program is designed for batch processing to count email addresses for EFT customers.
-
File Definitions:
FAREFTS IP F 100 100 DISK: DefinesAREFTSas the primary input file (100 bytes, fixed length).FARCUFMX IF F 266 266 L21AI EXTK DISK: DefinesARCUFMXas an input file (266 bytes, indexed with a 21-byte key, externally defined key).-
FARDTWSC UF F 11 11 8AI 1 DISK A: DefinesARDTWSCas an update-capable output file (11 bytes, indexed with an 8-byte key, append modeA). -
Input Specifications:
IAREFTS NS 01 1NCD:- Defines the
AREFTSrecord layout for non-deleted records (1NCD). - Fields include:
AFDEL(position 1, delete flag).AFCO(positions 2-3, company number).AFCUST(positions 4-9, customer number).AFCOCU(positions 2-9, composite key: company + customer).AFDESC(positions 10-39, description).AFAMT(positions 40-44, packed, amount).AFDISC(positions 45-49, packed, discount).AFEAMT(positions 50-54, packed, EFT amount).AFDAT8(positions 55-62, 8-digit date).AFUPD8(positions 63-70, 8-digit update date).
- Defines the
IARCUFMX NS:- Defines the
ARCUFMXrecord layout: FMDEL(position 1, delete code).FMCONO(positions 2-3, company number).FMCUST(positions 4-9, customer number).FMFMTY(positions 10-13, form type).FMSEQ#(positions 14-22, sequence number).FMCNTC(positions 23-72, contact name).FMEMLA(positions 73-132, email address).FMFAX#(positions 133-152, fax number).FMFMYN(position 153, send original flag).FMRPYN(position 154, send reprint flag).FMMLYN(position 155, send by mail flag).FMBKYN(position 155, send terms on back flag).
- Defines the
-
IARDTWSC NS: Defines theARDTWSCrecord layout (not explicitly detailed but includesAFCOCUandCOUNT). -
Calculation Logic:
- Main Loop (DO for
01Indicator):- Processes each non-deleted record in
AREFTS(01indicator,1NCD). - Initializes:
A(counter) to 1.FMKEY(21-byte key) to blanks.- Constructs
FMKY12(12 bytes) by combiningAFCO(company) andFMKY10(10 bytes, customer + ‘EFT’). - Sets
FMKEYtoFMKY12for indexingARCUFMX. - Positions the
ARCUFMXfile at the key usingSETLL.
- Processes each non-deleted record in
- Read ARCUMFX Loop (AGNFM):
- Reads
ARCUFMXrecords (READ, indicator08). - If end of file (
08on), jumps toSKIP1. - If counter
Aexceeds 4, jumps toSKIP1(limits processing to 4 email addresses per customer). - Validates:
- If
FMFMTYis not ‘EFT’, jumps toSKIP1. - If
AFCOdoes not matchFMCONO, jumps toSKIP1. - If
AFCUSTdoes not matchFMCUST, jumps toSKIP1. - If
FMDELis ‘D’, loops back toAGNFM(skips deleted records). - If
FMEMLA(email address) is not blank andFMFMYN(send original) is ‘Y’, incrementsCOUNT(3 digits). - If
Ais 2, 3, or 4, incrementsCOUNT(likely for multiple email addresses or formats). - Loops back to
AGNFMto read the nextARCUFMXrecord.
- Reads
-
Output to ARDTWSC:
- Chains to
ARDTWSCusingAFCOCU(company + customer key, indicator98). - Ends the
DOloop for the currentAREFTSrecord.
- Chains to
-
Output Specification:
OARDTWSC DADD 01 98:- If
98is on (record found inARDTWSC), updates the record with: AFCOCU(positions 1-8, company + customer key).COUNT(positions 9-11, packed, email address count).
- If
-
O D 01N98:- If
98is off (no record found), adds a new record toARDTWSCwith: COUNT(positions 9-11, packed, email address count).
- If
-
Program Termination:
- The program processes all non-deleted records in
AREFTSusing RPG’s implicit file processing cycle, writing or updating records inARDTWSCwith email address counts, and terminates when complete.
Business Rules¶
The AR137E program enforces the following business rules:
- Non-Deleted Records:
-
Only processes non-deleted records in
AREFTS(1NCD) to ensure valid EFT summary data. -
Email Address Counting:
- Counts email addresses in
ARCUFMXfor each customer where:FMFMTYis ‘EFT’ (specific to EFT forms).FMCONOmatchesAFCO(company number).FMCUSTmatchesAFCUST(customer number).FMDELis not ‘D’ (not deleted).FMEMLAis not blank andFMFMYNis ‘Y’ (valid email for sending original EFT drafts).
-
Limits counting to a maximum of 4 email addresses per customer (
A≤ 4). -
Counter Logic:
- Increments
COUNTfor each valid email address (FMEMLAnot blank,FMFMYN = 'Y'). -
Additional increments for
A= 2, 3, or 4, possibly accounting for multiple email formats or addresses. -
Output to ARDTWSC:
- Writes or updates a record in
ARDTWSCfor each customer (AFCOCU) with the count of valid email addresses (COUNT). - Uses the company + customer key (
AFCOCU) to locate or create records.
Integration with AR137 OCL Script¶
The AR137E RPG program is invoked by the AR137.ocl36.txt script via // LOAD AR137E and // RUN, following the AR137A program. The OCL script:
- Defines AREFTS (input, EFT summary data from AR137A), ARCUFMX (input, customer format data), and ARDTWSC (output, temporary file for email counts).
- Uses the ?9? library prefix and a temporary retention for ARDTWSC (50 records).
The AR137E program processes the AREFTS file generated by AR137A, counts email addresses per customer using ARCUFMX, and stores the results in ARDTWSC for use by subsequent programs (e.g., AR137B for final EFT reporting).
Tables (Files) Used¶
The program uses the following files:
- AREFTS:
- Type: Primary input (100 bytes, fixed length).
- Purpose: Contains EFT summary data from
AR137A. -
Fields:
AFDEL,AFCO,AFCUST,AFCOCU,AFDESC,AFAMT,AFDISC,AFEAMT,AFDAT8,AFUPD8. -
ARCUFMX:
- Type: Input (266 bytes, indexed, 21-byte key).
- Purpose: Contains customer format data, including email addresses for EFT drafts.
-
Fields:
FMDEL,FMCONO,FMCUST,FMFMTY,FMSEQ#,FMCNTC,FMEMLA,FMFAX#,FMFMYN,FMRPYN,FMMLYN,FMBKYN. -
ARDTWSC:
- Type: Update-capable output (11 bytes, indexed, 8-byte key, append mode).
- Purpose: Stores the count of email addresses per customer for EFT draft notices.
- Fields:
AFCOCU(company + customer key),COUNT(email address count).
External Programs Called¶
The AR137E program does not call any external programs. It operates solely on the defined files and performs its logic internally.
Summary¶
The AR137E RPG III program counts the number of valid email addresses for each EFT customer in AREFTS, using ARCUFMX to identify email addresses marked for sending original EFT drafts. It writes or updates the count in ARDTWSC, ensuring only non-deleted records with matching company and customer numbers are processed, with a limit of 4 email addresses per customer. The output supports the EFT draft notice process by providing email address counts for reporting.
Tables Used: AREFTS, ARCUFMX, ARDTWSC.
External Programs Called: None.