AR136 RPG36
The provided RPG program, AR136.rpg36.txt, is an RPG III program executed on IBM midrange systems (e.g., AS/400 or IBM i) and is called by the OCL program AR136.ocl36.txt as part of an Accounts Receivable (AR) Electronic Funds Transfer (EFT) process. This program generates an EFT Customer Accounts Receivable Due Report, which lists transactions for EFT customers, including invoice amounts, discounts, and EFT amounts. Below, I will explain the process steps, business rules, tables/files used, and external programs called, integrating its context with the main OCL (AR136P.ocl36.txt) and RPG (AR136P.rpgle.txt) programs.
Process Steps of the RPG Program¶
The RPG program AR136 reads transaction, customer, and control files to produce a printed report detailing EFT transactions. Here’s a step-by-step breakdown of its execution:
- Program Initialization:
-
File Specifications:
1 2 3 4
FCRTRAN IP F 256 256 DISK FARCUST IC F 384 384R 8AI 2 DISK FARCONT IC F 256 256R 2AI 2 DISK FLIST O F 164 164 OF PRINTERCRTRAN: Primary input file (256 bytes), containing EFT transaction data.ARCUST: Input file (384 bytes, keyed starting at position 8), containing customer master data.ARCONT: Input file (256 bytes, keyed starting at position 2), containing AR control data.LIST: Output printer file (164 bytes), used to generate the EFT report.
-
Array Definition:
1E HD 1 3 60 PRINTER HEADINGS- Defines an array
HDwith 3 elements (60 characters each) for report headings, loaded from compile-time data at the end of the source.
- Defines an array
-
Data Area Definitions:
1 2 3 4 5 6 7
I UDS I 101 1020KYCO I 103 1080KYSLDT I 109 109 STATUS I 110 1150KYUPDT I 509 5100Y2KCEN I 511 5120Y2KCMP- Defines a data area (
UDS) with fields: KYCO(101-102): Company number.KYSLDT(103-108): Selected date.STATUS(109): Status flag.KYUPDT(110-115): Bank upload date.Y2KCEN(509-510): Y2K century.Y2KCMP(511-512): Y2K company.
- Defines a data area (
-
One-Time Initialization:
1 2 3 4 5 6 7 8 9 10 11 12 13
C ONCE IFEQ *ZERO B1 C TIME SYTMDT 120 C MOVELSYTMDT SYSTME 60 C MOVE SYTMDT SYSDTE 60 C ATCO CHAINARCONT 99 C EXCPTPRTHD3 C Z-ADD1 ONCE 10 C Z-ADD*ZEROS LRIAMT 102 C Z-ADD*ZEROS LRDAMT 102 C Z-ADD*ZEROS LREAMT 102 C Z-ADD*ZEROS SEQ# 50 C Z-ADD*ZEROS ZERO9 90 C END E1 - Checks if
ONCEis zero (indicating first execution). - Retrieves the system time (
SYTMDT) and moves it toSYSTME(time) andSYSDTE(date) for report headers. - Chains to
ARCONTusingATCO(company number fromCRTRAN, mapped toKYCO) to retrieve company details. - Prints the report header (
PRTHD3). - Sets
ONCEto 1 to prevent re-execution. -
Initializes accumulators (
LRIAMT,LRDAMT,LREAMT) for invoice, discount, and EFT amounts, andSEQ#andZERO9to zero. -
Clear Overflow Indicator:
1 2
C SETOF 10 C OF EXCPTPRTHD3 - Clears indicator 10.
-
If the overflow indicator (
OF) is on (indicating a page break), prints the report header (PRTHD3). -
Main Processing Loop:
1 2 3 4 5 6 7 8
C 01 DO C ATKEY CHAINARCUST 99 C ATAMT SUB ATDISC EFTAMT 102 C ADD ATAMT LRIAMT C ADD ATDISC LRDAMT C ADD EFTAMT LREAMT C EXCPTPRTDTL C END - Processes each record in
CRTRAN(indicator 01 indicates input primary processing). - Chains to
ARCUSTusingATKEY(company + customer number fromCRTRAN) to retrieve customer details. - Calculates
EFTAMTasATAMT(transaction amount) minusATDISC(discount amount). - Accumulates totals:
LRIAMT+=ATAMT(total invoice amount).LRDAMT+=ATDISC(total discount amount).LREAMT+=EFTAMT(total EFT amount).
- Prints a detail line (
PRTDTL) for each transaction. -
Continues until all
CRTRANrecords are processed. -
Print Report Totals:
1C EXCPTPRTLRT -
After the main loop, prints the report totals (
PRTLRT), including accumulated totals (LRIAMT,LRDAMT,LREAMT). -
Output Specifications:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
OLIST E 103 PRTHD3 O ACNAME 30 O 34 'D E T A I L ' O HD,1 95 O 117 'BANK UPLOAD DATE:' O KYUPDT 128 '0 / / ' O E 1 PRTHD3 O 9 'ARMENU #8' O 117 'RUN DATE:' O SYSDTEY 128 O SYSTME 138 '0 : : ' O E 1 PRTHD3 O 65 'SETTLEMENT' O 87 'INVOICE' O 102 'DISCOUNT' O 117 'EFT' O E 1 PRTHD3 O 9 'SEQ#' O 16 'CUST#' O 32 'NAME' O 25 'CUSTOMER' O 63 'DATE' O 73 'INV#' O 87 'AMOUNT' O 102 'AMOUNT' O 117 'AMOUNT' O E 2 PRTHD3 O 9 '-----' O 16 '------' O 41 '------------------------' O 65 '----------' O 73 '-------' O 88 '--------------' O 103 '--------------' O 118 '--------------' O E 1 PRTDTL O ATSEQ# 9 O ATCUSTZ 16 O ARNAME 47 O KYSEDTY 63 O ATINV#Z 73 O ATAMT K 88 O ATDISCK 103 O EFTAMTK 118 O E 1 PRTLRT O 88 '--------------' O 103 '--------------' O 118 '--------------' O E 1 PRTLRT O LRIAMTK 88 O LRDAMTK 103 O LREAMTK 118 - Header (
PRTHD3):- Prints company name (
ACNAME), heading text (“D E T A I L”), and compile-time headings (HD,1). - Includes bank upload date (
KYUPDT), program identifier (“ARMENU #8”), run date (SYSDTEY), and time (SYSTME). - Prints column headers: “SEQ#”, “CUST#”, “CUSTOMER NAME”, “SETTLEMENT DATE”, “INV#”, “INVOICE AMOUNT”, “DISCOUNT AMOUNT”, “EFT AMOUNT”.
- Prints company name (
- Detail (
PRTDTL):- Prints transaction details: sequence number (
ATSEQ#), customer number (ATCUSTZ), customer name (ARNAME), settlement date (KYSEDTY), invoice number (ATINV#Z), invoice amount (ATAMT), discount amount (ATDISC), and EFT amount (EFTAMT).
- Prints transaction details: sequence number (
- Totals (
PRTLRT):- Prints lines and accumulated totals for invoice (
LRIAMT), discount (LRDAMT), and EFT (LREAMT) amounts.
- Prints lines and accumulated totals for invoice (
Business Rules¶
The program enforces the following business rules for generating the EFT report:
1. Transaction Processing:
- Processes all records in CRTRAN for the specified company (KYCO) and bank upload date (KYUPDT), which are validated by AR136P.rpgle.txt.
- Only transactions marked as EFT-eligible (likely based on AREFT = 'Y' in ARCUST) are included.
- Customer Validation:
- Each transaction’s company and customer number (
ATKEY) are validated againstARCUSTto retrieve customer details (e.g.,ARNAME). -
If no matching customer record is found (indicator 99 on), the transaction is still processed, but customer details may be blank.
-
EFT Amount Calculation:
-
Calculates the EFT amount (
EFTAMT) as the transaction amount (ATAMT) minus the discount amount (ATDISC) for each transaction. -
Report Formatting:
- The report includes:
- A header with company name, bank upload date, run date/time, and column headers.
- Detail lines for each transaction, showing sequence number, customer number, customer name, settlement date, invoice number, and amounts.
- Totals for invoice, discount, and EFT amounts at the end.
-
Headings include static text from compile-time data, such as contact information for questions about the draft.
-
Company Validation:
-
The company number (
ATCO, mapped toKYCO) is validated againstARCONTduring initialization to retrieve company details (e.g.,ACNAME). -
Data Integrity:
- Accumulates totals (
LRIAMT,LRDAMT,LREAMT) to ensure accurate reporting of invoice, discount, and EFT amounts. - Uses
KYUPDT(bank upload date) to ensure the report reflects the correct transaction file.
Tables/Files Used¶
- CRTRAN:
- Type: Primary input file (disk).
- Record Length: 256 bytes.
- Fields:
ATDEL(1): Delete code.ATSEQ#(2-6): Sequence number.ATCO(7-8): Company number.ATCUST(9-14): Customer number.ATKEY(7-14): Composite key (company + customer).ATINV#(15-21): Invoice number.ATAMT(22-26): Transaction amount (packed).ATDISC(27-30): Transaction discount (packed).ATTYPE(31): Transaction type.ATDATE(32-37): Transaction date.ATGLCR(38-45): G/L credit account.ATGLDR(46-53): G/L debit account.ATDESC(55-79): Transaction description.ATDUDT(80-85): Due date.ATTERM(86-87): Terms.ATCODI(96-97): Discount company.ATGLDI(98-105): G/L discount account.ATCOCR(106-107): Credit company.ATCODR(108-109): Debit company.ATNOD(227): Additional field.KYUPDT(228-233): Bank upload date.KYSEDT(234-239): Settlement date.
-
Purpose: Contains EFT transaction data for the report.
-
ARCUST:
- Type: Input file (disk, keyed).
- Record Length: 384 bytes.
- Key: Starts at position 8 (likely company + customer number).
- Fields:
ARDEL(1): Delete code.ARCO(2-3): Company number.ARCUST(4-9): Customer number.ARNAME(10-39): Customer name.AREFT(302): EFT participant (Y/N).- Other fields for customer details (address, totals, etc.).
-
Purpose: Provides customer details (e.g., name) for the report.
-
ARCONT:
- Type: Input file (disk, keyed).
- Record Length: 256 bytes.
- Key: Starts at position 2 (company number).
- Fields:
ACDEL(1): Delete code.ACCO(2-3): Company number.ACNAME(4-33): Company name.
-
Purpose: Provides company details (e.g., name) for the report header.
-
LIST:
- Type: Output printer file.
- Record Length: 164 bytes.
- Purpose: Outputs the EFT report, including headers, detail lines, and totals.
External Programs Called¶
- None: The
AR136RPG program does not call any external programs. It performs all processing internally using the input files (CRTRAN,ARCUST,ARCONT) and outputs to theLISTprinter file.
Integration with OCL and Other Programs¶
The AR136 RPG program is called by the AR136.ocl36.txt OCL program, which is itself called conditionally by the main OCL program AR136P.ocl36.txt after the RPG program AR136P.rpgle.txt validates input. The integration is as follows:
- Main OCL (AR136P.ocl36.txt):
- Calls GSGENIEC for setup, runs GSY2K for date handling, and executes AR136P to validate the company number (KYCO) and bank upload date (KYUPDT).
- Checks the STATUS field (position 109). If not 'Y', calls AR136 with parameters including ?9? (library/prefix) and uses KYUPDT (positions 110-115) to construct the CRTRAN file name.
- RPG Program (
AR136P.rpgle.txt): - Prompts for and validates
KYCOandKYUPDTusingarcontandAR135TC. -
Sets
STATUSto 'Y' if valid, allowing the OCL to proceed toAR136. -
OCL Program (
AR136.ocl36.txt): - Loads
AR136and specifiesCRTRAN(with label?9?E?L'110,6'?, matchingGE+KYUPDT),ARCUST, andARCONT. -
Executes
AR136to generate the report. -
AR136 RPG:
- Uses
KYUPDTto process the correctCRTRANfile, retrieves customer details fromARCUST, and company details fromARCONT. - Produces a detailed report with transaction-level data and totals.
Notes¶
- The program is part of the EFT draft process, likely preparing data for upload to a bank (e.g., PNC, as mentioned in the heading).
- The
CRTRANfile’s dynamic name (GE+KYUPDT) aligns with the validation inAR136P.rpgle.txt, ensuring the report processes the correct EFT transactions. - The report is designed for pre-upload verification, providing a detailed listing of EFT transactions with contact information for issue resolution.
- The compile-time headings include contact details (e.g., “LISA AT AMERICAN REFINING GROUP”), indicating the report’s use in a specific organizational context.
If you have additional details (e.g., the structure of the CRTRAN file, the exact report layout, or the AR135TC program), I can provide further insights into the system’s functionality.