Skip to content

AR211 RPG36

The provided document, AR211.rpg36.txt, is an RPG III program used in an IBM AS/400 or iSeries environment, called by the OCL script AR201.ocl36.txt. Its primary function is to process sorted journal entries from the temporary general ledger file (ARTEMG and AR211S), summarize them by account number if required, post them to the general ledger temporary file (TEMGEN) and daily transaction file (ARDALY), and print sales and cash receipts journals. Below, I’ll explain the process steps, business rules, tables used, and external programs called.

Process Steps of the RPG Program (AR211)

The AR211 program processes journal entries, accumulates totals, and generates reports for sales (SJ) and cash receipts (CR) journals. Here’s a step-by-step breakdown:

  1. Program Initialization:
  2. Files Defined:
    • Input: ARTEMG (primary input, 128 bytes), AR211S (sorted journal entries, 300 bytes, indexed), GLMAST (G/L master, 256 bytes, keyed, shared), ARCONT (A/R control, 256 bytes, keyed, shared).
    • Output: TEMGEN (G/L temporary file, 128 bytes), ARDALY (daily transaction file, 96 bytes), REPORT (primary journal report, 132 bytes), REPORTP (Indianola copy, 132 bytes).
  3. Data Structures:
    • UDS: User data structure with journal date (JRNLDT), user ID (USERID), workstation ID (WSID), ledger journal type (LDJTYP), journal number (LDJRN#), ledger retention flag (LDRETL), and Y2K variables (Y2KCEN = 19, Y2KCMP = 80).
    • MN: Month names array (January–December) for report formatting.
  4. Subroutines:

    • L4DET: Initializes for each journal date/month.
    • JRNL: Writes journal entries.
    • L4TOT: Writes journal totals.
  5. Detail Processing (L4DET):

  6. Executes at level break L4 (change in journal year GDYR or month GDMO).
  7. Captures system time (TIMEOF) and date (TIMDAT), converts to YMD format (SYSDT8, CCYYMMDD).
  8. Resets page counter (PAGE) to 0.
  9. Applies Y2K compliance to journal year (GDYY):
    • If GDYY >= Y2KCMP (80), sets century (GCN) to Y2KCEN (19); otherwise, increments Y2KCEN by 1.
  10. Chains to ARCONT using company code (GDCO) to retrieve control data (e.g., ACARJ#, ACSLJ#, G/L accounts).
  11. Sets journal type (JRNTYP) and number (JRN#) based on GDJTYP (SJ or CR) and GDJRN#.
  12. Sets indicators 61 (sales journal) or 63 (cash receipts journal).
  13. Writes report header (indicator 11), clears 11.
  14. Resets level 4 totals (L4CR$, L4DB$) to 0.

  15. Main Processing Loop:

  16. Processes ARTEMG records sequentially, with level breaks:
    • L6 (Company Change): Not explicitly handled but triggers L4.
    • L5 (Journal Type/Number Change): Not explicitly handled but triggers L4.
    • L4 (Year/Month Change): Executes L4DET and L4TOT.
    • L3 (Summarization Flag Change): Checks if GDSUMM = 'S' (indicator 20 for summarized entries).
    • L2 (Account Change): Resets level 2 totals (L2CR$, L2DB$, L2TOT$).
    • L1 (Detail Record): Accumulates amount (GDAMT) to L1TOT$.
  17. Converts journal date (GDDATE) to YMD format (CYMD, CCYYMMDD) with Y2K compliance.

  18. Non-Summarized Entries (N20):

  19. Checks if entry is credit (GDCRDB = 'C', indicator 15).
  20. Adds L1TOT$ to L2CR$ (credit) or L2DB$ (debit).
  21. Executes JRNL to write the entry.
  22. Resets L1TOT$, L2CR$, L2DB$, L2TOT$.

  23. Summarized Entries (20):

  24. At L1, accumulates L1TOT$ to L2CR$ (credit, 15) or L2DB$ (debit, N15).
  25. At L2, executes JRNL to write summarized entry.

  26. Journal Entry Writing (JRNL):

  27. Builds G/L key (KEY11 = GDCO + GDACCT + 'C') and chains to GLMAST to retrieve account description (GLDESC).
  28. Calculates net total (L2TOT$ = L2CR$ - L2DB$ if 15, or L2DB$ - L2CR$ if N15).
  29. If non-zero (N40), increments journal sequence (JRNSEQ) and writes to TEMGEN and ARDALY (indicator WRITIT).
  30. Adds L2TOT$ to L4CR$ (credit) or L4DB$ (debit).

  31. Totals Processing (L4TOT):

  32. If records were read (GDCO ≠ 0) and no entries written (JRNSEQ = 0), increments JRNSEQ and writes a journal entry.
  33. Writes journal totals to REPORT and REPORTP with L4DB$ and L4CR$.

  34. Output Operations:

  35. TEMGEN: Writes G/L entries with company (GDCO), account (GDACCT), journal type (JRNTYP), number (JRN#), sequence (JRNSEQ), debit/credit type, description, date, and amount (L2TOT$).
  36. ARDALY: Writes daily transactions with similar fields.
  37. REPORT/REPORTP: Prints sales or cash receipts journal with headers (company, date, time, user ID, journal type), detail lines (journal number, date, description, debit/credit amounts), and totals.

Business Rules

  1. Journal Types:
  2. Sales Journal (SJ, indicator 61): Processes invoices and adjustments.
  3. Cash Receipts Journal (CR, indicator 63): Processes payments and miscellaneous cash.
  4. Determined by GDJTYP from ARTEMG.

  5. Summarization:

  6. If GDSUMM = 'S' (20), accumulates amounts by account (GDACCT) at L2 and writes a single entry.
  7. If N20, writes individual entries without summarization.

  8. Debit/Credit Handling:

  9. Credit entries (GDCRDB = 'C', 15): Accumulate to L2CR$, L4CR$.
  10. Debit entries (N15): Accumulate to L2DB$, L4DB$.
  11. Net total (L2TOT$) determines if entry is written (N40).

  12. Y2K Compliance:

  13. Converts journal date (GDDATE) to CCYYMMDD format (CYMD) using Y2KCEN (19) and Y2KCMP (80).

  14. G/L Validation:

  15. Chains to GLMAST to retrieve account description (GLDESC) for reporting.

  16. Journal Sequence:

  17. Increments JRNSEQ for each non-zero entry or at totals if no entries were written.

  18. Reporting:

  19. Produces two journal reports (REPORT, REPORTP) with headers, detail lines (journal number, date, G/L account, description, debit/credit amounts), and totals.
  20. Includes company name (ACNAME), user ID, workstation ID, and system date/time.

  21. ARCONT Update (Removed):

  22. Per 8/06/14 change, ARCONT is no longer updated (previously updated journal numbers ACARJ#, ACSLJ#).

  23. Description Handling:

  24. Per 4/20/05 change, retains full 25-character description (GDDESC) from cash receipts, with date in the second description field in TEMGEN.

Tables Used

The program uses the following files (tables): 1. Input Files: - ARTEMG (F-spec 0009): Temporary general ledger file (128 bytes, primary input) from AR210 (?9?ARTGGG). - AR211S (0010): Sorted journal entries (300 bytes, indexed, extension of ARTEMG, ?9?AR211S). - GLMAST (0011): General ledger master file (256 bytes, keyed by company/account, shared access, ?9?GLMAST). - ARCONT (0014): A/R control file (256 bytes, keyed by company, shared access, ?9?ARCONT).

  1. Output Files:
  2. TEMGEN (0012): General ledger temporary file (128 bytes, ?9?TEMGEN).
  3. ARDALY (0013): Daily transaction file (96 bytes, ?9?ARDALY).
  4. REPORT (0015): Primary journal report (132 bytes, printer file).
  5. REPORTP (0016): Indianola copy of journal report (132 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: - L4DET: Initializes for journal date/month changes. - JRNL: Writes journal entries to TEMGEN and ARDALY. - L4TOT: Writes journal totals.

Notes

  • Modifications:
  • 4/20/05: Enhanced description field handling to retain 25 characters from cash receipts, with date in second description field in TEMGEN.
  • 8/06/14: Removed ARCONT updates and changed printer names for paperless reporting, with output still printing in Bradford.
  • Indicators:
  • 61: Sales journal.
  • 63: Cash receipts journal.
  • 15: Credit entry.
  • 20: Summarized entry.
  • 40: Non-zero net total.
  • File Access: GLMAST and ARCONT are shared (DISP-SHR) for concurrent access.
  • Output: Reports are formatted for clarity, with separate sections for sales and cash receipts journals.

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