Skip to content

AR110 RPG36

The AR110.rpg36.txt program is an RPG II program (with System/36 syntax) designed for editing and validating individual cash receipts transactions in an accounts receivable (AR) system. It is invoked by the AR110.ocl36 OCL script, which prepares the environment by sorting transactions, cleaning invalid records, and defining necessary files. The program validates transactions entered via AR100, produces edit reports, and generates Notices of Difference (NODs) for discrepancies. It includes modifications to handle inactive GL accounts as deleted (JB01, 08/24/2016) and to add a total cash received by invoice column (MG02, 06/13/2022). Below, I outline the process steps, business rules, tables (files) used, and external programs called, based on the provided code and context from the OCL script.

Process Steps of the AR110 RPG Program

  1. Initialization:
  2. Program Setup: The program defines files and initializes variables for processing transactions. It uses the NODPRM data structure to hold customer, company, invoice, and sales data for NOD reports.
  3. Key Fields: Initializes fields like ATCO (company number), ATCUST (customer number), ATINV# (invoice number), and others from CRTRAN and CR110S (sorted transaction file).

  4. Read Sorted Transaction File (CR110S):

  5. Reads records from CR110S (sorted by company and sequence number, excluding deleted records and non-payment types, as defined in the OCL sort).
  6. Checks for level breaks (L1, L3, L4) on sequence (ATKEY), customer (ATCUST), and company (ATCO) to control report formatting and totals calculation.

  7. Validate Transaction Data:

  8. Customer Validation:
    • Chains to ARCUST using ATCUST to verify the customer exists and is not deleted (ARDEL <> 'D').
    • Retrieves customer details: name (ARNAME), address (ARADR1ARADR4), salesman number (ARSLS#).
  9. Invoice Validation:
    • Chains to ARDETL using the composite key ATCOCU (company + customer) and ATINV# to verify the invoice exists and is not deleted (ADDEL <> 'D').
    • Retrieves invoice details: amount (ADAMT), partial payment (ADPART), payment (ADPAY), due date (ATDUDT), terms (ATTERM).
  10. GL Account Validation:
    • Chains to GLMAST for credit (ATGLCR), debit (ATGLDR), and discount (if applicable) GL accounts.
    • Checks GLDEL: Treats inactive accounts ('I') the same as deleted ('D') per JB01 update (08/24/2016).
    • If invalid, marks the transaction with an error ('E' in position 54 of CRTRAN).
  11. Check Validation:
    • Chains to CRCHKS using ATCKNO (check number) to retrieve check amount (CRCKAM).
  12. Control File Check:
    • Chains to ARCONT using ATCO to get company name (ACNAME) and default GL accounts (ACARGL, ACCSGL).
  13. System Table Check:

    • Chains to GSTABL for additional configuration data (e.g., table description TBDESC).
  14. Error Handling:

  15. If validation fails (e.g., invalid customer, invoice, or GL account), updates CRTRAN with an error flag ('E' in position 54) via output operation O CRTRAN D 01.
  16. If valid, clears the error flag (' ' in position 54).

  17. Totals Calculation:

  18. Accumulates totals for reports:
    • TOTAMT: Total transaction amount (ATAMT).
    • TOTDIS: Total discount amount (ATDISC).
    • TOTCAS: Total cash received by invoice (added per MG02, 06/13/2022, calculated from ATAMT + ATDISC).
    • TOTARC: Total AR impact (likely ATAMT - ATDISC).
    • TOTMIS: Total miscellaneous cash (transactions without invoices).
    • NETCHG: Net change to AR (calculated at last record, LR).
  19. Outputs totals at level breaks (L1, L3, L4) or end of job (LR).

  20. Edit Report Generation (PRINT):

  21. Outputs to PRINT (164-byte printer file) with formatted transaction details:
    • Fields: ATCO, ATCUST, ATINV#, ATAMT, ATDISC, ATTYPE, ATDATE, ATGLCR, ATGLDR, ATDESCL2, ATDUDT, ATTERM, ATSLS, ATCOCR, ATCODR, ATNOD.
    • Totals: TOTAMT, TOTDIS, TOTCAS, TOTARC, TOTMIS, NETCHG.
  22. Includes headers, footers, and separators (e.g., '* * *' at LR).

  23. Notice of Difference (NOD) Report (NODLIST):

  24. Generates NOD reports for transactions with discrepancies (ATNOD = 'Y') to NODLIST (164-byte printer file).
  25. Content includes:

    • Company name (ACNAME).
    • Header: "NOTICE OF DIFFERENCE" and "(NOD)".
    • Sales engineer name (SLNAME) and transaction date (ATDATEY).
    • Customer details: number (ATCUST), name (ARNAME), address (ARADR1ARADR4).
    • Ship-to number (PSHIP) and invoice number (ATINV#).
    • Invoice date (INVDATY), check number (ATDESC), check amount (CRCKAMJ).
    • Discrepancy amount (ARBALNJ) with "SHORTPAY" or "OVERPAY" flags.
    • Instructions for approval (sales manager, vice president, president) for adjustments over $2,500.
    • Permanent record notice for the customer credit file.
  26. File Updates:

  27. Updates CRTRAN to mark transactions as valid (' ') or erroneous ('E').
  28. Does not directly update ARDETL or GLMAST but validates against them.

  29. Program Termination:

  30. At last record (LR), outputs final totals and report footers (e.g., "NET CHANGE TO A/R", NETCHG).
  31. Closes files and terminates.

Business Rules

  1. Transaction Validation:
  2. Customers must exist in ARCUST and not be deleted (ARDEL <> 'D').
  3. Invoices must exist in ARDETL and not be deleted (ADDEL <> 'D').
  4. GL accounts (ATGLCR, ATGLDR) must exist in GLMAST, not deleted (GLDEL <> 'D'), and not inactive (GLDEL <> 'I') per JB01.
  5. Invalid transactions are flagged with 'E' in CRTRAN.

  6. Transaction Type:

  7. Processes only payment transactions (ATTYPE = 'P', enforced by OCL sort).
  8. Miscellaneous cash (no invoice) is identified and included in TOTMIS.

  9. Notice of Difference (NOD):

  10. Generated when ATNOD = 'Y' (notification of difference).
  11. Requires discrepancy amount (ARBALNJ) to be classified as "SHORTPAY" or "OVERPAY".
  12. Adjustments over $2,500 require president approval; NODs become permanent records in the customer credit file.
  13. Includes instructions for returning to the AR clerk in Pittsburgh.

  14. Totals Tracking:

  15. Tracks total amount (TOTAMT), discount (TOTDIS), cash received by invoice (TOTCAS, per MG02), AR impact (TOTARC), miscellaneous cash (TOTMIS), and net AR change (NETCHG).
  16. Outputs totals at company, customer, and job-end breaks.

  17. Error Handling:

  18. Invalid data (customer, invoice, GL account) flags transactions for correction.
  19. No direct updates to ARDETL or GLMAST during editing; errors are marked in CRTRAN for later correction.

  20. Atrium Compatibility:

  21. Uses GG suffix for files (CRIEGG, CR10GG, CRICGG) to align with Atrium environment (JB01, 11/28/23).

  22. Multi-User Support:

  23. Files are accessed in shared mode (DISP-SHR or DISP-SHRMM in OCL), allowing concurrent access without locking.

Tables (Files) Used

  1. CR110S:
  2. Type: Input file (IR), disk-based, indexed temporary (IT).
  3. Record Length: 3 bytes (likely a typo in source; should be 256 bytes per CRTRAN).
  4. Usage: Sorted transaction file (from OCL #GSORT), read sequentially for validation.

  5. CRTRAN:

  6. Type: Update file (UP), disk-based.
  7. Record Length: 256 bytes.
  8. Key: 5-byte sequence number (ATKEY, positions 2-6).
  9. Usage: Original transaction file, updated with error flags ('E' or ' ').

  10. ARDETL:

  11. Type: Input file (IF), disk-based.
  12. Record Length: 128 bytes.
  13. Key: 18-byte key (company + customer + invoice).
  14. Usage: Validates invoice details (e.g., ADAMT, ADPAY, ADPART, ATDUDT).

  15. ARCUST:

  16. Type: Input file (IF), disk-based.
  17. Record Length: 384 bytes.
  18. Key: 8-byte customer key.
  19. Usage: Validates customer data (e.g., ARNAME, ARADR1ARADR4, ARSLS#).

  20. GLMAST:

  21. Type: Input file (IF), disk-based.
  22. Record Length: 256 bytes.
  23. Key: 11-byte GL key (company + account).
  24. Usage: Validates GL accounts (ATGLCR, ATGLDR); checks GLDEL.

  25. ARCONT:

  26. Type: Input file (IF), disk-based.
  27. Record Length: 256 bytes.
  28. Key: 2-byte company key.
  29. Usage: Provides company name (ACNAME) and default GL accounts (ACARGL, ACCSGL).

  30. GSTABL:

  31. Type: Input file (IF), disk-based.
  32. Record Length: 256 bytes.
  33. Key: 12-byte key.
  34. Usage: Configuration data (e.g., TBDESC).

  35. CRCHKS:

  36. Type: Input file (IF), disk-based.
  37. Record Length: 96 bytes.
  38. Key: 14-byte key (likely customer + check number).
  39. Usage: Validates check amount (CRCKAM).

  40. PRINT:

  41. Type: Output file (O), printer.
  42. Record Length: 164 bytes.
  43. Usage: Generates edit listing with transaction details and totals.

  44. NODLIST:

    • Type: Output file (O), line printer (LPRINTER).
    • Record Length: 164 bytes.
    • Usage: Prints NOD reports for discrepancies (ATNOD = 'Y').

External Programs Called

The AR110 program does not explicitly call external programs within the provided code, but the OCL script indicates: 1. AR1101: - Implied by the OCL file definitions (GSPROD, NODPRINT), likely called by AR110 for additional processing (e.g., generating further reports). - Purpose: Handles post-validation tasks, possibly updating ledgers or producing detailed outputs.

No other external calls are evident in the RPG code, which focuses on validation and reporting.

Summary

The AR110 program validates individual cash receipts from AR100, ensuring customers, invoices, and GL accounts are valid before posting. It: - Reads sorted transactions (CR110S), validates against master files (ARCUST, ARDETL, GLMAST), and flags errors in CRTRAN. - Generates edit reports (PRINT) with totals (including cash received by invoice per MG02) and NOD reports (NODLIST) for discrepancies requiring approval. - Enforces rules for valid data, inactive GL handling (JB01), and discrepancy documentation. - Integrates with the OCL script for sorted input, file cleanup, and Atrium compatibility.

The program supports a multi-user AR system with shared file access, producing critical validation outputs for the cash receipts workflow.