Skip to content

BB953 RPG36

The provided document, BB953.rpg36.txt, is an RPG (Report Program Generator) program for the IBM System/36 environment (or AS/400 in compatibility mode), named BB953. It is invoked by the OCL script BB953B.ocl36.txt as the final step in the rack pricing process within the PRICES.ocl36.txt workflow, which is itself part of the PRICEGEN.clp pricing generation process for blended lubes. The program generates a rack price report by processing the sorted temporary file BB9531 (from BB9534 and #GSORT), printing the last two price changes for each product/container/unit of measure combination within two print lines for easy customer quoting. 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.

Process Steps of the RPG Program

  1. File Definitions:
  2. Input Files:
    • BB9531 (Input Primary, IP, 169 bytes, disk): Sorted temporary file, mapped to ?9?BB953S (e.g., ABB953S), containing filtered pricing data from BB9534.
    • BICONT (Input, IC, 256 bytes, indexed with 2-byte key, disk): Contract file for company data, shared read with record locking.
    • GSTABL (Input, IC, 256 bytes, indexed with 12-byte key, disk): Table file for product class and division data, shared read with record locking.
    • INLOC (Input, IC, 512 bytes, indexed with 5-byte key, disk): Location file for location descriptions, shared read with record locking.
    • GSCNTR1 (Input, IF, 512 bytes, indexed with 3-byte key, disk): Container file for container descriptions, shared read (replaces GSTABL for container codes per JK01).
  3. Output Files:

    • OUTFILE (Output, O, 121 bytes, disk): Rack price output file, mapped to ?9?RKPRCE (e.g., ARKPRCE), shared mode.
    • LIST (Output, O, 164 bytes, printer): Printer file for the rack price report.
  4. Extension Specifications:

  5. Arrays for processing and reporting:

    • XXPR (5 elements, 9 bytes, 4 decimals): Current rack prices.
    • XXQT (5 elements, 7 bytes, 0 decimals): Quantity levels.
    • PRPR (5 elements, 9 bytes, 4 decimals): Previous rack prices.
    • SEP (82 elements, 2 bytes): Separator line (--) for formatting between locations.
    • QTY (5 elements, 10 bytes): Quantity headings (e.g., quantity ranges).
    • QTH (10 elements, 1 byte): Quantity heading flags.
    • QT (5 elements, 1 byte): Quantity type (begin or end).
    • BQT (5 elements, 1 byte): Beginning quantity flags.
    • EQT (5 elements, 1 byte): Ending quantity flags.
    • DESC (4 elements, 10 bytes): Freight descriptions (e.g., COLLECT, PPD & ADD, DELIVERED, 3RD PARTY).
    • COM (2 elements, 15 bytes): Division descriptions (e.g., REFINERY, BLENDED LUBES).
    • ERR (3 elements, 30 bytes): Error messages (e.g., NO PRODUCT CLASS LISTED, BAD PRODUCT, NO SHIPTO RECORD EXISTS).
  6. Input Specifications:

  7. BB9531 (record type NS):
    • XXCO (1–2): Company number.
    • XXLOC (3–5): Location.
    • ILKEY (1–5): Key field (company + location).
    • XXPRGRL1 (6–7): Product group.
    • XXPROD (8–11): Product code.
    • XXCNTR (12–14): Container code.
    • XXUNMS (15–17): Unit of measure.
    • XXQT (18–52): Quantity levels (5 elements).
    • XXPR (53–82): Current prices (5 elements, packed).
    • PRPR (83–112): Previous prices (5 elements, packed).
    • XXDES1 (113–132): Product description.
    • ABDSCP (133–142): Short description.
    • XXDATE (143–150): Date (CYMD).
    • XXTIME (151–154): Time (HHMM).
    • XXMINQ (155–161): Minimum quantity.
    • XXDIV (162–164): Division code.
    • XXPRCL (165–167): Product class code.
    • XXRKRQ (168): No rack price required flag (per JB04).
    • XXINAC (169): Inactive flag (b, I, or B, per JB04).
  8. BICONT (record type NS):
    • BCDEL (1): Delete code.
    • BCCO (2–3): Company number.
    • BCNAME (4–33): Company name.
  9. GSTABL (record type NS):
    • TBDEL (1): Delete code.
    • TBCSRT (178–179): Division code.
  10. INLOC (record type NS):
    • ILDEL (1): Delete code.
    • ILLOC (2–4): Location code.
    • ILDESC (5–34): Location description.
  11. GSCNTR1 (record type NS):

    • TCDEL (1): Delete code.
    • TCCNTR (2–4): Container code.
    • TCDESC (14–43): Container description (per JK01).
  12. Calculation Specifications (inferred due to truncation):

  13. Main Loop:
    • Processes each BB9531 record (01 DO, implied).
  14. Filtering:
    • Skips deleted records (XXDEL = 'D' from BICONT, GSTABL, INLOC, GSCNTR1).
    • Applies date range filtering using KYFRDT and KYTODT (from UDS, set by BB953B.ocl36.txt).
  15. Lookups:
    • Chains BICONT using XXCO to get company name (BCNAME).
    • Chains INLOC using ILKEY (company + location) to get location description (ILDESC).
    • Chains GSTABL for division description (TBCSRT).
    • Chains GSCNTR1 using XXCNTR to get container description (TCDESC, per JK01).
  16. Price Processing:
    • Compares XXDATE and XXTIME to identify the last two price changes for each product/container/unit of measure combination.
    • Stores current prices (XXPR) and previous prices (PRPR) for reporting.
  17. Formatting:
    • Uses QTY, BQT, EQT to format quantity headings (e.g., begin/end ranges).
    • Sets flags for inactive records (XXINAC, e.g., 'I' or 'B') and rack price not required (XXRKRQ, per JB04).
  18. Output:

    • Writes to OUTFILE (?9?RKPRCE) with pricing data (121 bytes).
    • Writes to LIST (printer) with formatted report lines.
  19. Output Specifications:

  20. LIST (printer, 164 bytes):
    • Header (D 0, OF):
    • Company name (BCNAME), division (DIVNAM), date (SYSDAT), time (SYSTIM), page (PAGE1).
    • Fields: Location (XXLOC), product class (XXPRCL), product (XXPROD), container (XXCNTR), unit of measure (XXUNMS), quantities (XXQT,1XXQT,4), prices (XXPR,1XXPR,4), minimum quantity (XXMINQ).
    • Detail Lines:
    • PRTLN1 (EF 1): Prints product, description (XXDES1), container code (XXCNTR), container description (CNTDSC), unit of measure (XXUNMS), effective date (CURDAT, MM/DD/YY), time (CURTIM), quantities (QTY,1QTY,4), prices (XXPR,1XXPR,4), minimum quantity (XXMINQ4), and flags (XXINAC, XXRKRQ).
    • PRTLN2 (EF02, EF10): Prints product class description (PRCLDS) and code (XXPRCL).
    • PRTSEP (EF 1): Prints separator line (SEP) between locations.
    • Flags (per JB04):
    • 'INACTIVE' if XXINAC = 'I' (indicator 22).
    • 'INACTIV BUT' if XXINAC = 'B' (indicator 23).
    • 'RACK NOT REQ''D' if XXRKRQ is set (indicator 21).
  21. OUTFILE (?9?RKPRCE, 121 bytes):
    • Writes pricing data, likely including company, location, product, container, prices, quantities, and flags.

Business Rules

  1. Purpose: Generates a rack price report showing the last two price changes for each product/container/unit of measure combination, formatted within two print lines for easy customer quoting, and writes pricing data to OUTFILE (?9?RKPRCE).
  2. Price Reporting:
  3. Selects the most recent and second-most recent price changes based on XXDATE and XXTIME.
  4. Prints current prices (XXPR) and previous prices (PRPR) for up to four quantity levels (XXQT,1XXQT,4).
  5. Filtering:
  6. Excludes deleted records (BCDEL, TBDEL, ILDEL, TCDEL = 'D').
  7. Filters by date range (KYFRDT to KYTODT, set by BB953B.ocl36.txt).
  8. Applies division, location, product class, container, and product filters from UDS (set in BB953B).
  9. Formatting:
  10. Groups output by company, location, product class, product, container, and unit of measure.
  11. Uses separator lines (SEP) between locations for readability.
  12. Includes quantity headings (QTY) and flags for inactive records (XXINAC) and rack price exemptions (XXRKRQ).
  13. Descriptions:
  14. Retrieves company name (BCNAME) from BICONT.
  15. Retrieves location description (ILDESC) from INLOC.
  16. Retrieves division (TBCSRT) from GSTABL.
  17. Retrieves container description (TCDESC) from GSCNTR1 (per JK01).
  18. Context: Final step in the BB953B.ocl36.txt workflow, producing the rack price report (LIST) and data file (?9?RKPRCE) from ?9?BB953S.

Tables (Files) Used

  1. BB9531 (?9?BB953S):
  2. Access: Input Primary (IP), shared mode.
  3. Purpose: Sorted pricing data from BB9534 via #GSORT.
  4. BICONT (?9?BICONT):
  5. Access: Input (IC), shared read with record locking.
  6. Purpose: Provides company name (BCNAME).
  7. GSTABL (?9?GSTABL):
  8. Access: Input (IC), shared read with record locking.
  9. Purpose: Provides division code (TBCSRT).
  10. INLOC (?9?INLOC):
  11. Access: Input (IC), shared read with record locking.
  12. Purpose: Provides location description (ILDESC).
  13. GSCNTR1 (?9?GSCNTR1):
  14. Access: Input (IF), shared read.
  15. Purpose: Provides container description (TCDESC).
  16. OUTFILE (?9?RKPRCE):
  17. Access: Output (O), shared mode.
  18. Purpose: Stores final rack pricing data.
  19. LIST:
  20. Access: Output (O), printer.
  21. Purpose: Generates the formatted rack price report.

External Programs Called

  • None: The BB953 RPG program does not call external programs or subroutines. It performs internal processing and output formatting.

Additional Notes

  • Context with BB953B.ocl36.txt: Final program in the BB953B workflow, processing ?9?BB953S to produce ?9?RKPRCE and the printed report (LIST).
  • Revisions:
  • FHL082198: Fixed index error in BQT (quantity handling).
  • FHL112098: Printed container code before description.
  • LT03 (09/14/11): Removed tax arrays.
  • JB04 (09/20/12): Added XXRKRQ and XXINAC fields.
  • JK01 (02/24/16): Replaced GSTABL with GSCNTR1 for container data.
  • System/36 Environment: Uses RPG II/III syntax, likely on AS/400.
  • Truncation: The document is truncated, but output specifications provide sufficient detail. Missing calculations likely involve price comparison and formatting logic.
  • Error Handling: Uses ERR array for messages (e.g., NO PRODUCT CLASS LISTED) and relies on System/36 for file errors.

If you have the RPG source code for the SA505* programs or need further analysis of the pricing workflow, please provide those details! Let me know if you have additional questions or files to share.