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:
- Program Initialization:
- 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).
- Input:
- 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.
-
Subroutines:
L4DET
: Initializes for each journal date/month.JRNL
: Writes journal entries.L4TOT
: Writes journal totals.
-
Detail Processing (
L4DET
): - Executes at level break
L4
(change in journal yearGDYR
or monthGDMO
). - Captures system time (
TIMEOF
) and date (TIMDAT
), converts to YMD format (SYSDT8
, CCYYMMDD). - Resets page counter (
PAGE
) to 0. - Applies Y2K compliance to journal year (
GDYY
):- If
GDYY >= Y2KCMP (80)
, sets century (GCN
) toY2KCEN (19)
; otherwise, incrementsY2KCEN
by 1.
- If
- Chains to
ARCONT
using company code (GDCO
) to retrieve control data (e.g.,ACARJ#
,ACSLJ#
, G/L accounts). - Sets journal type (
JRNTYP
) and number (JRN#
) based onGDJTYP
(SJ
orCR
) andGDJRN#
. - Sets indicators
61
(sales journal) or63
(cash receipts journal). - Writes report header (indicator
11
), clears11
. -
Resets level 4 totals (
L4CR$
,L4DB$
) to 0. -
Main Processing Loop:
- 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
andL4TOT
. - L3 (Summarization Flag Change): Checks if
GDSUMM = 'S'
(indicator20
for summarized entries). - L2 (Account Change): Resets level 2 totals (
L2CR$
,L2DB$
,L2TOT$
). - L1 (Detail Record): Accumulates amount (
GDAMT
) toL1TOT$
.
- L6 (Company Change): Not explicitly handled but triggers
-
Converts journal date (
GDDATE
) to YMD format (CYMD
, CCYYMMDD) with Y2K compliance. -
Non-Summarized Entries (
N20
): - Checks if entry is credit (
GDCRDB = 'C'
, indicator15
). - Adds
L1TOT$
toL2CR$
(credit) orL2DB$
(debit). - Executes
JRNL
to write the entry. -
Resets
L1TOT$
,L2CR$
,L2DB$
,L2TOT$
. -
Summarized Entries (
20
): - At
L1
, accumulatesL1TOT$
toL2CR$
(credit,15
) orL2DB$
(debit,N15
). -
At
L2
, executesJRNL
to write summarized entry. -
Journal Entry Writing (
JRNL
): - Builds G/L key (
KEY11 = GDCO + GDACCT + 'C'
) and chains toGLMAST
to retrieve account description (GLDESC
). - Calculates net total (
L2TOT$ = L2CR$ - L2DB$
if15
, orL2DB$ - L2CR$
ifN15
). - If non-zero (
N40
), increments journal sequence (JRNSEQ
) and writes toTEMGEN
andARDALY
(indicatorWRITIT
). -
Adds
L2TOT$
toL4CR$
(credit) orL4DB$
(debit). -
Totals Processing (
L4TOT
): - If records were read (
GDCO ≠ 0
) and no entries written (JRNSEQ = 0
), incrementsJRNSEQ
and writes a journal entry. -
Writes journal totals to
REPORT
andREPORTP
withL4DB$
andL4CR$
. -
Output Operations:
- 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$
). - ARDALY: Writes daily transactions with similar fields.
- 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¶
- Journal Types:
- Sales Journal (
SJ
, indicator61
): Processes invoices and adjustments. - Cash Receipts Journal (
CR
, indicator63
): Processes payments and miscellaneous cash. -
Determined by
GDJTYP
fromARTEMG
. -
Summarization:
- If
GDSUMM = 'S'
(20
), accumulates amounts by account (GDACCT
) atL2
and writes a single entry. -
If
N20
, writes individual entries without summarization. -
Debit/Credit Handling:
- Credit entries (
GDCRDB = 'C'
,15
): Accumulate toL2CR$
,L4CR$
. - Debit entries (
N15
): Accumulate toL2DB$
,L4DB$
. -
Net total (
L2TOT$
) determines if entry is written (N40
). -
Y2K Compliance:
-
Converts journal date (
GDDATE
) to CCYYMMDD format (CYMD
) usingY2KCEN
(19) andY2KCMP
(80). -
G/L Validation:
-
Chains to
GLMAST
to retrieve account description (GLDESC
) for reporting. -
Journal Sequence:
-
Increments
JRNSEQ
for each non-zero entry or at totals if no entries were written. -
Reporting:
- Produces two journal reports (
REPORT
,REPORTP
) with headers, detail lines (journal number, date, G/L account, description, debit/credit amounts), and totals. -
Includes company name (
ACNAME
), user ID, workstation ID, and system date/time. -
ARCONT Update (Removed):
-
Per 8/06/14 change,
ARCONT
is no longer updated (previously updated journal numbersACARJ#
,ACSLJ#
). -
Description Handling:
- Per 4/20/05 change, retains full 25-character description (
GDDESC
) from cash receipts, with date in the second description field inTEMGEN
.
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
).
- Output Files:
TEMGEN
(0012): General ledger temporary file (128 bytes,?9?TEMGEN
).ARDALY
(0013): Daily transaction file (96 bytes,?9?ARDALY
).REPORT
(0015): Primary journal report (132 bytes, printer file).-
REPORTP
(0016): Indianola copy of journal report (132 bytes, printer file). -
Compile-Time Data:
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
andARCONT
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!