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:
- Program Setup and File Definitions:
- 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 inTEMGEN. - Comment (8/06/14): Removed updates to
ARCONT(no longer needed); changed printer file names for paperless reporting (still prints in Bradford location).
- 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).
- Extension Specifications (E Specs):
E AR211S ARTEMG: LinksAR211S(sorted input) toARTEMGfields for processing.E MN 1 12 9: Array for month names (e.g., JANUARY).
-
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 (ARACARGL, salesACSLGL, discountACDSGL, cashACCSGL, inter-companyACTRGL).GLMAST: GL key (GLKEY), description (GLDESC).- Data structures:
GDDATE(composed of monthGMO, dayGDA, yearGDYY),UDS(journal dateJRNLDT, user IDUSERID, workstationWSID, journal type/numberLDJTYP,LDJRN#, Y2K fieldsY2KCEN,Y2KCMP).
-
Level Break Initialization (L4):
-
At highest level break (L4, change in
GDYRor primary sort key):- Calls
L4DETsubroutine to initialize details (see step 3). - Compares
GDSUMM(summarize flag) to'S'to set indicator 20 (summarization mode).
- Calls
-
Subroutine
L4DET(Level 4 Detail Initialization): - Captures system time (
TIMEOF,TIMDAT) and converts to 8-digit YMD format (SYSDT8) using Y2K logic. - Resets page counters (
PAGE,PAGE1for reports). - Converts journal year (
GDYY) to century-adjusted format (GCN) usingY2KCENandY2KCMP. - Chains to
ARCONTusingGDCO(company) to retrieve control data (e.g., GL accounts, journal numbers). - Determines journal type: Sets indicator 61 for sales journal (
GDJTYP = 'SJ'), 63 for cash receipts (GDJTYP = 'CR'). - Copies journal type (
JRNTYP) and number (JRN#) from input. -
Sets indicator 11 (likely for report headers).
-
Level Break Processing (L2 and L1):
- At L2 (change in account or secondary key):
- Resets accumulators:
L2CR$(credits),L2DB$(debits),L2TOT$(total).
- Resets accumulators:
- At L1 (change in detail or primary detail key):
- Resets
L1TOT$(line total).
- Resets
- Accumulates
L1TOT$ += GDAMTfor each record. -
Converts transaction date (
GDDATE) to YMD format (YMD,CYMD) with century adjustment (CN). -
Non-Summarized Processing (Indicator 20 Off):
-
Loops (
DO) for each non-summarized entry:- If
GDCRDB = 'C'(credit, indicator 15), addsL1TOT$toL2CR$; else toL2DB$. - Calls
JRNLsubroutine to write the journal entry (see step 6). - Resets accumulators (
L1TOT$,L2CR$,L2DB$,L2TOT$).
- If
-
Subroutine
JRNL(Write Journal Entry): -
(Inferred from truncation and output specs): Formats and writes detail lines to
REPORT/REPORTPusingWRITITexception.- Outputs journal sequence (
JRNSEQ), date (GDDATEY), GL description (GLDESC), account (GDACCT), amount (L2TOT$Jformatted), transaction (GDTRANif non-summarized). - Chains to
GLMASTusingGDACCTfor description. - Writes to
TEMGEN(GL updates) andARDALY(daily summaries) with fields like company (GDCO), account (GDACCT), type (JRNTYP), number (JRN#), sequence (JRNSEQ), CR/DB flag, source (BILLINGorCASH), transaction (GDTRAN), date components (MN,GMO,GDA,GCN,GDYY), amount (L2TOT$).
- Outputs journal sequence (
-
Summarized Processing (Indicator 20 On):
- At L1: If credit (15 on), adds
L1TOT$toL2CR$; else toL2DB$. - At L2: Calls
JRNLto write the summarized entry (accumulated totals). -
Accumulates grand totals (
L4DB$,L4CR$). -
Level 4 Totals (L4):
-
Calls
L4TOTsubroutine (inferred): Outputs journal totals to reports (e.g.,JOURNAL TOTALS, debitsL4DB$ J, creditsL4CR$ J). -
Report Generation:
- 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).
- Page headers with company (
- Detail Lines (via
WRITITexception):- Journal ID (
JRNTYP-JRN#-JRNSEQ), date (GDDATEY), description (GLDESC), account/amount for debit/credit sides, transaction (GDTRANif non-summarized).
- Journal ID (
- Totals (L4): Grand totals for debits/credits.
-
Dual output:
REPORT(legacy) andREPORTP(paperless, per 8/06/14 change), with separate page counters. -
Program Termination:
- Ends when input (
ARTEMG/AR211S) is exhausted. - No final
ARCONTupdate (removed per 8/06/14).
- Ends when input (
Business Rules¶
The program enforces GL posting and reporting rules for AR-integrated journals:
- Journal Types:
- Sales Journal (61, 'SJ'): Processes billing-related entries.
-
Cash Receipts Journal (63, 'CR'): Processes cash receipts, including payments and discounts.
-
Summarization:
- If
GDSUMM = 'S'(20 on), accumulates amounts by GL account (GDACCT) before writing (avoids duplicate entries). -
Non-summarized (20 off): Writes each entry individually, resetting totals per line.
-
Debit/Credit Handling:
- Credits (
GDCRDB = 'C', 15 on): Accumulate toL2CR$. - Debits: Accumulate to
L2DB$. -
Ensures balanced journals (debits = credits via totals).
-
Date and Y2K Compliance:
- Converts dates (
GDDATE,GDYY) to century-adjusted YMD (CYMD,GCN) usingY2KCEN(e.g., 19/20) andY2KCMP(e.g., 80 for 1980+). -
Formats dates for reports (e.g.,
MN,GMOfor month name, day, century-year). -
GL and AR Updates:
- Writes to
TEMGENfor GL postings (accountGDACCT, amountL2TOT$, CR/DB flag). - Writes to
ARDALYfor daily summaries (company, account, journal details, date, amount). - Chains to
GLMASTfor account descriptions (GLDESC); no updates to GL balances here (likely in another program). -
Removed
ARCONTupdates (8/06/14), as journal numbers are no longer tracked there. -
Reporting:
- Generates detailed journals with headers, details, and totals.
- Supports paperless output (
REPORTP) alongside legacy (REPORT). -
Includes audit fields: User (
USERID), workstation (WSID), system date/time (SYSDT8,TIMEOF). -
Error Handling and Flow:
- Level breaks ensure proper grouping (e.g., by year L4, account L2).
- Assumes sorted input (from OCL
#GSORT); unsorted data would break logic. - Balances via accumulators (
L1TOT$,L2CR$/DB$,L4CR$/DB$).
Tables Used¶
In RPG, "tables" refer to disk or printer files. The program uses:
- Input Files:
ARTEMG(?9?CRTGGG): Temporary GL journal entries (primary, 128 bytes, fromAR210).AR211S(?9?AR211S): Sorted journal input (secondary, 300 bytes, from OCL sort).GLMAST(?9?GLMAST): GL master (input/control, 256 bytes, keyed, for descriptions).-
ARCONT(?9?ARCONT): AR control (input/control, 256 bytes, keyed, for company/GL accounts). -
Output Files:
TEMGEN(?9?TEMGEN): Temporary GL postings (128 bytes, append).-
ARDALY(?9?ARDALY): Daily AR summaries (96 bytes, append). -
Printer Files:
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
#GSORTsortsCRTGGGintoAR211S. Uses journal date fromAR200P(viaUDS). - Parameters: Inherits
?9?for file labels (e.g.,GGCRTGGG). - Flow: Finalizes GL postings (
TEMGEN) and daily summaries (ARDALY); reports route toARPOST/TESTOUTQper OCL. Followed byGSDELETE,AR2011, and cleanup. - Changes: 8/06/14 removal of
ARCONTupdates 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!