Skip to content

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:

  1. Program Initialization:
  2. 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     PRINTER
    

    • CRTRAN: 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.
  3. Array Definition:

    1
    E                    HD      1   3 60               PRINTER HEADINGS
    

    • Defines an array HD with 3 elements (60 characters each) for report headings, loaded from compile-time data at the end of the source.
  4. 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.
  5. 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
    

  6. Checks if ONCE is zero (indicating first execution).
  7. Retrieves the system time (SYTMDT) and moves it to SYSTME (time) and SYSDTE (date) for report headers.
  8. Chains to ARCONT using ATCO (company number from CRTRAN, mapped to KYCO) to retrieve company details.
  9. Prints the report header (PRTHD3).
  10. Sets ONCE to 1 to prevent re-execution.
  11. Initializes accumulators (LRIAMT, LRDAMT, LREAMT) for invoice, discount, and EFT amounts, and SEQ# and ZERO9 to zero.

  12. Clear Overflow Indicator:

    1
    2
    C                     SETOF                     10
    C   OF                EXCPTPRTHD3
    

  13. Clears indicator 10.
  14. If the overflow indicator (OF) is on (indicating a page break), prints the report header (PRTHD3).

  15. 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
    

  16. Processes each record in CRTRAN (indicator 01 indicates input primary processing).
  17. Chains to ARCUST using ATKEY (company + customer number from CRTRAN) to retrieve customer details.
  18. Calculates EFTAMT as ATAMT (transaction amount) minus ATDISC (discount amount).
  19. Accumulates totals:
    • LRIAMT += ATAMT (total invoice amount).
    • LRDAMT += ATDISC (total discount amount).
    • LREAMT += EFTAMT (total EFT amount).
  20. Prints a detail line (PRTDTL) for each transaction.
  21. Continues until all CRTRAN records are processed.

  22. Print Report Totals:

    1
    C                     EXCPTPRTLRT
    

  23. After the main loop, prints the report totals (PRTLRT), including accumulated totals (LRIAMT, LRDAMT, LREAMT).

  24. 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
    

  25. 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”.
  26. 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).
  27. Totals (PRTLRT):
    • Prints lines and accumulated totals for invoice (LRIAMT), discount (LRDAMT), and EFT (LREAMT) amounts.

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.

  1. Customer Validation:
  2. Each transaction’s company and customer number (ATKEY) are validated against ARCUST to retrieve customer details (e.g., ARNAME).
  3. If no matching customer record is found (indicator 99 on), the transaction is still processed, but customer details may be blank.

  4. EFT Amount Calculation:

  5. Calculates the EFT amount (EFTAMT) as the transaction amount (ATAMT) minus the discount amount (ATDISC) for each transaction.

  6. Report Formatting:

  7. 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.
  8. Headings include static text from compile-time data, such as contact information for questions about the draft.

  9. Company Validation:

  10. The company number (ATCO, mapped to KYCO) is validated against ARCONT during initialization to retrieve company details (e.g., ACNAME).

  11. Data Integrity:

  12. Accumulates totals (LRIAMT, LRDAMT, LREAMT) to ensure accurate reporting of invoice, discount, and EFT amounts.
  13. Uses KYUPDT (bank upload date) to ensure the report reflects the correct transaction file.

Tables/Files Used

  1. CRTRAN:
  2. Type: Primary input file (disk).
  3. Record Length: 256 bytes.
  4. 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.
  5. Purpose: Contains EFT transaction data for the report.

  6. ARCUST:

  7. Type: Input file (disk, keyed).
  8. Record Length: 384 bytes.
  9. Key: Starts at position 8 (likely company + customer number).
  10. 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.).
  11. Purpose: Provides customer details (e.g., name) for the report.

  12. ARCONT:

  13. Type: Input file (disk, keyed).
  14. Record Length: 256 bytes.
  15. Key: Starts at position 2 (company number).
  16. Fields:
    • ACDEL (1): Delete code.
    • ACCO (2-3): Company number.
    • ACNAME (4-33): Company name.
  17. Purpose: Provides company details (e.g., name) for the report header.

  18. LIST:

  19. Type: Output printer file.
  20. Record Length: 164 bytes.
  21. Purpose: Outputs the EFT report, including headers, detail lines, and totals.

External Programs Called

  • None: The AR136 RPG program does not call any external programs. It performs all processing internally using the input files (CRTRAN, ARCUST, ARCONT) and outputs to the LIST printer 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 KYCO and KYUPDT using arcont and AR135TC.
  • Sets STATUS to 'Y' if valid, allowing the OCL to proceed to AR136.

  • OCL Program (AR136.ocl36.txt):

  • Loads AR136 and specifies CRTRAN (with label ?9?E?L'110,6'?, matching GE + KYUPDT), ARCUST, and ARCONT.
  • Executes AR136 to generate the report.

  • AR136 RPG:

  • Uses KYUPDT to process the correct CRTRAN file, retrieves customer details from ARCUST, and company details from ARCONT.
  • 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 CRTRAN file’s dynamic name (GE + KYUPDT) aligns with the validation in AR136P.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.