Skip to content

BB202 RPG36

Process Steps of the RPG Program (BB202.rpg36.txt)

This RPG III program (BB202) processes order transaction headers from a batch file (BBORTR) to check for orders placed on credit hold during posting. If an order is newly on hold and unauthorized, it generates output reports (as spool files) for emailing notifications to relevant parties (e.g., CSR, salesman, credit manager). The program reads sequentially, performs lookups, calculates dates, and applies conditional logic for notifications. It ignores deleted orders and focuses on credit hold changes. The process is executed in a loop for each qualifying header record.

High-level process steps:

  1. Initialization and Date Setup:
  2. On first pass (ONCE = 0), captures system time (TIMDAT) and date (UDATE), breaking them into SYSTIM, SYSDAT, YMD, CYR.
  3. Handles Y2K century rollover: If year >= Y2KCMP (likely 2000), sets CN to Y2KCEN (19); else adds 1 to Y2KCEN (20).
  4. Converts dates to CYMD (SYCYMD) and MDY formats.
  5. Calls subroutine @DTE1 to convert Gregorian date ($MDY, $CN) to Julian (G$JD) and day of week (G$JW).
  6. Calculates days from current date to requested date (BORQDT) for display.
  7. Initializes zeros for accumulators (Z92, Z2, ZERO6, ZERO8) and increments ONCE.

  8. Header Record Processing (L2 DO Loop):

  9. Chains to BICONT using company (BOCO) for company info.
  10. Sets keys (OKEY8, COCUST) for further lookups.
  11. Resets totals (L2TOTL = 0).

  12. Skip Deleted Orders:

  13. If BODEL = 'D' (delete flag), skips processing (per JB01/JB02 revisions to ignore deleted orders).

  14. Subroutine HDR (Main Processing):

  15. Sets indicators (10 for process order, 72 on).
  16. Checks order type: Sets 26/27 if BOTYPE = 'R' (return/credit invoice?).
  17. Chains to ARCUST using customer (BOCUST/COCUST) for customer details (name, address, aging balances, credit limit).
  18. Builds keys (KEY14, ORCLKY) for BBORCL chain.
  19. Looks up CSR email (EDICU) from BBCSR using company + order taken by (BOTKBY); defaults to 'SJM' if not found.
  20. Looks up salesman email (EDISM) from BBSLSM using company + salesman (BOSLMN).
  21. Looks up A/R clerk email (EDIAR) from BBCSR using company + authorization initials (BLAUIN).
  22. Chains to BBORCL using order key (company + customer + order#) to get credit hold details.
  23. Calculates order amount (ORDAMT): Prioritizes BLOAMT (order file amount) if non-zero; falls back to BLTAMT (transaction amount).
  24. Checks for credit hold change: If BLOVCL (current hold Y/N) == BLOVSV (saved hold), skips notification (TAG SKIP).
  25. Removed check for days >= 21 (MG01; previously skipped notifications for far-future orders).
  26. If not in BBORCL (N98), unauthorized (BLAUIN blank), and on hold (BLOVCL = 'Y'), executes exception output (EXCPT UNAU) to generate notification reports.
  27. Tags SKIP and executes EXCPT RESET to clear.

  28. Date Conversion Subroutine (@DTE1):

  29. Breaks $MDY into month/day/year.
  30. Handles century if not provided (similar to init).
  31. Converts Gregorian to Julian: Adjusts month/year, calculates days using formulas (e.g., month * 30.6, year * 365.25).
  32. Determines day of week via modulo 7.

  33. Output and End:

  34. Exception records (UNAU) written to CREMAL and SMEMAL (printer files, likely spooled for email).
  35. Outputs include: Timestamp, order/customer details, addresses, pickup date/days away, amounts, credit limit, payment dates, aging buckets (current, 1-30, 31-60, etc.), notify emails.
  36. Resets BBORCL record with blanks in positions 89+.
  37. Ends when end-of-file on BBORTR.

Business Rules

  • Deleted Orders: Skipped entirely (BODEL != 'D'; revisions JB01/JB02 to refine ignoring deletes).
  • Order Types: Flags 'R' as credit invoice (ind 26/27), but processes all non-deleted.
  • Credit Hold Notification:
  • Triggered only if hold status changed (BLOVCL != BLOVSV; i.e., newly on hold during batch).
  • Requires unauthorized (BLAUIN blank) and active hold (BLOVCL = 'Y').
  • No longer limited to <21 days from request date (removed per MG01).
  • Order Amount: Uses BLOAMT if available; falls back to BLTAMT; sums if both present (handles discrepancies between transaction and order files).
  • Emails/Notifications:
  • Sent to CSR (from BBCSR via BOTKBY), Salesman (from BBSLSM via BOSLMN), A/R Clerk (from BBCSR via BLAUIN).
  • Defaults CSR to 'SJM' if not found.
  • Fixed notifies in output: bzolkos@amref.com, lmidla@amref.com (likely credit team).
  • Dual outputs (CREMAL for credit, SMEMAL for salesman) with identical content.
  • Dates: Handles Y2K, calculates days to request date for urgency display.
  • Customer Aging: Displays balances (total due, current, overdues in buckets) from ARCUST.
  • Credit Limit: Compared implicitly via hold, displayed in notification.

Tables Used (Files)

Files are disk or printer, with keyed access (AI for alternate index).

  • BBORTR: Input primary (IP) - Order transaction batch (headers).
  • BICONT: Input combined (IC) - Company/container info.
  • BBORCL: Update (UF) - Order credit hold log.
  • ARCUST: Input combined (IC) - A/R customer master (aging, limits).
  • BBCSR: Input (IF) - CSR (customer service rep) table (emails).
  • BBSLSM: Input (IF) - Salesman table (emails).
  • CREMAL: Output (O) - Printer/spool for credit manager email notifications.
  • SMEMAL: Output (O) - Printer/spool for salesman email notifications.

External Programs Called

None. This program does not call any external programs (no CALL opcodes).