AR300 RPG36
The provided document is an RPG/36 program, AR300.rpg36.txt
, called from the OCL program AR300P.ocl36.txt
. This program generates monthly accounts receivable (A/R) statements and prepares the ARDETL
file for purging. It processes customer and transaction data, calculates finance charges, and produces multiple output reports with different formats. Below, I’ll explain the process steps, business rules, tables/files used, and external programs called.
Process Steps of the AR300 RPG/36 Program¶
- Program Initialization:
- Header Specifications:
H P064
: Program identifier forAR300
.
- File Declarations:
ARDETL UP F 128 128R I DISK
: Accounts receivable detail file, update mode, 128-byte records, indexed.AR300S IR F 30 3 3IT EDISK
: Input file for statement parameters, 30-byte records, indexed, externally described.ARCUST UC 384 384R 8AI 2 DISK
: Customer master file, update mode, 384-byte records, keyed on company/customer number.ARCONT IC F 256 256R 2AI 2 DISK
: A/R control file, input mode, 256-byte records, keyed on company number.BICONT IC F 256 256R 2AI 2 DISK
: Billing control file, input mode, 256-byte records, keyed on company number.REPORT O 132 132 OF LPRINTER
: Primary statement output file, 132 characters, overflow indicatorOF
.REPRT2 O 132 132 OV LPRINTER
: Remittance stub output, overflow indicatorOV
.REPRT3 O 132 132 OA LPRINTER
: Statement copy for saving (e.g., toPITT-FS/SHARED/AR STATEMENTS
), overflow indicatorOA
.REPRT4 O 132 132 OB LPRINTER
: Alternate statement format, overflow indicatorOB
.REPRT5 O 132 132 OC LPRINTER
: Wire transfer statement format, overflow indicatorOC
.
- Arrays and Data Structures:
AGE
: Array of 5 elements (9 digits, 2 decimals) for aging buckets (current, 01-10, 11-20, 21-30, over 30 days).MSG
: Array of 15 elements (70 characters) for auditor’s messages (e.g., “PLEASE EXAMINE THIS STATEMENT CAREFULLY”).UDS
: Data structure for job parameters:KYALCO
(ALL/CO),KYCO1
,KYCO2
,KYCO3
(company numbers),KYJOBQ
(job queue),KYCOPY
(number of copies),KYDATE
(statement date),STMO
,STDAY
,STYR
,DATE4
(date fields).
-
Line Counter Specifications:
LREPORT
,LREPRT2
,LREPRT3
,LREPRT4
,LREPRT5
: Define 66 lines per page, 61 lines before overflow.
-
One-Time Initialization (
ONETIM
Subroutine): - Sets indicator
98
on to mark completion. - Initializes
ZERO9
(9-digit, 0 decimals) to 0 for use in output calculations. -
Executed only if indicator
98
is off (N98
). -
Company Loop (Level Break
L2
): - Control File Access:
- Chains to
ARCONT
usingADCO
(company number fromARDETL
). - If not found (
95
on), skips further processing for the company. - Calculates
LFMO
(last fiscal month) by subtracting 1 fromACFFMO
(first fiscal month). IfLFMO <= 0
, setsLFMO = 12
. - Compares
STMO
(statement month) withLFMO
. If equal, sets92
(last fiscal month indicator). - Chains to
BICONT
usingADCO
. If not found (97
on), sets64
(default invoicing style). - Checks
BCINST
(invoicing style) inBICONT
: 1
: Sets61
(style 1).2
: Sets62
(style 2).5
: Sets63
(style 5, likely wire transfer format).- Other: Sets
64
(default format).
- Chains to
-
Loop Control:
- Continues processing for each company (
DO
atL2
).
- Continues processing for each company (
-
Customer Processing (
ARCUST
Subroutine): - Chains to
ARCUST
usingADCOCU
(company/customer number fromARDETL
). - If not found (
20
on), setsARFIN$
(finance charge) to 0. - Resets
PAGE
to 0 and indicators10
(print statement) and82
(finance charge calculation). - Checks if statements are required (
ARSTMT ≠ 'N'
and indicator11
on) to set10
. - Checks if wire transfer is used (
ARWIRE = 'Y'
) to set49
. - Validates total due (
ARTOTD
) against sum of aging buckets (XFOOT AGE
). If unequal, sets40
. - Calculates finance charge balance (
FCBAL
) by summingAR0110
,AR1120
,AR2130
,AROV30
. -
Sets previous balance (
ARPBAL = ARTOTD
). -
Transaction Processing (
TRANS
Subroutine): - Resets indicators
39
,44
,73
(credit transaction). - Converts
ADDATE
(A/R date, YMD) toADMDY
(MDY) by multiplying by 100.0001. - Determines transaction type (
ADTYPE
):I
: Sets35
(invoice).J
: Sets37
(journal).P
: Sets38
(payment).
- Sets
44
(print transaction line). - If not an invoice (
N35
), skips toNOINV
. - Calculates remaining amount (
ADLEFT = ADAMT - ADPART
). - Adds current month payment (
ADPAY
) to partial payment (ADPART
). - Recalculates remaining amount (
LEFTAR = ADAMT - ADPART
). If equal, sets41
(paid in full). - Checks if
PPINV#
(partial payment invoice) is 9 to set15
(miscellaneous cash). -
Checks
ADAGE
(aging code) for 1 to set13
(past due invoice). -
Finance Charge Calculation (
L1CALC
Subroutine): - Resets indicators
80
,83
,85
. - If finance charges apply (
ARFINC = 'Y'
), sets80
. - Calculates finance charge (
FCAMT = FCBAL * ACFINC
). IfFCAMT > 0
, sets83
. - If
FCAMT < 0.50
, setsFCAMT = 0.50
and85
. - Adds
FCAMT
toARFIN$
and current due (CURPRT = ARCURD + FCAMT
). -
Moves aging amounts to print fields:
AR0110
toX10PRT
,AR1120
toX11PRT
,AR2130
toX21PRT
,AROV30
toX31PRT
,ARTOTD
toTOTPRT
. -
Output Processing:
- Detail Records (
ARDETL
):- For non-invoice transactions (
N35
), writesP
(payment) at position 48. - For invoices (
35
), writesADAMT
,ADPART
,ZERO9
, andP
(paid, if41
) orS
(statement, ifN41
) at position 48.
- For non-invoice transactions (
- Customer Totals (
ARCUST
):- At level break
L1
, if40
(total mismatch) or80
(finance charge), writesARFIN$
andARPBAL
.
- At level break
- REPORT (Primary Statement):
- Prints headers (company address, date, customer info) and transaction details.
- Includes aging totals, finance charges, and “CONTINUED ON NEXT PAGE” if overflow (
OF
).
- REPRT2 (Remittance Stub):
- Prints remittance details (e.g., “REMIT TO: COMM*PLAN DIVISION”).
- REPRT3 (Saved Copy):
- Similar to
REPORT
but includes wire transfer details if63
is on (e.g., PNC Bank info). - Added 6/21/13 for saving to
PITT-FS/SHARED/AR STATEMENTS
.
- Similar to
- REPRT4 (Alternate Format):
- Prints minimal remittance info, used if
64
(default style).
- Prints minimal remittance info, used if
- REPRT5 (Wire Transfer Format):
- Includes bank details (e.g., ABA# 031207607) for wire transfer customers (
63
).
- Includes bank details (e.g., ABA# 031207607) for wire transfer customers (
Business Rules¶
- Statement Generation:
- Statements are printed only if
ARSTMT ≠ 'N'
and total due is non-zero (11
on). - Supports multiple companies (
KYALCO = 'ALL'
or specificKYCO1
,KYCO2
,KYCO3
). - Finance Charges:
- Applied if
ARFINC = 'Y'
inARCUST
. - Calculated as
FCBAL * ACFINC
(fromARCONT
), with a minimum of $0.50. - Added to
ARFIN$
and current due (ARCURD
). - Aging Validation:
- Total due (
ARTOTD
) must equal sum of aging buckets (ARCURD
,AR0110
,AR1120
,AR2130
,AROV30
). - Transaction Processing:
- Supports invoices (
I
), journals (J
), and payments (P
). - Calculates remaining balance (
ADLEFT = ADAMT - ADPART
). - Flags paid-in-full invoices (
ADAMT = ADPART
). - Identifies miscellaneous cash payments (
PPINV# = 9
). - Invoicing Styles:
- Determined by
BCINST
inBICONT
:1
: Style 1 (61
).2
: Style 2 (62
).5
: Wire transfer format (63
).- Other: Default format (
64
).
- Output Formats:
- Multiple reports (
REPORT
,REPRT2
,REPRT3
,REPRT4
,REPRT5
) for different purposes (primary, remittance, saved copy, wire transfer). - Includes auditor’s messages for verification.
- Purge Preparation:
- Updates
ARDETL
with payment status (P
orS
) to facilitate purging of paid records.
Tables/Files Used¶
- ARDETL:
- A/R detail file (128 bytes, indexed, update mode).
- Fields:
ADCO
(company),ADCUST
(customer),ADINV#
(invoice),ADTYPE
(I/J/P),ADDATE
(YMD),ADAMT
(amount),ADAGE
(aging code),ADPART
(partial payment),ADPAY
(current month paid),PPINV#
(partial payment invoice). - AR300S:
- Statement parameter file (30 bytes, indexed, externally described).
- ARCUST:
- Customer master file (384 bytes, keyed on company/customer, update mode).
- Fields:
ARCO
(company),ARCUST
(customer),ARNAME
,ARADR1
–ARADR4
(address),ARTOTD
(total due),ARCURD
,AR0110
,AR1120
,AR2130
,AROV30
(aging),ARPYMT
(last payment),ARSTMT
(statements Y/N),ARFIN$
(finance charge),ARPBAL
(previous balance),ARFINC
(finance charge Y/N),ARM$PD
,ARWIRE
(wire transfer Y/N). - ARCONT:
- A/R control file (256 bytes, keyed on company, input mode).
- Fields:
ACFINC
(finance charge %),ACFFMO
(first fiscal month). - BICONT:
- Billing control file (256 bytes, keyed on company, input mode).
- Field:
BCINST
(invoicing style). - REPORT, REPRT2, REPRT3, REPRT4, REPRT5:
- Printer files (132 characters) for statement outputs.
External Programs Called¶
- None:
- The program does not explicitly call external programs (e.g., via
CALL
). - It is invoked by the OCL program (
AR300P.ocl36.txt
) as theAR300
procedure but does not call other programs itself.
Additional Notes¶
- Purpose: Generates detailed A/R statements with customer, transaction, and aging information, and prepares
ARDETL
for purging by marking paid records. - Output Variants: Multiple printer files support different statement formats, including a saved copy (
REPRT3
) and wire transfer details (REPRT5
). - Integration with OCL: Called as
AR300
in the OCL, using parameters like?9?
for file labels andKY
fields for input. - Modification: Addition of
REPRT5
(6/21/13) for wire transfer format enhances functionality for specific customers.
If you need further analysis or specific details (e.g., output format specifics or purge logic), let me know!