AR156 RPG36
The provided document is an RPG/36 program named AR156.rpg36, called by the main AR156.ocl36 script. This program creates a NACHA (National Automated Clearing House Association) formatted file for EFT (Electronic Funds Transfer) withdrawals from accounts receivable, specifically for PNC Bank in Pittsburgh. It processes EFT data, generates a NACHA-compliant file, and produces a report. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.
Process Steps of the AR156.rpg36 Program¶
- Program Initialization:
- The program defines input, output, and printer files:
AREFTS(input, 100 bytes): Staging file with processed EFT data.ARCUST(input, 384 bytes, 8-byte key at position 2): Customer master file.ARCONT(input, 256 bytes, 2-byte key at position 2): Company control file.ARCUSP(input, 1344 bytes, 8-byte key at position 2): Customer-specific data file (e.g., EFT banking details).EFTFILE(output, 94 bytes): NACHA-compliant file for bank upload.REPORT(output, 132 bytes): Printer file for EFT report.
- Data structures (
UDS) define key fields:KYCO(company number, positions 101-102).KYSLDT(selected date, positions 103-108).STATUS(status indicator, position 109).KYUPDT(update date, positions 110-115).Y2KCENandY2KCMP(Year 2000 fields, positions 509-512).
-
The program initializes variables (e.g.,
LRCNT,LRHASH,LRDR,LRCR,RECCNT,BATCH#,TRACE#) to track counts, hashes, and amounts for NACHA file creation. -
One-Time Setup (LRTOT1 Subroutine):
-
Executed once at the start:
- Initializes counters (
LRCNT,LRHASH,LRDR,LRCR) to zero and setsRECCNTto 1. - Captures the system date and time (
TIMEtoTIMDAT, moved toTIMEHMandDATE). - Converts
DATEto YYMMDD format by multiplying by 10000.01. - Writes the NACHA File Header Record (
RECTY1) toEFTFILE, including: - Record type '1', priority code '01', ABA numbers, transmission date/time, file ID modifier 'A', record size '094', blocking factor '10', format code '1', destination name 'PNC BANK. PITTSBURGH', origin name 'AMERICAN REFINING GROUP', and reference code 'EFT DRAW'.
- Initializes counters (
-
Company/Batch Header Processing (L2DET Subroutine):
-
Triggered at the level-2 break (
L2, company numberAFCO):- Resets batch-level counters (
L2CNT,L2HASH,L2DR,L2CR) to zero. - Increments
RECCNT(record count). - Sets indicator 84 (likely for report formatting).
- Writes the NACHA Batch Header Record (
RECTY5) toEFTFILE, including: - Record type '5', service class code '200' (EFT debits only), company name 'AMERREFINING ACH', federal tax ID '1222318612', company entry description 'EFT DRAW', effective date (
EFFDTE), originator status code '1', originating DFI-ID '04300009', and batch number (BATCH#).
- Resets batch-level counters (
-
Entry Detail Processing (EACH Subroutine):
-
Processes each EFT record at the level-1 break (
L1, customerAFCUST):- Chains to
ARCUSTusingAFCUSTto retrieve customer details (e.g.,AREFT,ARNAME,CSARTE). - Chains to
ARCUSPto get EFT banking details (e.g.,CSARTEfor bank routing number,CSABK#for bank account number). - Calculates the EFT amount (
AMOUNT=AFEAMTfromAREFTS). - Increments
TRACE#(transaction trace number),L2CNT(batch entry count),LRCNT(file entry count), andRECCNT. - Updates hash totals (
L2HASH,LRHASH) withDDBR(derived fromCSARTE) and debit totals (L2DR,LRDR) withAMOUNT. - Writes the NACHA Entry Detail Record (
RECTY6) toEFTFILE, including: - Record type '6', transaction code '27' (checking debit), customer bank routing number (
CSARTE), bank account number (CSABK#), amount (AMOUNT), customer ID (ARCUST), customer name (ARNAME), addenda indicator '0', and trace number.
- Chains to
-
Batch Control Processing (L2TOT Subroutine):
-
Triggered at the level-2 break:
- Increments
RECCNT. - Writes the NACHA Batch Control Record (
RECTY8) toEFTFILE, including: - Record type '8', service class code '200', entry count (
L2CNT), entry hash (L2HASH), debit total (L2DR), credit total (L2CR), company ID '1222318612', originating DFI-ID '04300009', and batch number.
- Increments
-
File Control and Padding (LRTOT Subroutine):
-
Triggered at the file level:
- Sets
LRBCNTtoBATCH#(batch count). - Increments
RECCNT. - Calculates the number of blocks (
LRBLOK=RECCNT/ 10, rounded up if remainder exists). - Writes the NACHA File Control Record (
RECTY9) toEFTFILE, including: - Record type '9', batch count (
LRBCNT), block count (LRBLOK), entry count (LRCNT), entry hash (LRHASH), debit total (LRDR), and credit total (LRCR). - Pads the file to a multiple of 10 records by writing filler records (
FILLER) with '999999...' untilRECCNTreachesLRBLOK * 10.
- Sets
-
Report Generation:
- The program generates a report via the
REPORTprinter file, likely detailing EFT transactions for each customer, including company and customer details, amounts, and dates.
Business Rules¶
- NACHA File Format Compliance:
-
The program generates a NACHA-compliant file with specific record types:
- File Header (
RECTY1): Includes bank and company details, transmission date/time. - Batch Header (
RECTY5): Defines the batch with company ID and effective date. - Entry Detail (
RECTY6): Contains customer-specific EFT details (e.g., bank account, amount). - Batch Control (
RECTY8): Summarizes batch totals. - File Control (
RECTY9): Summarizes file totals. - Filler Records: Pads the file to a multiple of 10 records for NACHA compliance.
- File Header (
-
EFT Participant Validation:
-
Only customers with
AREFT= 'Y' inARCUSTare processed for EFT withdrawals. -
Banking Details:
-
Customer banking details (
CSARTE,CSABK#) are retrieved fromARCUSPto populate NACHA entry detail records. -
Amount and Hash Totals:
-
The program maintains running totals for debit amounts (
L2DR,LRDR) and entry hashes (L2HASH,LRHASH) for batch and file control records, ensuring accurate NACHA reporting. -
Blocking Factor:
-
The NACHA file uses a blocking factor of 10, requiring filler records to pad the file to a multiple of 10 records.
-
Dynamic File Naming:
-
The program uses dynamic file labels (e.g.,
?9?EFTFIL) from the OCL script, ensuring flexibility across libraries and environments. -
Report Generation:
- A report is generated for auditing, listing EFT transactions with customer details (e.g., name, amount) from
AREFTSandARCUST.
Tables (Files) Used¶
- AREFTS (Input, 100 bytes):
-
Staging file with processed EFT data, including:
AFDEL(delete code, position 1).AFCO(company, positions 2-3).AFCUST(customer, positions 4-9).AFDESC(description, positions 10-39).AFAMT(invoice amount, positions 40-44, packed).AFDISC(discount amount, positions 45-49, packed).AFEAMT(EFT amount, positions 50-54, packed).AFDAT8(8-digit selected date, positions 55-62).AFUPD8(8-digit update date, positions 63-70).
-
ARCUST (Input, 384 bytes, 8-byte key at position 2):
-
Customer master file, including:
ARDEL(delete code, position 1).ARCONO(company, positions 2-3).ARCUST(customer, positions 4-9).ARNAME(name, positions 10-31).AREFT(EFT participant, position 302, 'Y' or 'N').- Address, financial, and other customer details.
-
ARCONT (Input, 256 bytes, 2-byte key at position 2):
-
Company control file, including:
ACDEL(delete code, position 1).ACCO(company, positions 2-3).ACNAME(company name, positions 4-33).- EFT and financial configuration fields.
-
ARCUSP (Input, 1344 bytes, 8-byte key at position 2):
-
Customer-specific data file, including:
CSDEL(delete code, position 1).CSCONO(company, positions 2-3).CSCUST(customer, positions 4-9).CSARTE(bank routing number).CSABK#(bank account number).- Tax codes, exempt numbers, and other customer details.
-
EFTFILE (Output, 94 bytes):
-
NACHA-compliant file with records:
- File Header (
RECTY1): Bank and transmission details. - Batch Header (
RECTY5): Company and batch details. - Entry Detail (
RECTY6): Customer EFT transactions. - Batch Control (
RECTY8): Batch totals. - File Control (
RECTY9): File totals. - Filler Records: Pads to multiple of 10 records.
- File Header (
-
REPORT (Output, 132 bytes):
- Printer file for generating the EFT transaction report.
External Programs Called¶
- None:
- The
AR156program does not call any external programs. It performs all processing internally using the input files and writes to the output file and printer.
Summary¶
The AR156.rpg36 program generates a NACHA-compliant file for EFT withdrawals to PNC Bank, processing data from AREFTS, retrieving customer details from ARCUST and ARCUSP, and company settings from ARCONT. It creates file header, batch header, entry detail, batch control, and file control records, padding the file to meet NACHA’s blocking factor of 10. The program also produces a report via the REPORT file for auditing. It ensures only EFT participants are processed, maintains accurate totals and hashes, and uses dynamic file naming for flexibility. No external programs are called, and the process completes the EFT workflow initiated by the main OCL script.