Skip to content

AR200 RPG36

The provided document, AR200.rpg36.txt, is an RPG III program used in an IBM AS/400 or iSeries environment, called by the OCL script AR201.ocl36.txt. It processes accounts receivable (A/R) transactions, updates customer and detail files, generates journal entries, and prints a transaction posting register. Below, I’ll explain the process steps, business rules, tables used, and external programs called.

Process Steps of the RPG Program (AR200)

The AR200 program processes A/R transactions (invoices, adjustments, payments, and miscellaneous cash) from a sorted transaction file, updates relevant files, and produces a detailed posting register. Here’s a step-by-step breakdown:

  1. Program Initialization:
  2. Files Defined:
    • Input: ARTRAN (transactions), ARDETL (A/R details), ARCUST (customer master), ARCONT (A/R control).
    • Output: ARHIST (A/R history), ARDIST (distribution for journal entries), REPORT (primary posting register), REPORTP (Pittsburgh copy).
  3. Data Structures:
    • UDS: User data structure for journal date (JRNLDT, positions 100–105), user ID (USERID), workstation ID (WSID), journal type (SJTYPE), journal number (SJ##), and Y2K variables (Y2KCEN, Y2KCMP).
    • AGE: Array for aged customer balances (5 periods, 9.2 format).
    • MN: Month names array (January–December).
  4. Initialization (Level L3):

    • Clears accumulators (Z2, ZERO6, ZERO7, ZERO9) and sets constants (ONE1, ONE2).
    • Initializes page counters (PAGE, PAGE2, PAGE4) to 0.
    • Chains to ARCONT by company (ATCO) to retrieve journal numbers (ACARJ#, ACSLJ#). If found (N91), sets AR# and SL#; if SJ## is non-zero, uses it for SL#.
    • Clears indicators 05, 06.
  5. Main Processing Loop:

  6. Processes ARTRAN records sequentially, controlled by level breaks (L1, L2, L3):
    • L3 (Company Change): Resets accumulators and retrieves journal numbers.
    • L2 (Inter-Company Change): Checks if ATICCD = 'IC' (indicator 92 for inter-company customers).
    • L1 (Transaction Type Change): Resets transaction accumulators (NETCHG, INVAMT, ADJAMT, TOTREC, TOTMIS, TOTINV) and clears indicators 71, 72, 73.
  7. Executes one-time setup (ONETIM) if not already done (N90).

  8. One-Time Setup (ONETIM):

  9. Captures system time (TIMEOF) and date (TIMDAT).
  10. Converts journal date (JRNLDT) to YMD format (JYMD) with Y2K compliance:
    • If JYR >= Y2KCMP (80), uses Y2KCEN (19); otherwise, increments Y2KCEN by 1.
    • Builds 8-digit date (JRNLD8) in CCYYMMDD format.
  11. Converts system date to YMD (SYSDT8) for reporting.
  12. Sets indicator 90 to mark setup completion.

  13. Transaction Type Determination (TRNSID):

  14. Clears indicators for transaction types (10, 20, 30, 40, 50, 31, 32, 37, 15, 81, 12).
  15. Converts transaction date (ATDATE) and due date (ATDUDT) to YMD format (ATDAT8, ATDUD8) with Y2K compliance.
  16. Compares invoice date to journal date if LDRETL = 'R' (sets indicator 65 if different).
  17. Identifies transaction type:
    • ATCOD = 'Y' sets indicator 25 (COD invoice).
    • ATTYPE = 'I' sets 10 (invoice).
    • ATTYPE = 'J' sets 20 (adjustment).
    • ATTYPE = 'P' sets 30 (payment).
  18. Sets journal type (JRNTYP): SJ for invoices/adjustments, CR for payments.
  19. For COD invoices (25), skips further processing (GOTO ENDTR).

  20. Transaction Processing:

  21. Invoice (10):
    • If miscellaneous billing (16 and 86), sets indicators 15, 17, clears 10.
    • If not already an adjustment (N12), executes INVSUM.
    • If an adjustment (12), executes ADJUST.
  22. Adjustment (20):
    • Executes ADJUST.
  23. Payment (30):
    • If not miscellaneous (N80), executes PAYMNT.
    • If miscellaneous (80), executes MISC$$.
  24. Inter-Company Check:
    • If ATICCD = 'IC' (92), skips updates to ARCUST, ARDETL, ARHIST (only generates journal entries).
  25. Checks ARDETL for existing invoice (KEY18 = ATCOCU + ATINV# + 'I00'):
    • If found (39) and payment (30 or 20), executes PPDADD and loops back (GOTO AGNX).
    • If not found or invoice (10), proceeds to UNIQUE.
  26. Sets adjustment flag (12) if invoice starts with 9 (ATINV1 = '9', indicator 31).

  27. Invoice Summary (INVSUM):

  28. Increments invoice count (TOTINV).
  29. Adds transaction amount (ATAMT) to INVAMT.
  30. Chains to ARCUST by ATCOCU:
    • If found (N99), updates aged balance (AGE,P), total due (ARTOTD), month-to-date (ARMTD$), year-to-date (ARYTD$).
    • Sets indicator 40 for customer update.
  31. Writes to ARDETL and ARHIST (see output specs).

  32. Prepaid Invoice Add (PPDADD):

  33. Creates an empty invoice record for prepaid transactions (indicator 61).
  34. Writes to ARDETL and ARHIST with zero amounts.

  35. Adjustment Processing (ADJUST):

  36. Chains to ARCUST by ATCOCU:
    • If not found or exists (N39, N99), sets indicators 40, 50.
    • Updates AGE,P, ARTOTD, ARMTD$, ARYTD$.
  37. Updates ARDETL:
    • Subtracts ATAMT from current month paid (ADPAY).
    • Increments next sequence number (ADNEXT).
    • Adds sales amount (ATDSAL to ADDSAL).
    • Updates notification of difference (ADNOD) and reference invoice (ADRFIV) if blank/zero.
  38. Writes to ARDETL and ARHIST (indicator 60).
  39. Increments TOTINV, adds ATAMT to ADJAMT.

  40. Payment Processing (PAYMNT):

  41. Chains to ARCUST by ATCOCU:
    • If not found or exists (N39, N99), updates AGE,P, ARTOTD, month-to-date paid (ARM$PD), year-to-date paid (ARY$PD), payment amount (ARPYMT), payment date (ARPDAT, ARPDA8).
  42. Updates ARDETL:
    • Increments ADNEXT, adds ATAMT to ADPAY, updates ADNOD, ADRFIV.
  43. Writes to ARDETL and ARHIST (indicator 60).
  44. Increments TOTINV, accumulates totals:
    • TOTREC (received), TOTDIS (discount), ATCASH (net cash = ATAMT - ATDISC), TOTCAS (total cash), TOTARC (A/R cash).
  45. Compares ATAMT to remaining balance (ARLEFT, sets 32, 37).

  46. Miscellaneous Cash (MISC$$):

    • If finance charge (ATDSFC = 'FIN CHG'), chains to ARCUST and subtracts ATAMT from finance charges (ARFIN$).
    • Adds ATAMT to TOTCAS (total cash) and TOTMIS (miscellaneous cash).
    • Sets ATCASH to ATAMT.
  47. Final Totals (FINTOT):

    • Calculates net change to A/R (NETCHG = INVAMT + ADJAMT - TOTREC).
    • Writes final totals to REPORT and REPORTP.
  48. Output Operations:

    • ARDIST: Writes journal entries for invoices (I), adjustments (J), payments (P), COD invoices (I), including customer, amount, G/L accounts, and dates.
    • ARTRAN: Marks processed transactions with P (position 54).
    • ARCUST: Updates customer balances, payment info, and aged amounts (indicator 40).
    • ARDETL: Adds/updates invoice, adjustment, payment, or prepaid records.
    • ARHIST: Logs transaction history for invoices, adjustments, payments, and prepaids.
    • ARCONT: Updates journal numbers (ACARJ#, ACSLJ#) at company level break (L3).
    • REPORT/REPORTP: Prints posting register with headers, invoice, adjustment, payment details, and totals.

Business Rules

  1. Transaction Types:
  2. Invoices (ATTYPE = 'I'): Update customer balances, A/R details, and history; generate sales journal (SJ) entries.
  3. Adjustments (ATTYPE = 'J'): Adjust customer balances and A/R details; generate SJ entries.
  4. Payments (ATTYPE = 'P'): Reduce customer balances, update payment info, and generate cash receipts (CR) entries.
  5. COD Invoices (ATCOD = 'Y'): Skip standard processing, generate journal entries only.
  6. Miscellaneous Cash (80): If finance charge (FIN CHG), reduce ARFIN$; otherwise, record as miscellaneous cash.

  7. Inter-Company Customers (ATICCD = 'IC'):

  8. Do not update ARCUST, ARDETL, or ARHIST; only generate journal entries in ARDIST.

  9. Date Handling:

  10. Converts transaction and due dates to YMD format (CCYYMMDD) with Y2K compliance (Y2KCEN, Y2KCMP).
  11. Compares invoice date to journal date if LDRETL = 'R' to flag discrepancies (indicator 65).

  12. Journal Numbers:

  13. Increments ACSLJ# for invoices/adjustments (10 or 20, indicator 05) if SJ## is zero.
  14. Increments ACARJ# for payments (30, indicator 06).
  15. Updates ARCONT with new journal numbers at company level break.

  16. Customer Updates:

  17. Updates ARCUST for non-inter-company transactions: aged balances (AGE), total due (ARTOTD), payment info (ARPYMT, ARPDAT), and period totals (ARMTD$, ARYTD$, ARM$PD, ARY$PD).
  18. Reduces finance charges (ARFIN$) for miscellaneous cash payments.

  19. A/R Detail Updates:

  20. Adds new records for invoices, adjustments, payments, or prepaids.
  21. Updates existing records with payments (ADPAY), sequence numbers (ADNEXT), sales amounts (ADDSAL), notification of difference (ADNOD), and reference invoice (ADRFIV).

  22. History Logging:

  23. Records all transactions (except inter-company) in ARHIST with details like company, customer, invoice, amount, and dates.

  24. Reporting:

  25. Produces two copies of the posting register (REPORT, REPORTP) with sections for invoices, adjustments, and payments, including totals for A/R applied, discounts, cash, and net change.
  26. Includes headers with company name, date, time, user ID, workstation ID, and journal date.

  27. Prepaid Invoices:

  28. Creates empty invoice records in ARDETL and ARHIST for prepaid transactions with zero amounts.

  29. Error Handling:

    • Chains to ARCUST and ARDETL to validate customer and invoice existence.
    • Uses indicators (39, 99, 50) to handle missing or existing records.

Tables Used

The program uses the following files (tables): 1. Input Files: - ARTRAN (F-spec 0014): Transaction file (256 bytes, update mode), sorted input from ?9?AR201S. - ARDETL (0015): A/R detail file (128 bytes, update mode, keyed by company/customer/invoice, shared access). - ARCUST (0016): Customer master file (384 bytes, update mode, keyed by company/customer, shared access). - ARCONT (0017): A/R control file (256 bytes, update mode, keyed by company, shared access).

  1. Output Files:
  2. ARHIST (0018): A/R history file (128 bytes, output mode).
  3. ARDIST (0019): Distribution file (161 bytes, output mode) for journal entries.
  4. REPORT (0020): Primary transaction posting register (164 bytes, printer file).
  5. REPORTP (0021): Pittsburgh copy of the register (164 bytes, printer file).

  6. Compile-Time Data:

  7. MN: Month names array (January–December) for report formatting.

External Programs Called

The program does not explicitly call external programs using CALL operations. All processing is handled internally via subroutines: - ONETIM: One-time setup for dates and system info. - TRNSID: Determines transaction type and converts dates. - INVSUM: Processes invoice summaries. - PPDADD: Adds prepaid invoice records. - ADJUST: Processes adjustments. - PAYMNT: Processes payments. - MISC$$: Handles miscellaneous cash. - FINTOT: Calculates final totals.

Notes

  • Y2K Compliance: Uses Y2KCEN (19) and Y2KCMP (80) to handle century in dates, ensuring CCYYMMDD format.
  • Inter-Company Logic: Explicitly skips A/R updates for ATICCD = 'IC', focusing on journal entries.
  • Modifications:
  • 4/20/05: Enhanced description field handling for cash receipts in TEMGEN.
  • 8/06/14: Changed printer names for paperless reporting, removed W. Conshohocken copy.
  • Journal Types: SJ (sales journal) for invoices/adjustments, CR (cash receipts) for payments.
  • File Access: Shared access (DISP-SHR) for ARDETL, ARCUST, ARCONT allows concurrent processing.

If you have additional details (e.g., source for AR210, AR211, or file layouts), I can provide further analysis. Let me know if you need clarification or more information!