Skip to content

BI944 RPG36

The provided document, BI944.rpg36.txt, is an RPG (Report Program Generator) program for the IBM System/36 environment (or AS/400 in compatibility mode), named BI944. It is invoked by the OCL script BI944B.ocl36.txt as part of the pricing generation process for blended lubes, initiated by PRICEGEN.clp. The program processes customer sales agreement price changes, updating the BB203W work file, generating reports (PRTDOWN, PRTEXCEL), and populating the BICUAGC file for CRM uploads. It incorporates multiple revisions to handle container codes, freight terms, and other pricing-related logic. Below, I will explain the process steps, business rules, tables used, and external programs called, noting that the document is truncated but sufficient to infer key functionality based on the provided input, output, and context.

Process Steps of the RPG Program

  1. File Definitions:
  2. Input Files:
    • BICUAGXX (IP, 263 bytes, disk): Primary input file, mapped to ?9?BI944T (e.g., ABI944T), containing sorted pricing agreement records from BI9444.
    • BICONT (IF, 256 bytes, indexed, disk): Contract file.
    • BBPRCY (IF, 128 bytes, indexed, disk): Pricing history file.
    • ARCUST (IF, 384 bytes, indexed, disk): Customer master file.
    • GSTABL (IF, 256 bytes, indexed, disk): Table file for product class/division data.
    • SHIPTO (IF, 2048 bytes, indexed, disk): Ship-to file.
    • ARCUPR (IF, 80 bytes, indexed, disk): Customer price file.
    • ARCUSP (IF, 1344 bytes, indexed, disk): Customer pricing file.
    • INLOC (IF, 512 bytes, indexed, disk): Location file.
    • BICUA7 (IF, 261 bytes, indexed, disk): Indexed pricing file (replaces BICUA5 per MG04).
    • GSCTWT (IF, 64 bytes, indexed, disk): Contract weight file (added per JB12).
    • GSUMCV (IF, 64 bytes, indexed, disk): Summary conversion file.
    • GSCNTR1 (IF, 512 bytes, indexed, disk): Container file (replaces GSTABL for container codes per JK01).
    • GSPROD (IF, 512 bytes, indexed, disk): Product file (replaces GSTABL for product codes per JK02).
  3. Output Files:

    • BB203W (O, 327 bytes, indexed, disk): Work file for updated pricing data.
    • PRTDOWN (O, 164 bytes, printer): Report file for printed output.
    • PRTEXCEL (O, 224 bytes, printer): Excel-compatible report file.
    • BICUAGC (O, 271 bytes, disk, conditional on switch U3): Output file for CRM uploads.
  4. Extension Specifications:

  5. Arrays for processing:

    • SEP (79 elements, 2 bytes): Likely separators for report formatting.
    • BAP (10 elements, 4 bytes): Stores product codes (BAPR01BAPR10).
    • BAD (10 elements, 10 bytes): Stores product descriptions.
    • FLD (28 elements, 1 byte): Field indicators.
    • CTY (26 elements, 1 byte): City/county codes.
    • ST (2 elements, 1 byte): State codes.
    • DESC (5 elements, 10 bytes): Freight descriptions (e.g., COLLECT, PPD & ADD).
    • COM (2 elements, 15 bytes): Division descriptions (e.g., REFINERY, BLENDED LUBES).
    • ERR (4 elements, 30 bytes): Error messages (e.g., NO PRODUCT CLASS LISTED).
  6. Input Specifications (for BICUAGXX, NS 01):

  7. Key fields:
    • ARKEY (2–9): Company + customer number.
    • BAP (13–52): Product codes (BAPR01BAPR10).
    • BADEL (1): Delete code.
    • BACONOL7, CO (2–3): Company number.
    • BACUSTL2, CUST (4–9): Customer number.
    • BALOC (10–12): Location.
    • BAPR01L3BAPR10 (13–52): Product codes.
    • BASTDT (53–59), BAENDT (64–70): Start/end dates (YMD).
    • BASTTM (60–63), BAENTM (71–74): Start/end times (HM).
  8. Other fields include price (BAPRCE), off-price (BAOFFP), quantities (BAMNGL, BAMXGL), indicators (BAPPD, BAALSH, BAPRIM, BADELV, BAFRCD), timestamps (BACRDT, BACRTM, BALUDT, BALUTM), container (BACNTR), ship-to (BASHIP), contract (BACNT#), and unit of measure (BAUNMS).

  9. Calculation Specifications (inferred due to truncation):

  10. Main Loop: Processes each BICUAGXX record (01 DO).
  11. Lookups:
    • Chains BICONT for contract details using company number (CO).
    • Chains ARCUST for customer name (ARNAME) using ARKEY.
    • Chains SHIPTO for ship-to data (e.g., freight terms, per JB08/MG09).
    • Chains ARCUPR for previous pricing, trying container type (BACNTR) first, then blank or 'P' for non-fluids (per JB05).
    • Chains GSPROD for product descriptions (BAD array, per JK02).
    • Chains GSCNTR1 for container details (per JK01).
    • Chains GSCTWT for gallons/container (per JB12, bypassing GSUMCV if found).
    • Chains BICUA7 for previous pricing data (per MG04).
  12. Freight Logic (JB08, MG09, JB10):
    • Uses BAFRCD from BICUAGXX for freight description (FRTDSC, per MG09).
    • Handles special freight calculations for non-Bradford locations (e.g., Anchor) when BAFRCD = 'C' (per JB10).
  13. Date Handling:
    • Uses KYSTDT (new start date, per JB03) for BB203W.
    • Compares BASTDT, BAENDT, and KYDAT8 (from BI944A) for validity.
  14. Error Handling:
    • Logs errors (e.g., missing product class, ship-to, or bad product) to ERR array.
  15. Output:
    • Writes to BB203W with updated pricing data (including KYSTDT).
    • Writes to PRTDOWN and PRTEXCEL for reports, including customer, product, price, freight, and quantity details.
    • Writes to BICUAGC (if U3 switch is on) for CRM uploads (per MG05).
  16. Counter: Increments COUNT for total records processed.

  17. Output Specifications:

  18. BB203W: Writes updated pricing records (327 bytes, including new start date).
  19. PRTDOWN (D 2, 01 38):
    • Fields: Product code (BAP,1), description (BAD,1), customer (BACUSTZ, ARNAME), ship-to (BASHIP or 'ALL'), city/state (CTYST), container (BACNTR), prices (BAPRCEJ, PRVPRCJ, BAOFFPJ), location (BALOC), unit of measure (BAUNMS), freight terms (FRTDSC, FRTDIF per JB08), dates (STDT, ENDT), quantities (BAMNQYJ, BAMXQYJ).
    • Conditional formatting based on indicators (e.g., 50, 71, 72, 73).
  20. PRTEXCEL (D 101, L7 39):
    • Header: Company name (BCNAME), division (DIVNAM), date (SYSDAT), time (SYSTIM), page (PAGE1).
    • Detail: Similar to PRTDOWN, with additional fields like new price (PRICE), start date (KYSTDT).
  21. BICUAGC (U3 switch): Writes 271-byte records for CRM, including all pricing details.

Business Rules

  1. Purpose: Processes pricing agreements to update BB203W, generate reports (PRTDOWN, PRTEXCEL), and populate BICUAGC for CRM uploads, handling price changes, freight terms, and container-specific pricing.
  2. Filtering and Validation:
  3. Excludes records with BADEL = 'D' (deleted).
  4. Validates ship-to (SHIPTO), customer (ARCUST), and product (GSPROD) data.
  5. Logs errors (e.g., missing ship-to, product class) to ERR array.
  6. Previous Price Logic (JB02, JB05, MG04):
  7. Retrieves previous price from ARCUPR using container type (BACNTR), falling back to blank or 'P' for non-fluids.
  8. Uses BICUA7 (indexed from BICUAGX) for accurate previous pricing.
  9. Freight Handling (JB08, MG09, JB10):
  10. Uses BAFRCD from BICUAGXX for freight terms (e.g., COLLECT, PPD & ADD) per MG09, reversing JB08’s ship-to-based logic.
  11. Special freight calculation for non-Bradford locations when BAFRCD = 'C' (per JB10).
  12. Gallons Calculation (JB12):
  13. Uses GSCTWT for gallons/container if available, bypassing GSUMCV.
  14. Date Handling (JB03):
  15. Writes new start date (KYSTDT) to BB203W.
  16. Sets default end date (00/00/00) if indicator 50 is on (no end date).
  17. CRM Output (MG05):
  18. Populates BICUAGC only when U3 switch is on (hourly CRM upload).
  19. Context: Final step in BI944B, building on BI9443 and BI9444 to produce final pricing data for blended lubes in ?9?BICUAGP.

Tables (Files) Used

  1. BICUAGXX (?9?BI944T): Input pricing agreements (263 bytes).
  2. BICONT (?9?BICONT): Contract data (shared).
  3. BBPRCY (?9?BBPRCY): Pricing history (shared read, record locking).
  4. ARCUST (?9?ARCUST): Customer master (shared read, record locking).
  5. GSTABL (?9?GSTABL): Product class/division (shared read, record locking).
  6. SHIPTO (?9?SHIPTO): Ship-to data (shared read, record locking).
  7. ARCUPR (?9?ARCUPR): Customer prices (shared read, record locking).
  8. ARCUSP (?9?ARCUSP): Customer pricing (shared read, record locking).
  9. INLOC (?9?INLOC): Location data (shared read, record locking).
  10. BICUA7 (?9?BICUA7): Indexed pricing (shared read, record locking).
  11. GSCTWT (?9?GSCTWT): Contract weights (shared read, record locking).
  12. GSUMCV (?9?GSUMCV): Summary conversions (shared read, record locking).
  13. GSCNTR1 (?9?GSCNTR1): Container data (shared).
  14. GSPROD (?9?GSPROD): Product data (shared).
  15. BB203W (?9?BB203?WS?): Work file output (shared).
  16. PRTDOWN: Printed report output.
  17. PRTEXCEL: Excel-compatible report output.
  18. BICUAGC (?9?BICUAGP): CRM output (shared, conditional on U3).

External Programs Called

  • None: The program does not explicitly call external programs, performing all logic internally.

Additional Notes

  • Context: Final step in BI944B, processing sorted ?9?BI944T to produce ?9?BICUAGP, reports, and BB203W.
  • Revisions:
  • JB02 (2010): Enhanced previous price logic with container codes.
  • JB03 (2012): Renamed work file, added new start date to BB203W.
  • MG04 (2013): Replaced BICUA5 with BICUA7 for pricing accuracy.
  • JB05 (2015): Added container type to ARCUPR key.
  • JK01 (2016): Used GSCNTR1 for container codes.
  • MG05 (2017): Added BICUAGC for CRM uploads.
  • JB08/MG09 (2018–2019): Switched freight code source between SHIPTO and BICUAG.
  • JB10 (2020): Added freight calculation for non-Bradford locations.
  • JK02 (2023): Used GSPROD for product codes.
  • JB12 (2024): Added GSCTWT for gallons calculation.
  • Truncation: The document is truncated, but output specifications and context provide sufficient detail. Missing calculations likely involve chaining, price comparisons, and freight logic.
  • System/36: Runs in a System/36 environment, likely on AS/400.
  • Error Handling: Uses ERR array for logging, relies on OCL for file errors.

If you have the full BI944.rpg36.txt or source code for BI942E or PRICES, I can refine the analysis. Please provide additional details or files if available!