Skip to content

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:

  1. Program Initialization:
  2. Header Specifications:
    • H P064 B AR745: Specifies program identifier and type (batch).
  3. File Declarations:
    • FARDETL IP F 128 128 DISK: Primary input file for accounts receivable details (sorted by AR745.ocl36.txt into AR745S).
    • 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.
  4. 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).
  5. 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.
  6. Initial Setup (ONCE):

  7. ONCE IFEQ *ZERO:

    • Executes on first cycle:
    • Captures system time (SYTMDT) and date (SYSDTE, SYSTME).
    • Chains to ARCONT using ADCO (company number from ARDETL) to validate company.
    • Outputs report headers (PRTHD2, PRTHD3) to LIST2 and LIST3.
    • Initializes accumulators (LRIAMT, LRDAMT, LREAMT, SEQ#, ZERO9, ZERO7) to zero.
    • Sets ONCE to 1 to prevent re-execution.
    • Resets indicator 10.
  8. Report Header Output:

  9. Outputs headers based on overflow indicators:

    • OF EXCPTPRTHDR: For LIST (rarely used).
    • OB EXCPTPRTHD1: For LIST1 (detailed report headers).
    • OA EXCPTPRTHD2: For LIST2 (summary report headers).
    • OC EXCPTPRTHD3: For LIST3 (detailed report headers).
  10. Level Break Initialization (L2):

  11. At company break (L2):

    • Resets company-level accumulators (L2IAMT, L2DAMT, L2EAMT) to zero.
    • Clears indicator 11.
  12. Level Break Initialization (L1):

  13. At customer break (L1):

    • Resets customer-level accumulators (ADWRK1, INVAMT, INVAM9, EFTAMT, L1IAMT, L1DAMT, L1EAMT) to zero.
  14. Customer Validation:

  15. Chains to ARCUST using CUSKEY (company and customer number from ARDETL).
  16. If found (N99) and AREFT = 'Y' (EFT participant):

    • Proceeds to process the record (calls subroutines DSDT and CALEFT, though DSDT is commented out).
  17. EFT Calculation (CALEFT Subroutine):

  18. 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) to LIST1 (detail report) and AREFTD (EFT disk file).
    • Writes customer totals (PRTL2T) to LIST1, LIST2, and LIST3.
    • Writes grand totals (PRTLRT) to LIST2 and LIST3.
  19. Report Output:

  20. Detailed Report (LIST1, LIST3):
    • Headers include company name, date range (KYFRDT to KYTODT), 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).
  21. 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.
  22. 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).

Business Rules

  1. Data Selection:
  2. Processes only non-deleted records (ADDEL ≠ 'C') from ARDETL.
  3. Requires matching company number (ADCO = KYCO1).
  4. Includes only invoice types 'I' (ADTYPE).
  5. Filters by transaction date (ADTYM8) within KFCYMD to KTCYMD.
  6. Processes all customers or a specific customer based on KYCUST (set in OCL).
  7. Requires AREFT = 'Y' for EFT eligibility.

  8. EFT Processing:

  9. Calculates invoice, discount, and EFT amounts for each customer.
  10. Accumulates totals at customer and company levels.
  11. Writes EFT data to AREFTD for bank upload, including G/L codes and dates.

  12. Report Formatting:

  13. Detailed report (LIST3) includes sequence numbers and invoice details.
  14. Summary report (LIST2) omits sequence and invoice numbers.
  15. Both reports include customer, company, and date information, with totals.
  16. Printer output uses 10 CPI, 6 LPI, and EFT forms (per OCL).

  17. Y2K Compliance:

  18. Uses Y2KCEN and Y2KCMP to handle century in date fields (ADTXCN, ADDUCN).
  19. Formats dates as MM/DD/YY for display and CYYMMDD for processing.

  20. Error Handling:

  21. Validates company (ARCONT) and customer (ARCUST) existence.
  22. Outputs error messages (e.g., "INVALID COMPANY #") if validation fails (though not directly used in this program).

Tables (Files) Used

  1. ARDETL:
  2. Type: Primary input (disk)
  3. Record Length: 128 bytes
  4. Fields: ADDEL (delete flag), ADCO (company), ADCUST (customer), ADINV# (invoice), ADTYPE (type), ADTYM8 (transaction date), ADDUD8 (due date), ADAMT (amount), ADDSAL (discount).
  5. Purpose: Sorted accounts receivable details (from AR745S).

  6. ARCUST:

  7. Type: Input (disk)
  8. Record Length: 384 bytes
  9. Key: Company and customer number (8 bytes)
  10. Fields: ARDEL (delete), ARCO (company), ARCUST (customer), ARNAME (name), AREFT (EFT flag), ARTERM (terms).
  11. Purpose: Customer master data for validation and reporting.

  12. ARCONT:

  13. Type: Input (disk)
  14. Record Length: 256 bytes
  15. Key: Company number (2 bytes)
  16. Fields: ACDEL (delete), ACCO (company), ACNAME (name), ACARGL (A/R G/L), ACCSGL (cash G/L), ACDSGL (discount G/L).
  17. Purpose: Accounts receivable control data.

  18. LIST:

  19. Type: Printer output
  20. Record Length: 120 bytes
  21. Purpose: Minimal use (header output).

  22. LIST1:

  23. Type: Printer output
  24. Record Length: 120 bytes
  25. Purpose: Detailed report headers and lines.

  26. LIST2:

  27. Type: Printer output
  28. Record Length: 164 bytes
  29. Purpose: Summary report.

  30. LIST3:

  31. Type: Printer output
  32. Record Length: 164 bytes
  33. Purpose: Detailed report with sequence numbers.

  34. AREFTD:

  35. Type: Output (disk)
  36. Record Length: 256 bytes
  37. Key: Sequence number (5 bytes)
  38. Fields: SEQ#, ADCO, ADCUST, ADINV#, INVAM9, ADDSA7, dates, G/L codes.
  39. 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 AR745A separately 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!