Skip to content

AR300 RPG36

The provided document is an RPG/36 program, AR300.rpg36.txt, called from the OCL program AR300P.ocl36.txt. This program generates monthly accounts receivable (A/R) statements and prepares the ARDETL file for purging. It processes customer and transaction data, calculates finance charges, and produces multiple output reports with different formats. Below, I’ll explain the process steps, business rules, tables/files used, and external programs called.

Process Steps of the AR300 RPG/36 Program

  1. Program Initialization:
  2. Header Specifications:
    • H P064: Program identifier for AR300.
  3. File Declarations:
    • ARDETL UP F 128 128R I DISK: Accounts receivable detail file, update mode, 128-byte records, indexed.
    • AR300S IR F 30 3 3IT EDISK: Input file for statement parameters, 30-byte records, indexed, externally described.
    • ARCUST UC 384 384R 8AI 2 DISK: Customer master file, update mode, 384-byte records, keyed on company/customer number.
    • ARCONT IC F 256 256R 2AI 2 DISK: A/R control file, input mode, 256-byte records, keyed on company number.
    • BICONT IC F 256 256R 2AI 2 DISK: Billing control file, input mode, 256-byte records, keyed on company number.
    • REPORT O 132 132 OF LPRINTER: Primary statement output file, 132 characters, overflow indicator OF.
    • REPRT2 O 132 132 OV LPRINTER: Remittance stub output, overflow indicator OV.
    • REPRT3 O 132 132 OA LPRINTER: Statement copy for saving (e.g., to PITT-FS/SHARED/AR STATEMENTS), overflow indicator OA.
    • REPRT4 O 132 132 OB LPRINTER: Alternate statement format, overflow indicator OB.
    • REPRT5 O 132 132 OC LPRINTER: Wire transfer statement format, overflow indicator OC.
  4. Arrays and Data Structures:
    • AGE: Array of 5 elements (9 digits, 2 decimals) for aging buckets (current, 01-10, 11-20, 21-30, over 30 days).
    • MSG: Array of 15 elements (70 characters) for auditor’s messages (e.g., “PLEASE EXAMINE THIS STATEMENT CAREFULLY”).
    • UDS: Data structure for job parameters:
    • KYALCO (ALL/CO), KYCO1, KYCO2, KYCO3 (company numbers), KYJOBQ (job queue), KYCOPY (number of copies), KYDATE (statement date), STMO, STDAY, STYR, DATE4 (date fields).
  5. Line Counter Specifications:

    • LREPORT, LREPRT2, LREPRT3, LREPRT4, LREPRT5: Define 66 lines per page, 61 lines before overflow.
  6. One-Time Initialization (ONETIM Subroutine):

  7. Sets indicator 98 on to mark completion.
  8. Initializes ZERO9 (9-digit, 0 decimals) to 0 for use in output calculations.
  9. Executed only if indicator 98 is off (N98).

  10. Company Loop (Level Break L2):

  11. Control File Access:
    • Chains to ARCONT using ADCO (company number from ARDETL).
    • If not found (95 on), skips further processing for the company.
    • Calculates LFMO (last fiscal month) by subtracting 1 from ACFFMO (first fiscal month). If LFMO <= 0, sets LFMO = 12.
    • Compares STMO (statement month) with LFMO. If equal, sets 92 (last fiscal month indicator).
    • Chains to BICONT using ADCO. If not found (97 on), sets 64 (default invoicing style).
    • Checks BCINST (invoicing style) in BICONT:
    • 1: Sets 61 (style 1).
    • 2: Sets 62 (style 2).
    • 5: Sets 63 (style 5, likely wire transfer format).
    • Other: Sets 64 (default format).
  12. Loop Control:

    • Continues processing for each company (DO at L2).
  13. Customer Processing (ARCUST Subroutine):

  14. Chains to ARCUST using ADCOCU (company/customer number from ARDETL).
  15. If not found (20 on), sets ARFIN$ (finance charge) to 0.
  16. Resets PAGE to 0 and indicators 10 (print statement) and 82 (finance charge calculation).
  17. Checks if statements are required (ARSTMT ≠ 'N' and indicator 11 on) to set 10.
  18. Checks if wire transfer is used (ARWIRE = 'Y') to set 49.
  19. Validates total due (ARTOTD) against sum of aging buckets (XFOOT AGE). If unequal, sets 40.
  20. Calculates finance charge balance (FCBAL) by summing AR0110, AR1120, AR2130, AROV30.
  21. Sets previous balance (ARPBAL = ARTOTD).

  22. Transaction Processing (TRANS Subroutine):

  23. Resets indicators 39, 44, 73 (credit transaction).
  24. Converts ADDATE (A/R date, YMD) to ADMDY (MDY) by multiplying by 100.0001.
  25. Determines transaction type (ADTYPE):
    • I: Sets 35 (invoice).
    • J: Sets 37 (journal).
    • P: Sets 38 (payment).
  26. Sets 44 (print transaction line).
  27. If not an invoice (N35), skips to NOINV.
  28. Calculates remaining amount (ADLEFT = ADAMT - ADPART).
  29. Adds current month payment (ADPAY) to partial payment (ADPART).
  30. Recalculates remaining amount (LEFTAR = ADAMT - ADPART). If equal, sets 41 (paid in full).
  31. Checks if PPINV# (partial payment invoice) is 9 to set 15 (miscellaneous cash).
  32. Checks ADAGE (aging code) for 1 to set 13 (past due invoice).

  33. Finance Charge Calculation (L1CALC Subroutine):

  34. Resets indicators 80, 83, 85.
  35. If finance charges apply (ARFINC = 'Y'), sets 80.
  36. Calculates finance charge (FCAMT = FCBAL * ACFINC). If FCAMT > 0, sets 83.
  37. If FCAMT < 0.50, sets FCAMT = 0.50 and 85.
  38. Adds FCAMT to ARFIN$ and current due (CURPRT = ARCURD + FCAMT).
  39. Moves aging amounts to print fields: AR0110 to X10PRT, AR1120 to X11PRT, AR2130 to X21PRT, AROV30 to X31PRT, ARTOTD to TOTPRT.

  40. Output Processing:

  41. Detail Records (ARDETL):
    • For non-invoice transactions (N35), writes P (payment) at position 48.
    • For invoices (35), writes ADAMT, ADPART, ZERO9, and P (paid, if 41) or S (statement, if N41) at position 48.
  42. Customer Totals (ARCUST):
    • At level break L1, if 40 (total mismatch) or 80 (finance charge), writes ARFIN$ and ARPBAL.
  43. REPORT (Primary Statement):
    • Prints headers (company address, date, customer info) and transaction details.
    • Includes aging totals, finance charges, and “CONTINUED ON NEXT PAGE” if overflow (OF).
  44. REPRT2 (Remittance Stub):
    • Prints remittance details (e.g., “REMIT TO: COMM*PLAN DIVISION”).
  45. REPRT3 (Saved Copy):
    • Similar to REPORT but includes wire transfer details if 63 is on (e.g., PNC Bank info).
    • Added 6/21/13 for saving to PITT-FS/SHARED/AR STATEMENTS.
  46. REPRT4 (Alternate Format):
    • Prints minimal remittance info, used if 64 (default style).
  47. REPRT5 (Wire Transfer Format):
    • Includes bank details (e.g., ABA# 031207607) for wire transfer customers (63).

Business Rules

  1. Statement Generation:
  2. Statements are printed only if ARSTMT ≠ 'N' and total due is non-zero (11 on).
  3. Supports multiple companies (KYALCO = 'ALL' or specific KYCO1, KYCO2, KYCO3).
  4. Finance Charges:
  5. Applied if ARFINC = 'Y' in ARCUST.
  6. Calculated as FCBAL * ACFINC (from ARCONT), with a minimum of $0.50.
  7. Added to ARFIN$ and current due (ARCURD).
  8. Aging Validation:
  9. Total due (ARTOTD) must equal sum of aging buckets (ARCURD, AR0110, AR1120, AR2130, AROV30).
  10. Transaction Processing:
  11. Supports invoices (I), journals (J), and payments (P).
  12. Calculates remaining balance (ADLEFT = ADAMT - ADPART).
  13. Flags paid-in-full invoices (ADAMT = ADPART).
  14. Identifies miscellaneous cash payments (PPINV# = 9).
  15. Invoicing Styles:
  16. Determined by BCINST in BICONT:
    • 1: Style 1 (61).
    • 2: Style 2 (62).
    • 5: Wire transfer format (63).
    • Other: Default format (64).
  17. Output Formats:
  18. Multiple reports (REPORT, REPRT2, REPRT3, REPRT4, REPRT5) for different purposes (primary, remittance, saved copy, wire transfer).
  19. Includes auditor’s messages for verification.
  20. Purge Preparation:
  21. Updates ARDETL with payment status (P or S) to facilitate purging of paid records.

Tables/Files Used

  1. ARDETL:
  2. A/R detail file (128 bytes, indexed, update mode).
  3. Fields: ADCO (company), ADCUST (customer), ADINV# (invoice), ADTYPE (I/J/P), ADDATE (YMD), ADAMT (amount), ADAGE (aging code), ADPART (partial payment), ADPAY (current month paid), PPINV# (partial payment invoice).
  4. AR300S:
  5. Statement parameter file (30 bytes, indexed, externally described).
  6. ARCUST:
  7. Customer master file (384 bytes, keyed on company/customer, update mode).
  8. Fields: ARCO (company), ARCUST (customer), ARNAME, ARADR1ARADR4 (address), ARTOTD (total due), ARCURD, AR0110, AR1120, AR2130, AROV30 (aging), ARPYMT (last payment), ARSTMT (statements Y/N), ARFIN$ (finance charge), ARPBAL (previous balance), ARFINC (finance charge Y/N), ARM$PD, ARWIRE (wire transfer Y/N).
  9. ARCONT:
  10. A/R control file (256 bytes, keyed on company, input mode).
  11. Fields: ACFINC (finance charge %), ACFFMO (first fiscal month).
  12. BICONT:
  13. Billing control file (256 bytes, keyed on company, input mode).
  14. Field: BCINST (invoicing style).
  15. REPORT, REPRT2, REPRT3, REPRT4, REPRT5:
  16. Printer files (132 characters) for statement outputs.

External Programs Called

  • None:
  • The program does not explicitly call external programs (e.g., via CALL).
  • It is invoked by the OCL program (AR300P.ocl36.txt) as the AR300 procedure but does not call other programs itself.

Additional Notes

  • Purpose: Generates detailed A/R statements with customer, transaction, and aging information, and prepares ARDETL for purging by marking paid records.
  • Output Variants: Multiple printer files support different statement formats, including a saved copy (REPRT3) and wire transfer details (REPRT5).
  • Integration with OCL: Called as AR300 in the OCL, using parameters like ?9? for file labels and KY fields for input.
  • Modification: Addition of REPRT5 (6/21/13) for wire transfer format enhances functionality for specific customers.

If you need further analysis or specific details (e.g., output format specifics or purge logic), let me know!