Skip to content

AR781 RPG36

Overview of AR781

AR781 is the main processing program in the three-program batch chain (AR781P → AR781 → AR781A). It is an RPG II program written for the IBM System/36 environment (or AS/400 in S/36 compatibility mode).

Its purpose is to: - Take the pre-filtered list of group/parent customers (from AR780I, created by AR781P) that have at least one open order flagged as over credit limit and not yet authorized. - For each such group customer, aggregate all related customers in the same credit-limit group (via ARCLGR). - Calculate group-level credit exposure: - Total A/R balance and aging (current + past due) - Open approved orders - Open orders not yet approved (over limit and unauthorized) - Available credit - Determine which individual open order lines are eligible for release from credit hold. - Write qualifying order lines to CREDREL (detail file) and group summaries to CREDRLH (header file). - Print a report titled "CREDIT HOLD ELIGIBLE FOR RELEASE REPORT" showing group summaries and eligible orders.

This report helps credit managers decide which held orders can be safely released.

Process Steps (High-Level Flow)

  1. Initialization (ONCE block):
  2. Runs once at program start.
  3. Gets current date/time and formats it.
  4. Chains to ARCONT (likely company control) using a company number to retrieve aging bucket definitions (ACLMT1–ACLMT4) for display on the report header.
  5. Outputs the report heading (company name, title, page, date/time, aging buckets).

  6. Main Loop – Process each group customer from AR780I:

  7. Reads AR780I sequentially (input primary file, indicator 01).
  8. For each record (each qualifying group customer):

    • Uses the group key (company + group customer number) to read the ARCLGR (credit limit group) file, which contains an array of up to 200 member customers belonging to the same credit group.
    • Loops through all non-deleted member customers in the group:
    • Chains to ARCUST to get A/R balances (total due, current, aging buckets).
    • Accumulates group-level totals:
      • Total A/R due (S2TOTD)
      • Aging buckets (S2CURD, S20110, etc.)
      • Past-due amount (ARPBAM = sum of all overdue buckets)
    • If a member has a non-zero credit limit, uses it as the group credit limit (S2CLMT).
    • Reads all open order lines (BBORCL) for every member customer in the group.
    • Calculates order amount (BLAMT = BLTAMT if non-zero, else BLOAMT).
    • Classifies each order line:
      • Approved orders: either not over limit (BLOVCL ≠ 'Y') or over limit but already authorized (BLAUIN ≠ blank).
      • Not approved (pending): over limit and no authorization.
    • Accumulates:
      • S2ORAP = total value of approved orders
      • S2ONAP = total value of pending (over-limit, unauthorized) orders
    • Calculates available credit:
    • S2AVCL = S2CLMT – S2TOTD – S2ORAP (credit limit minus A/R minus approved open orders)
  9. Determine eligibility of individual pending orders:

  10. For each pending order line (over limit, no authorization):

    • Checks two business rules:
    • Customer is not flagged as a chronic credit problem (ARCLPB ≠ 'Y').
    • There is enough available credit for this specific order:
      S2AVCL – order amount > 0
    • If both true → the order is eligible for release:
    • Sets status message "THIS ORDER IS ELIGIBLE FOR RELEASE"
    • Outputs a detail record to CREDREL
    • Outputs/adds to header record in CREDRLH (if not already exists)
    • If not eligible:
    • If ARCLPB = 'Y' → "HAS PAST DUE BALANCE - NOT ELIGIBLE" (actually the message is for past-due, but code uses a different message for problem customers)
    • If not enough available credit → status reflects that.
  11. Report Output:

  12. Prints a header for each group with:
    • Group customer number, name, address, contact, phone
    • Group totals: total due, credit limit, approved orders, available credit, pending orders
  13. Prints detail lines for each eligible order line.

Key Business Rules

  1. Credit limit is shared at the group level (parent/group customer).
  2. Available credit calculation:
  3. Available = Credit Limit – (A/R Total Due + Value of Approved Open Orders)
  4. An order is eligible for release only if:
  5. It is currently over credit limit and not yet authorized.
  6. The customer is not marked as a credit problem (ARCLPB ≠ 'Y').
  7. Adding this order would not make available credit negative (i.e., there is room under the limit after considering A/R and approved orders).
  8. Past-due balances:
  9. The program accumulates past-due amounts but does not automatically block release due to past-due (except if ARCLPB = 'Y').
  10. Message 03 ("HAS PAST DUE BALANCE - NOT ELIGIBLE") is defined but not clearly used in visible logic — likely a remnant or used elsewhere.
  11. Authorization:
  12. Manual override via initials (BLAUIN) or user ID (BLUSID) marks an order as approved even if over limit.

Tables/Files Used

File Type Description Access Mode Key Usage
AR780I Input (Primary) Intermediate file from AR781P – list of group customers with potential over-limit orders Sequential read Driver file
ARCONT Input Company control / aging bucket definitions Random chain Once at start
ARCUST Input Customer master (A/R balances, credit limit, addresses, group info) Random chain Multiple times
ARCUSP Input Customer special/contact info Not clearly used in visible code Likely for contact name
BBORCL Input Open order lines (backlog) Sequential + SETLL/READ By customer
ARCLGR Input Credit limit group file (array of member customers) Random chain Group members
BBORDR Input Order header (used to get order-taker initials) Random chain By order number
CREDREL Output Detail file – one record per eligible order line Add (EADD) Written when eligible
CREDRLH Output (Update) Header/summary file – one record per group customer Add/Chain Written/updated
JBLIST / REPORT Output Printer file – spooled report output EXCPT Report

External Programs Called

  • None in the provided source code.
  • There are comments referencing a "CALL AUTHORIZATION ROUTINE" and subroutines like S2FILL, but no actual CALL statement to an external program.
  • All logic is internal subroutines (EXSR).

Summary

AR781 is the core of the credit release process. It performs group-level credit analysis, identifies which specific held orders can be safely released without exceeding the group credit limit (assuming no credit problem flag), and produces both data files (CREDREL/CREDRLH) for downstream use (likely by AR781A for final sorted reporting) and a detailed printed report for credit staff review. This was a classic batch decision-support tool in older ERP/AR systems.