AR210 RPG36
The provided document, AR210.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 create journal entries for accounts receivable (A/R) transactions (invoices, adjustments, payments, and miscellaneous amounts) in the temporary general ledger file (ARTEMG
) for further processing by the general ledger system. Below, I’ll explain the process steps, business rules, tables used, and external programs called.
Process Steps of the RPG Program (AR210)¶
The AR210
program processes records from the A/R distribution file (ARDIST
), generates debit and credit journal entries for the temporary general ledger file (ARTEMG
), and handles discounts and inter-company transactions. Here’s a step-by-step breakdown:
- Program Initialization:
- Files Defined:
- Input:
ARDIST
(primary input, 161 bytes),ARCONT
(A/R control, 256 bytes, keyed by company, shared access). - Output:
ARTEMG
(temporary general ledger file, 128 bytes).
- Input:
- Data Structures:
UDS
: User data structure with fields for user ID (USERID
), workstation ID (WSID
), sales journal number (SJ##
), ledger retention flag (LDRETL
), and Y2K variables (Y2KCEN
= 19,Y2KCMP
= 80).
-
Initial Setup:
- Clears discount amount (
DISAMT
) and indicator82
(discount < 0). - Executes one-time setup (
ONETIM
) if not already done (N98
).
- Clears discount amount (
-
One-Time Setup (
ONETIM
): - Captures system time (
TIMEOF
). - Chains to
ARCONT
using company code (ADCO
) to retrieve control data (e.g.,ACTRGL
, G/L account for inter-company transactions). - Sets transaction type indicators:
01
(invoice): Sets61
.02
(adjustment): Sets61
.03
(payment): Sets63
.
-
Sets indicator
98
to mark setup completion. -
Main Processing Loop:
- Processes
ARDIST
records sequentially, identified by record type:01
(invoice,CI
).02
(adjustment,CJ
).03
(payment,CP
).
- Adjusts transaction amount (
ADAMT
):- If miscellaneous amount exists (
86
) and not zero (N16
), subtractsADMISC
fromADAMT
(sets81
if negative). - If miscellaneous and zero amount (
16
,86
), setsADAMT
toADMISC
(sets81
if negative).
- If miscellaneous amount exists (
-
Handles discount amount:
- If discount exists (
51
), setsDISAMT
toADDISC
. - If
DISAMT
is negative (82
), multiplies by -1 to make positive.
- If discount exists (
-
Transaction Processing:
- Case Selection:
- If amount is non-negative (
N81
), executesCASE01
(standard debit/credit entries). - If amount is negative (
81
), executesCASE02
(reversed debit/credit entries). - If company codes differ (
ADCODR ≠ ADCO
orADCOCR ≠ ADCO
, indicator54
), executesCASE03
(inter-company entries) and adjustsADAMT
if negative.
- If amount is non-negative (
-
Discount Processing:
- If discount exists (
51
), setsADCODR
toADCODI
(cash invoice company) and executesGLDISC
to create a discount journal entry. - Adds
DISAMT
to debit total (DBTOT
, ifN82
) or credit total (CRTOT
, if82
).
- If discount exists (
-
Standard Entries (
CASE01
): - For payments (
63
):- If discount non-negative (
N82
), debit amount =ADAMT - DISAMT
. - If discount negative (
82
), debit amount =ADAMT + DISAMT
.
- If discount non-negative (
- For invoices/adjustments (
N63
), debit amount =ADAMT
. - Writes debit entry to
ARTEMG
:- Company:
DRCO
(ADCODR
). - Journal:
ADJRNL
. - Type:
D
(debit). - Account:
DRACCT
(ADGLDR
). - Customer:
ADNAME
. - Invoice:
ADINV#
. - Date:
ADJRDT
. - Amount:
DRAMT
. - Description:
ADDESC
.
- Company:
- Sets indicator
30
, writes, then clears30
. - Adds
DRAMT
toDBTOT
. -
Writes credit entry:
- Company:
CRCO
(ADCOCR
). - Journal:
ADJRNL
. - Type:
C
(credit). - Account:
CRACCT
(ADGLCR
). - Amount:
CRAMT
(ADAMT
). - Sets indicator
31
, writes, then clears31
. - Adds
CRAMT
toCRTOT
.
- Company:
-
Negative Amount Entries (
CASE02
): - Writes debit entry:
- Amount:
DRAMT
=-ADAMT
. - Account:
DRACCT
(ADGLCR
). - Company:
DRCO
(ADCOCR
). - Type:
D
. - Sets indicator
32
, writes, then clears32
. - Adds
DRAMT
toDBTOT
.
- Amount:
-
Writes credit entry:
- For payments (
63
): - If discount non-negative (
N82
),CRAMT
=-ADAMT + DISAMT
. - If discount negative (
82
),CRAMT
=-ADAMT - DISAMT
. - For invoices/adjustments (
N63
),CRAMT
=-ADAMT
. - Account:
CRACCT
(ADGLDR
). - Company:
CRCO
(ADCODR
). - Type:
C
. - Sets indicator
33
, writes, then clears33
. - Adds
CRAMT
toCRTOT
.
- For payments (
-
Inter-Company Entries (
CASE03
): -
Writes two entries to
ARTEMG
:- Credit Entry:
- Amount:
ICRAMT
=ADAMT ± DISAMT
(subtract ifN82
, add if82
). - Company:
ICRCO
(ADCODR
). - Account:
ICRGL8
(ACTRGL
+ADCOCR
). - Type:
C
ifN81
,D
if81
. - Debit Entry:
- Amount:
IDRAMT
=ADAMT ± DISAMT
. - Company:
IDRCO
(ADCOCR
). - Account:
IDRGL8
(ACTRGL
+ADCODR
). - Type:
D
ifN81
,C
if81
. - Both entries include
ADJRNL
,ADNAME
,ADINV#
,ADJRDT
,ADDESC
. - Sets indicator
34
, writes, then clears34
.
-
Discount Entry (
GLDISC
): - Writes discount entry to
ARTEMG
:- Company:
ADCODI
. - Journal:
ADJRNL
. - Type:
D
ifN82
,C
if82
. - Account:
ADGLDI
. - Amount:
DISC11
(DISAMT
). - Customer:
ADNAME
. - Invoice:
ADINV#
. - Date:
ADJRDT
. - Description:
ADDESC
.
- Company:
- Sets indicator
35
, writes, then clears35
.
Business Rules¶
- Transaction Types:
- Invoices (
01
,CI
) and adjustments (02
,CJ
): Generate debit (ADGLDR
) and credit (ADGLCR
) entries. - Payments (
03
,CP
): Generate debit and credit entries, adjusted for discounts. -
Miscellaneous amounts (
86
): AdjustADAMT
by subtractingADMISC
(if non-zero) or setting toADMISC
(if zero). -
Discount Handling:
- Discounts (
ADDISC
, indicator51
) are recorded as separate entries withADCODI
(company) andADGLDI
(account). - Negative discounts (
82
) are converted to positive for journal entries. -
Discounts adjust debit/credit amounts in payment entries.
-
Inter-Company Transactions:
- If company codes differ (
ADCODR ≠ ADCO
orADCOCR ≠ ADCO
,54
), generates entries using inter-company G/L account (ACTRGL
) fromARCONT
. -
Debit and credit types are swapped based on amount sign (
81
). -
Amount Sign Handling:
- Positive amounts (
N81
): Standard debit/credit entries. -
Negative amounts (
81
): Reverses debit/credit accounts and adjusts amounts. -
Journal Entry Structure:
- Entries include company, journal number, debit/credit type, G/L account, customer name, invoice number, journal date, amount, and description.
-
Description field (
ADDESC
) retains full 25 characters from cash receipts, with date moved to the second description field inARTEMG
(per 4/20/05 change). -
Accumulation:
-
Tracks debit (
DBTOT
) and credit (CRTOT
) totals for balancing. -
Y2K Compliance:
- Uses
Y2KCEN
(19) andY2KCMP
(80) for date handling, though no explicit date conversion occurs in this program (dates are pre-converted inAR200
).
Tables Used¶
The program uses the following files (tables):
1. Input Files:
- ARDIST
(F-spec 0007): A/R distribution file (161 bytes, primary input) from AR200
(?9?ARDIGG
).
- ARCONT
(0009): A/R control file (256 bytes, input mode, keyed by company, shared access).
- Output Files:
-
ARTEMG
(0008): Temporary general ledger file (128 bytes, output mode) for journal entries (?9?ARTGGG
). -
Compile-Time Data:
- None defined.
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 system time and control file access.
- CASE01
: Processes standard debit/credit entries for non-negative amounts.
- CASE02
: Processes reversed debit/credit entries for negative amounts.
- CASE03
: Handles inter-company entries.
- GLDISC
: Creates discount journal entries.
Notes¶
- Modification (4/20/05): Enhanced description field handling to retain 25 characters from cash receipts, with the date moved to the second description field in
ARTEMG
. - Indicators:
16
: Zero amount.51
: Non-zero discount.52
: Non-zero G/L credit account.53
: Non-zero G/L debit account.61
: Invoice or adjustment.63
: Payment.81
: Negative amount.82
: Negative discount.86
: Non-zero miscellaneous amount.- File Access:
ARCONT
is shared (DISP-SHR
) for concurrent access. - Output:
ARTEMG
entries are formatted for sorting and posting byAR211
.
If you have additional details (e.g., source for AR211
or file layouts), I can provide further analysis. Let me know if you need clarification or more information!