AR745 RPG36
The provided document, AR745.rpg36.txt, is an RPG III program invoked by the OCL script AR745.ocl36.txt to generate an Electronic Funds Transfer (EFT) Customer Accounts Receivable Due Report. Below, I’ll explain the process steps, business rules, tables (files) used, and external programs called, ensuring clarity and conciseness while adhering to the provided guidelines. The explanation integrates context from the OCL script and the main program flow.
Process Steps of the RPG Program¶
The AR745 RPG program processes sorted accounts receivable data to produce detailed and summary EFT reports, writing output to printer files and a disk file for EFT processing. The steps are as follows:
- Program Initialization:
- Header Specifications:
H P064 B AR745: Specifies program identifier and type (batch).
- File Declarations:
FARDETL IP F 128 128 DISK: Primary input file for accounts receivable details (sorted byAR745.ocl36.txtintoAR745S).FARCUST IC F 384 384R 8AI 2 DISK: Customer master file, keyed by company and customer number.FARCONT IC F 256 256R 2AI 2 DISK: Accounts receivable control file, keyed by company number.FLIST O F 120 120 OF PRINTER: Printer file for initial output (not heavily used).FLIST1 O F 120 120 OB PRINTER: Printer file for detailed report headers and lines.FLIST2 O F 164 164 OA PRINTER: Printer file for summary report.FLIST3 O F 164 164 OC PRINTER: Printer file for detailed report.FAREFTD O F 256 256 5AI 2 DISK: Output disk file for EFT data, keyed by sequence number.
- Data Structures:
MSG: Array of 9 error messages (e.g., "INVALID COMPANY #").HD: Array of 3 heading lines for reports (e.g., "ELECTRONIC FUNDS TRANSFER NOTIFICATION").UDS: Data structure for job control fields (e.g.,KYCO1,KYFRDT,KYTODT,KYSEDT,KFCYMD,KTCYMD,KSCYMD,KYUPDT,Y2KCEN,Y2KCMP).
-
Indicators:
L1,L2: Level indicators for customer (L1) and company (L2) breaks.51FL,45OL: Control printer overflow and forms alignment.10,11,22: Used for conditional logic and output control.
-
Initial Setup (ONCE):
-
ONCE IFEQ *ZERO:- Executes on first cycle:
- Captures system time (
SYTMDT) and date (SYSDTE,SYSTME). - Chains to
ARCONTusingADCO(company number fromARDETL) to validate company. - Outputs report headers (
PRTHD2,PRTHD3) toLIST2andLIST3. - Initializes accumulators (
LRIAMT,LRDAMT,LREAMT,SEQ#,ZERO9,ZERO7) to zero. - Sets
ONCEto 1 to prevent re-execution. - Resets indicator
10.
-
Report Header Output:
-
Outputs headers based on overflow indicators:
OF EXCPTPRTHDR: ForLIST(rarely used).OB EXCPTPRTHD1: ForLIST1(detailed report headers).OA EXCPTPRTHD2: ForLIST2(summary report headers).OC EXCPTPRTHD3: ForLIST3(detailed report headers).
-
Level Break Initialization (L2):
-
At company break (
L2):- Resets company-level accumulators (
L2IAMT,L2DAMT,L2EAMT) to zero. - Clears indicator
11.
- Resets company-level accumulators (
-
Level Break Initialization (L1):
-
At customer break (
L1):- Resets customer-level accumulators (
ADWRK1,INVAMT,INVAM9,EFTAMT,L1IAMT,L1DAMT,L1EAMT) to zero.
- Resets customer-level accumulators (
-
Customer Validation:
- Chains to
ARCUSTusingCUSKEY(company and customer number fromARDETL). -
If found (
N99) andAREFT = 'Y'(EFT participant):- Proceeds to process the record (calls subroutines
DSDTandCALEFT, thoughDSDTis commented out).
- Proceeds to process the record (calls subroutines
-
EFT Calculation (CALEFT Subroutine):
-
Calculates EFT amounts and writes output (assumed from context, as code is truncated):
- Accumulates invoice amounts (
INVAMT), discounts (ADDSAL), and EFT amounts (EFTAMT) at customer (L1) and company (L2) levels. - Writes detail lines (
PRTDTL) toLIST1(detail report) andAREFTD(EFT disk file). - Writes customer totals (
PRTL2T) toLIST1,LIST2, andLIST3. - Writes grand totals (
PRTLRT) toLIST2andLIST3.
- Accumulates invoice amounts (
-
Report Output:
- Detailed Report (
LIST1,LIST3):- Headers include company name, date range (
KYFRDTtoKYTODT), upload date (KYUPDT), run date/time (SYSDTE,SYSTME). - Detail lines show customer number (
ADCUST), name (ARNAME), ship date (ADTXMM/DD/YY), discount date (DISMD/CY), settlement date (KSMM/DD/YY), invoice number (ADINV#), invoice amount (INVAMT), discount amount (ADDSAL), and EFT amount (EFTAMT). - Totals at customer (
L2IAMT,L2DAMT,L2EAMT) and grand total levels (LRIAMT,LRDAMT,LREAMT).
- Headers include company name, date range (
- Summary Report (
LIST2):- Similar headers but labeled "S U M M A R Y".
- Detail lines omit invoice and sequence numbers, focusing on customer and totals.
- EFT Disk File (
AREFTD):- Writes records with sequence number (
SEQ#), company (ADCO), customer (ADCUST), invoice (ADINV#), amounts (INVAM9,ADDSA7), dates, and G/L codes (ACARGL,ACCSGL,ACDSGL).
- Writes records with sequence number (
Business Rules¶
- Data Selection:
- Processes only non-deleted records (
ADDEL ≠ 'C') fromARDETL. - Requires matching company number (
ADCO = KYCO1). - Includes only invoice types 'I' (
ADTYPE). - Filters by transaction date (
ADTYM8) withinKFCYMDtoKTCYMD. - Processes all customers or a specific customer based on
KYCUST(set in OCL). -
Requires
AREFT = 'Y'for EFT eligibility. -
EFT Processing:
- Calculates invoice, discount, and EFT amounts for each customer.
- Accumulates totals at customer and company levels.
-
Writes EFT data to
AREFTDfor bank upload, including G/L codes and dates. -
Report Formatting:
- Detailed report (
LIST3) includes sequence numbers and invoice details. - Summary report (
LIST2) omits sequence and invoice numbers. - Both reports include customer, company, and date information, with totals.
-
Printer output uses 10 CPI, 6 LPI, and EFT forms (per OCL).
-
Y2K Compliance:
- Uses
Y2KCENandY2KCMPto handle century in date fields (ADTXCN,ADDUCN). -
Formats dates as MM/DD/YY for display and CYYMMDD for processing.
-
Error Handling:
- Validates company (
ARCONT) and customer (ARCUST) existence. - Outputs error messages (e.g., "INVALID COMPANY #") if validation fails (though not directly used in this program).
Tables (Files) Used¶
- ARDETL:
- Type: Primary input (disk)
- Record Length: 128 bytes
- Fields:
ADDEL(delete flag),ADCO(company),ADCUST(customer),ADINV#(invoice),ADTYPE(type),ADTYM8(transaction date),ADDUD8(due date),ADAMT(amount),ADDSAL(discount). -
Purpose: Sorted accounts receivable details (from
AR745S). -
ARCUST:
- Type: Input (disk)
- Record Length: 384 bytes
- Key: Company and customer number (8 bytes)
- Fields:
ARDEL(delete),ARCO(company),ARCUST(customer),ARNAME(name),AREFT(EFT flag),ARTERM(terms). -
Purpose: Customer master data for validation and reporting.
-
ARCONT:
- Type: Input (disk)
- Record Length: 256 bytes
- Key: Company number (2 bytes)
- Fields:
ACDEL(delete),ACCO(company),ACNAME(name),ACARGL(A/R G/L),ACCSGL(cash G/L),ACDSGL(discount G/L). -
Purpose: Accounts receivable control data.
-
LIST:
- Type: Printer output
- Record Length: 120 bytes
-
Purpose: Minimal use (header output).
-
LIST1:
- Type: Printer output
- Record Length: 120 bytes
-
Purpose: Detailed report headers and lines.
-
LIST2:
- Type: Printer output
- Record Length: 164 bytes
-
Purpose: Summary report.
-
LIST3:
- Type: Printer output
- Record Length: 164 bytes
-
Purpose: Detailed report with sequence numbers.
-
AREFTD:
- Type: Output (disk)
- Record Length: 256 bytes
- Key: Sequence number (5 bytes)
- Fields:
SEQ#,ADCO,ADCUST,ADINV#,INVAM9,ADDSA7, dates, G/L codes. - Purpose: EFT data for bank upload.
External Programs Called¶
- None:
- The RPG program does not explicitly call external programs (e.g., via
CALL). - The OCL script invokes
AR745Aseparately for credit invoice checks and emailing, but this is not part of the RPG program itself.
Summary¶
The AR745 RPG program, called by AR745.ocl36.txt, generates detailed and summary EFT reports from sorted accounts receivable data (AR745S). It validates company and customer data, calculates EFT amounts, and writes output to printer files (LIST1, LIST2, LIST3) and a disk file (AREFTD) for bank upload. The program enforces strict data filtering, Y2K date handling, and formatted reporting.
Business Rules:
- Filters non-deleted, EFT-eligible records within date ranges.
- Accumulates and reports invoice, discount, and EFT amounts.
- Supports detailed and summary report formats.
- Writes EFT data to AREFTD with G/L codes.
Tables Used:
- ARDETL (input)
- ARCUST (input)
- ARCONT (input)
- LIST, LIST1, LIST2, LIST3 (printer output)
- AREFTD (output disk)
External Programs: - None (called directly by OCL).
If you need further details (e.g., the truncated CALEFT subroutine, integration with AR745A, or specific field formats), let me know!