Skip to content

AR200 RPG36

The provided document is an RPG program named AR200.rpg36.txt, written in RPG II or III for the IBM System/36 or AS/400 System/36 Environment. It is called by the OCL procedure AR200.ocl36.txt as part of the cash receipts posting process in an accounts receivable (AR) system. This program processes sorted transaction records, updates AR files, generates distribution entries, and produces a transaction posting register report. Below, I’ll explain the process steps, business rules, tables used, and external programs called.


Process Steps of the RPG Program

The AR200 program processes cash receipt transactions, updates customer balances, AR details, and history, and generates journal entries for the general ledger (GL). It handles different transaction types (invoices, adjustments, payments, and miscellaneous cash) and produces a detailed report. The program uses a level-break structure (L1, L2, L3) to organize processing by company and transaction type. Here’s a detailed breakdown of the steps:

  1. Program Setup and File Definitions:
  2. Header Specifications:
    • H P064: Program identifier (P064 is a control number).
  3. File Specifications (F Specs):
    • ARTRAN UP F 2560 256 DISK: Input transaction file, update mode (UP), 256-byte records, primary file for processing.
    • ARDETL UC F 128 128R18AI 2 DISK: AR detail file, update with control (UC), keyed by 18-byte key, alternate index (AI), disk.
    • ARCUST UC F 384 384R 8AI 2 DISK: Customer master file, update with control, keyed by 8-byte key, disk.
    • ARCONT UC F 256 256R 2AI 2 DISK: AR control file, update with control, keyed by 2-byte key, disk.
    • ARHIST O F 128 128 DISK: AR history file, output only, 128-byte records.
    • ARDIST O F 161 161 DISK: Distribution file for GL entries, output only, 161-byte records.
    • REPORT O F 164 164 OF PRINTER: Primary printer file for the posting register, 164-byte records, overflow indicator (OF).
    • REPORTP O F 164 164 OA PRINTER: Alternate printer file (likely for paperless reports, per 8/06/14 comment), overflow indicator (OA).
  4. Data Definitions:

    • E AGE 5 9 2: Array for aging customer balances (5 periods, 9 digits, 2 decimals).
    • E MN 1 12 9: Array for month names (e.g., JANUARY, FEBRUARY).
    • UDS (User Data Structure): Contains fields like journal date (JRNLDT, JMO, JDA, JYR), user ID (USERID), workstation ID (WSID), journal type/number (SJTYPE, SJ##), Y2K fields (Y2KCEN, Y2KCMP), etc.
    • Input specifications (I Specs) define fields for ARTRAN (transaction details), ARCUST (customer data), ARDETL (AR details), and ARCONT (control data).
  5. Level Break Initialization (L3):

  6. At company level break (L3, triggered by change in ATCO):

    • Resets accumulators (Z2, ZERO6, ZERO7, ZERO9) to zero.
    • Sets ONE1, ONE2 to 1, PAGE, PAGE2, PAGE4 to 0.
    • Chains to ARCONT using ATCO (company number) to retrieve journal numbers (ACARJ#, ACSLJ#).
    • Sets journal number (AR# = ACARJ#) and sales journal number (SL# = ACSLJ# or SJ## if non-zero).
    • Turns off indicators 05, 06, 91.
  7. Transaction Type Determination:

  8. Subroutine TRNSID (called for each ARTRAN record, indicator 01):
    • Resets indicators (10, 20, 30, 12, 40, 50, 31, 32, 37, 15, 81).
    • Converts transaction date (ATDATE) and due date (ATDUDT) from MMDDYY to YYMMDD (YMD) format for Y2K compliance using Y2KCEN, Y2KCMP.
    • Sets ATDAT8 (8-digit date: CCYYMMDD) for reporting.
  9. Checks inter-company code (ATICCD = 'IC') to set indicator 92, which skips AR updates for inter-company transactions.

  10. Transaction Processing by Type:

  11. Uses level break L1 (transaction level) and L2 (inter-company check).
  12. Resets accumulators (NETCHG, INVAMT, ADJAMT, TOTREC, TOTMIS, TOTINV) at L1.
  13. Processes based on transaction type (ATTYPE, indicators 10, 20, 30):
    • Invoice (10): If indicator 16 (miscellaneous accounts) and 86 (billing flag) are on, calls INVSUM (invoice summary) or ADJUST (adjustment) based on indicator 12.
    • Adjustment (20): Calls ADJUST to process adjustments.
    • Payment (30): Calls PAYMNT (payment processing) if not miscellaneous cash (indicator 80 off), or MISC$$ if miscellaneous cash (80 on).
  14. If indicator 25 is on, jumps to END (terminates processing).

  15. Subroutine ONETIM:

  16. Runs once (indicator 90 off):

    • Captures system time (TIMEOF, TIMDAT) and converts to YYMMDD format (SYSDT8).
    • Converts journal date (JRNLDT) to YMD format (JRNLD8, CCYYMMDD) using Y2K logic.
    • Sets indicator 90 to prevent re-running.
  17. Subroutine INVSUM:

  18. Processes invoice transactions:

    • Updates ARDETL (adds invoice amount to ADAMT).
    • Updates aging array (AGE) based on ADAGE (aging code 1–5).
    • Accumulates totals (INVAMT, TOTINV).
    • Writes to ARHIST for audit trail unless inter-company (92 on).
  19. Subroutine ADJUST:

  20. Processes adjustments:

    • Updates ARDETL (adjusts ADAMT, ADPART, or ADPAY based on ATAMT).
    • Updates aging and customer balances (ARCUST) unless inter-company.
    • Accumulates ADJAMT and NETCHG.
    • Writes to ARHIST.
  21. Subroutine PAYMNT:

  22. Processes payments:

    • Updates ARDETL (reduces ADAMT by payment amount, updates ADPAY).
    • Updates ARCUST (increases ARPYMT, updates ARPDA8 with last cash receipt date).
    • Accumulates TOTREC, TOTDIS (discounts), TOTCAS (cash), TOTARC (AR cash).
    • Writes to ARHIST unless inter-company.
  23. Subroutine MISC$$:

  24. Handles miscellaneous cash transactions:

    • Generates ARDIST entries for GL without updating ARDETL or ARCUST.
    • Accumulates TOTMIS (miscellaneous cash).
    • Writes to ARHIST if needed.
  25. Subroutine FINTOT:

    • At end of level L1 (end of transaction group):
    • Writes final totals to REPORT/REPORTP (totals for invoices, adjustments, payments, net AR change).
    • Updates journal numbers in ARCONT (ACARJ#, ACSLJ#).
  26. Report Generation:

    • Outputs to REPORT and REPORTP (dual outputs for paperless and legacy printing, per 8/06/14 change).
    • Headers include company name (ACNAME), date (UDATE), time (TIMEOF), user/workstation ID, and journal date (JRNLD8).
    • Sections for:
    • Invoices: Customer, invoice number, description, amount, date, reference invoice.
    • Adjustments: Similar, with adjustment-specific fields.
    • Payments: Includes customer, invoice, AR amount, discount, net cash, and flags (e.g., prepay, partial, misc cash).
    • Totals: Summarizes invoices, adjustments, payments, discounts, and net AR change.
    • Uses indicators (e.g., 17 for invoices, 20 for adjustments, 30 for payments) to control output formats.
  27. Program Termination:

    • Reaches END tag when indicator 25 is on or input is exhausted.
    • Updates ARCONT with final journal numbers and exits.

Business Rules

The program enforces standard AR and GL integration rules for cash receipts posting:

  1. Transaction Types:
  2. Invoices (10): Add to AR detail (ARDETL) and customer balances (ARCUST), unless inter-company.
  3. Adjustments (20): Modify AR detail and customer balances (e.g., credit memos, write-offs).
  4. Payments (30): Reduce AR balances, apply discounts, and update last payment dates.
  5. Miscellaneous Cash (80): Generates GL entries without affecting AR files (e.g., non-AR cash).

  6. Inter-Company Transactions:

  7. If ATICCD = 'IC' (indicator 92), skip updates to ARCUST, ARDETL, and ARHIST. Only generate ARDIST entries for GL.

  8. Date Handling:

  9. Converts all dates (transaction, due, journal) to YMD (CCYYMMDD) format for Y2K compliance.
  10. Uses Y2KCEN (century) and Y2KCMP (comparison year) to determine century (e.g., 19 or 20).

  11. File Updates:

  12. Updates ARDETL for invoice amounts, payments, and adjustments.
  13. Updates ARCUST for payment totals (ARPYMT), last payment date (ARPDA8), and aging (AGE).
  14. Writes to ARHIST for audit trail (except inter-company).
  15. Generates ARDIST for GL journal entries (debit/credit accounts: ATGLDR, ATGLCR).
  16. Updates ARCONT with journal numbers (ACARJ#, ACSLJ#).

  17. Reporting:

  18. Produces a detailed transaction posting register with sections for invoices, adjustments, and payments.
  19. Includes totals for invoices (TOTINV), adjustments (ADJAMT), payments (TOTREC, TOTDIS, TOTCAS, TOTARC), and miscellaneous cash (TOTMIS).
  20. Net change to AR (NETCHG) is reported for reconciliation.
  21. Supports paperless output (REPORTP) and legacy printing (REPORT) per 8/06/14 modification.

  22. Error Handling:

  23. Chains to ARCONT to validate company (ATCO); sets indicator 91 if not found.
  24. Uses indicators to control flow (e.g., 92 for inter-company, 80 for misc cash).
  25. Accumulators ensure totals match across files for balancing.

  26. Audit and Control:

  27. Tracks journal numbers (AR#, SL#) for traceability.
  28. Includes user ID (USERID) and workstation ID (WSID) in reports.
  29. Flags like ATNOD (notification of difference) and ATRFIV (reference invoice) are printed for audit.

Tables Used

In RPG, "tables" refer to database or printer files. The program uses:

  1. Input/Update Files:
  2. ARTRAN (?9?CRTRGG): Sorted transaction register (input, 256 bytes).
  3. ARDETL (?9?ARDETL): AR detail/open items, updated (128 bytes, keyed).
  4. ARCUST (?9?ARCUST): Customer master, updated (384 bytes, keyed).
  5. ARCONT (?9?ARCONT): AR control file, updated (256 bytes, keyed).

  6. Output Files:

  7. ARHIST (?9?ARHIST): AR history archive (128 bytes).
  8. ARDIST (?9?CRDIGG): GL distribution entries (161 bytes).
  9. REPORT/REPORTP: Printer files for transaction register (164 bytes).

No additional database queries; all processing is file-based.


External Programs Called

The AR200 program does not explicitly call external programs (no CALL operations). All logic is handled internally via subroutines: - Subroutines: ONETIM, TRNSID, INVSUM, ADJUST, PAYMNT, MISC$$, FINTOT. - No External Calls: The program is self-contained, relying on file inputs from the OCL (AR200.ocl36.txt).


Integration with OCL and AR200P

  • OCL Context: AR200 is called by AR200.ocl36.txt after sorting input files (CRIEGG, CRPSGG) into CRTRGG. It uses the journal date (JRNLDT) from AR200P.rpgle.txt (stored in UDS).
  • Parameters: The ?9? parameter from the OCL (AR200 ,,,,,,,,?9?) sets the library/prefix for file labels (e.g., GGCRTRGG).
  • Flow: After AR200, the OCL calls AR210 to generate GL journals, then AR211 for GL posting, using outputs (CRDIGG, CRTGGG).
  • Switches: If AR200P sets switch bit U1 (cancellation), AR200 may not run (per OCL IF SWITCH1-1 CANCEL). AR200 itself does not set switches explicitly.

Notes

  • Y2K Compliance: Extensive date conversion logic (Y2KCEN, Y2KCMP) ensures correct century handling.
  • Paperless Reporting: The 8/06/14 change by Marty Greenberg modified REPORTP for paperless output, removing duplicate printing for W Conshohocken.
  • Inter-Company Logic: Special handling for ATICCD = 'IC' ensures GL entries without AR updates, supporting multi-entity accounting.
  • Source Length: The document was truncated (33,138 characters omitted), but the provided output specs (O Specs) and logic cover the core functionality. If critical subroutines are in the truncated section, please provide them for a complete analysis.

If you have the full source, additional OCL/RPG programs (e.g., AR210, AR211, AR2011), or file layouts, I can refine the analysis further. Let me know if you need specific details or clarification!