Skip to content

AR211 RPG36

Process Steps of the RPG Program

The AR211 program is an RPG II/III program for the IBM System/36 or AS/400 System/36 Environment, called by the OCL procedure AR200.ocl36.txt as the final step in the cash receipts posting process. It processes sorted journal entries from ARTEMG (generated by AR210), summarizes them by GL account, updates the general ledger master (GLMAST), generates daily AR summaries (ARDALY), and produces sales/cash receipts journal reports. The program uses level breaks (L1–L4) for grouping and summarization, with Y2K-compliant date handling. Note: The source is truncated after line 0132, but based on the provided code, output specs, and context from prior programs, the core logic is inferable (e.g., subroutines like JRNL, L4TOT, WRITIT handle entry writing, totals, and report formatting).

Here's a sequential breakdown of the process steps:

  1. Program Setup and File Definitions:
  2. Header Specifications:
    • H P064: Program identifier (P064 is a control number).
    • Comment (4/20/05): Modified to preserve the full 25-character description (GDDESC) from cash receipts entry, with the journal date moved to the start of the second description field in TEMGEN.
    • Comment (8/06/14): Removed updates to ARCONT (no longer needed); changed printer file names for paperless reporting (still prints in Bradford location).
  3. File Specifications (F Specs):
    • ARTEMG IP F 128 128R I DISK: Primary input file (Input Primary, IP), 128-byte records, keyed by index I (likely from sort in OCL).
    • AR211S IR 300 3 3IT EDISK: Secondary sorted input file (from OCL #GSORT), 300-byte records, indexed by 3-byte key (IT for indexed temporary?).
    • GLMAST IC F 256 256R11AI 2 DISK: GL master file, input with control (IC), keyed by 11-byte key, alternate index (AI).
    • TEMGEN O F 128 128 DISK A: Output temporary GL file, 128-byte records, append mode (A).
    • ARDALY O F 96 96 DISK A: Output daily AR summary file, 96-byte records, append mode.
    • ARCONT IC F 256 256R 2AI 2 DISK: AR control file, input with control, keyed by 2-byte key.
    • REPORT O F 132 132 OF PRINTER: Primary printer file for journals, 132-byte records, overflow indicator (OF).
    • REPORTP O F 132 132 OA PRINTER: Alternate printer file for paperless reports, overflow indicator (OA).
  4. Extension Specifications (E Specs):
    • E AR211S ARTEMG: Links AR211S (sorted input) to ARTEMG fields for processing.
    • E MN 1 12 9: Array for month names (e.g., JANUARY).
  5. Input Specifications (I Specs):

    • ARTEMG: Fields like journal year (GDYR), month (GDMO), company (GDCO), journal type (GDJTYPL5), number (GDJRN#L5), reference (GDREF), CR/DB flag (GDCRDBL1), account (GDACCTL2), transaction (GDTRAN), source (GDSRCE), date (GDDATE), amount (GDAMT), summarize flag (GDSUMML3), description (GDDESC).
    • ARCONT: Company name (ACNAME), journal numbers (ACARJ#, ACSLJ#), GL accounts (AR ACARGL, sales ACSLGL, discount ACDSGL, cash ACCSGL, inter-company ACTRGL).
    • GLMAST: GL key (GLKEY), description (GLDESC).
    • Data structures: GDDATE (composed of month GMO, day GDA, year GDYY), UDS (journal date JRNLDT, user ID USERID, workstation WSID, journal type/number LDJTYP, LDJRN#, Y2K fields Y2KCEN, Y2KCMP).
  6. Level Break Initialization (L4):

  7. At highest level break (L4, change in GDYR or primary sort key):

    • Calls L4DET subroutine to initialize details (see step 3).
    • Compares GDSUMM (summarize flag) to 'S' to set indicator 20 (summarization mode).
  8. Subroutine L4DET (Level 4 Detail Initialization):

  9. Captures system time (TIMEOF, TIMDAT) and converts to 8-digit YMD format (SYSDT8) using Y2K logic.
  10. Resets page counters (PAGE, PAGE1 for reports).
  11. Converts journal year (GDYY) to century-adjusted format (GCN) using Y2KCEN and Y2KCMP.
  12. Chains to ARCONT using GDCO (company) to retrieve control data (e.g., GL accounts, journal numbers).
  13. Determines journal type: Sets indicator 61 for sales journal (GDJTYP = 'SJ'), 63 for cash receipts (GDJTYP = 'CR').
  14. Copies journal type (JRNTYP) and number (JRN#) from input.
  15. Sets indicator 11 (likely for report headers).

  16. Level Break Processing (L2 and L1):

  17. At L2 (change in account or secondary key):
    • Resets accumulators: L2CR$ (credits), L2DB$ (debits), L2TOT$ (total).
  18. At L1 (change in detail or primary detail key):
    • Resets L1TOT$ (line total).
  19. Accumulates L1TOT$ += GDAMT for each record.
  20. Converts transaction date (GDDATE) to YMD format (YMD, CYMD) with century adjustment (CN).

  21. Non-Summarized Processing (Indicator 20 Off):

  22. Loops (DO) for each non-summarized entry:

    • If GDCRDB = 'C' (credit, indicator 15), adds L1TOT$ to L2CR$; else to L2DB$.
    • Calls JRNL subroutine to write the journal entry (see step 6).
    • Resets accumulators (L1TOT$, L2CR$, L2DB$, L2TOT$).
  23. Subroutine JRNL (Write Journal Entry):

  24. (Inferred from truncation and output specs): Formats and writes detail lines to REPORT/REPORTP using WRITIT exception.

    • Outputs journal sequence (JRNSEQ), date (GDDATEY), GL description (GLDESC), account (GDACCT), amount (L2TOT$J formatted), transaction (GDTRAN if non-summarized).
    • Chains to GLMAST using GDACCT for description.
    • Writes to TEMGEN (GL updates) and ARDALY (daily summaries) with fields like company (GDCO), account (GDACCT), type (JRNTYP), number (JRN#), sequence (JRNSEQ), CR/DB flag, source (BILLING or CASH), transaction (GDTRAN), date components (MN,GMO, GDA, GCN, GDYY), amount (L2TOT$).
  25. Summarized Processing (Indicator 20 On):

  26. At L1: If credit (15 on), adds L1TOT$ to L2CR$; else to L2DB$.
  27. At L2: Calls JRNL to write the summarized entry (accumulated totals).
  28. Accumulates grand totals (L4DB$, L4CR$).

  29. Level 4 Totals (L4):

  30. Calls L4TOT subroutine (inferred): Outputs journal totals to reports (e.g., JOURNAL TOTALS, debits L4DB$ J, credits L4CR$ J).

  31. Report Generation:

  32. Headers (Indicator 11):
    • Page headers with company (ACNAME), page number (PAGE/PAGE1), date (UDATE), user (USERID), workstation (WSID), time (TIMEOF).
    • Journal title: ** SALES JOURNAL ** (61 on) or ** CASH RECEIPTS JOURNAL ** (63 on).
    • Detail headers: Columns for reference/source (REFERENCE SOURCE), description, debits/credits (G/L no., amount).
  33. Detail Lines (via WRITIT exception):
    • Journal ID (JRNTYP-JRN#-JRNSEQ), date (GDDATEY), description (GLDESC), account/amount for debit/credit sides, transaction (GDTRAN if non-summarized).
  34. Totals (L4): Grand totals for debits/credits.
  35. Dual output: REPORT (legacy) and REPORTP (paperless, per 8/06/14 change), with separate page counters.

  36. Program Termination:

    • Ends when input (ARTEMG/AR211S) is exhausted.
    • No final ARCONT update (removed per 8/06/14).

Business Rules

The program enforces GL posting and reporting rules for AR-integrated journals:

  1. Journal Types:
  2. Sales Journal (61, 'SJ'): Processes billing-related entries.
  3. Cash Receipts Journal (63, 'CR'): Processes cash receipts, including payments and discounts.

  4. Summarization:

  5. If GDSUMM = 'S' (20 on), accumulates amounts by GL account (GDACCT) before writing (avoids duplicate entries).
  6. Non-summarized (20 off): Writes each entry individually, resetting totals per line.

  7. Debit/Credit Handling:

  8. Credits (GDCRDB = 'C', 15 on): Accumulate to L2CR$.
  9. Debits: Accumulate to L2DB$.
  10. Ensures balanced journals (debits = credits via totals).

  11. Date and Y2K Compliance:

  12. Converts dates (GDDATE, GDYY) to century-adjusted YMD (CYMD, GCN) using Y2KCEN (e.g., 19/20) and Y2KCMP (e.g., 80 for 1980+).
  13. Formats dates for reports (e.g., MN,GMO for month name, day, century-year).

  14. GL and AR Updates:

  15. Writes to TEMGEN for GL postings (account GDACCT, amount L2TOT$, CR/DB flag).
  16. Writes to ARDALY for daily summaries (company, account, journal details, date, amount).
  17. Chains to GLMAST for account descriptions (GLDESC); no updates to GL balances here (likely in another program).
  18. Removed ARCONT updates (8/06/14), as journal numbers are no longer tracked there.

  19. Reporting:

  20. Generates detailed journals with headers, details, and totals.
  21. Supports paperless output (REPORTP) alongside legacy (REPORT).
  22. Includes audit fields: User (USERID), workstation (WSID), system date/time (SYSDT8, TIMEOF).

  23. Error Handling and Flow:

  24. Level breaks ensure proper grouping (e.g., by year L4, account L2).
  25. Assumes sorted input (from OCL #GSORT); unsorted data would break logic.
  26. Balances via accumulators (L1TOT$, L2CR$/DB$, L4CR$/DB$).

Tables Used

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

  1. Input Files:
  2. ARTEMG (?9?CRTGGG): Temporary GL journal entries (primary, 128 bytes, from AR210).
  3. AR211S (?9?AR211S): Sorted journal input (secondary, 300 bytes, from OCL sort).
  4. GLMAST (?9?GLMAST): GL master (input/control, 256 bytes, keyed, for descriptions).
  5. ARCONT (?9?ARCONT): AR control (input/control, 256 bytes, keyed, for company/GL accounts).

  6. Output Files:

  7. TEMGEN (?9?TEMGEN): Temporary GL postings (128 bytes, append).
  8. ARDALY (?9?ARDALY): Daily AR summaries (96 bytes, append).

  9. Printer Files:

  10. REPORT/REPORTP: Journal reports (132 bytes, with overflow control).

External Programs Called

The AR211 program does not explicitly call external programs (no CALL operations). All logic is handled internally via subroutines: - Subroutines (inferred/complete from code): L4DET (initialization), JRNL (journal writing), L4TOT (totals), WRITIT (report exception output). - No External Calls: Self-contained; relies on pre-sorted input from OCL.


Integration with OCL and Other Programs

  • OCL Context: Called after #GSORT sorts CRTGGG into AR211S. Uses journal date from AR200P (via UDS).
  • Parameters: Inherits ?9? for file labels (e.g., GGCRTGGG).
  • Flow: Finalizes GL postings (TEMGEN) and daily summaries (ARDALY); reports route to ARPOST/TESTOUTQ per OCL. Followed by GSDELETE, AR2011, and cleanup.
  • Changes: 8/06/14 removal of ARCONT updates simplifies end-of-job; paperless support enhances reporting.

If the full source (post-truncation) or related files (e.g., TEMGEN layout) are available, I can refine subroutine details. Let me know for further analysis!