Skip to content

BB953 RPG36

The provided document, BB953.rpg36.txt, is an RPG (Report Program Generator) program for an IBM System/36 or AS/400 environment. It is called by the OCL program BB953.ocl36.txt and is responsible for generating the final rack price list report. The program processes records from the sorted temporary file BB9531 (labeled BB953S in the OCL), retrieves additional data from reference files, and produces a formatted report on the printer (LIST) and a disk file (OUTFILE). The report displays the last two price changes for each product/container/unit of measure combination, formatted to fit within two print lines for easy customer quoting. Below, I will explain the process steps, business rules, tables (files) used, and any external programs called.


Process Steps of the RPG Program

The BB953 RPG program reads sorted records from BB9531, performs lookups to enrich the data with company, location, product class, and container descriptions, and generates a formatted report. It handles page headers, detail lines, and separators, ensuring the output is concise and user-friendly. Here’s a detailed breakdown of the process steps:

  1. Header and File Definitions:
  2. H-Spec: The header specification (H P064 BB953) identifies the program as BB953 with a program identifier P064. The comments describe its purpose: printing the last two price changes within a product/container/unit of measure, keeping data within two print lines.
  3. File Definitions (F-Specs):
    • BB9531: Primary input file (169 bytes, disk-based), containing sorted rack price data (labeled BB953S in the OCL).
    • BICONT: Input file (256 bytes, indexed with 2 keys, record-address type R), for company data.
    • GSTABL: Input file (256 bytes, indexed with 12 keys, record-address type R), for product class and group descriptions.
    • INLOC: Input file (512 bytes, indexed with 5 keys), for location data.
    • GSCNTR1: Input file (512 bytes, indexed with 3 keys), for container descriptions (added per JK01 to replace GSTABL for container data).
    • OUTFILE: Output file (121 bytes, disk-based, append mode A), for storing report data.
    • LIST: Printer file (164 bytes, overflow indicator OF), for printing the rack price list report.
  4. Array Definitions (E-Specs):
    • XXPR: Array of 5 elements (9 bytes, 4 decimals) for current rack prices.
    • XXQT: Array of 5 elements (7 bytes, 0 decimals) for quantity levels.
    • PRPR: Array of 5 elements (9 bytes, 4 decimals) for previous rack prices (unused in output).
    • SEP: Array of 82 elements (2 bytes each) for printing separator lines (--) between locations.
    • QTY: Array of 5 elements (10 bytes) for quantity headings.
    • QTH: Array of 10 elements (1 byte) for quantity heading flags.
    • QT: Array of 5 elements (1 byte) for beginning or ending quantity flags.
    • BQT: Array of 5 elements (1 byte) for beginning quantity flags.
    • EQT: Array of 5 elements (1 byte) for ending quantity flags.
    • DESC: Array of 4 elements (10 bytes) for delivery descriptions (e.g., COLLECT, PPD & ADD).
    • COM: Array of 2 elements (15 bytes) for division descriptions (e.g., REFINERY, BLENDED LUBES).
    • ERR: Array of 3 elements (30 bytes) for error messages (e.g., NO PRODUCT CLASS LISTED).
  5. Input Specifications (I-Specs):

    • BB9531: Defines fields like XXCO (company, pos 1-2), XXLOC (location, pos 3-5), XXPRGR (product group, pos 6-7), XXPROD (product code, pos 8-11), XXCNTR (container, pos 12-14), XXUNMS (unit of measure, pos 15-17), XXQT (quantity array, pos 18-52), XXPR,1-5 (current prices, pos 58-82), PRPR,1-5 (previous prices, pos 88-112), XXDES1 (full description, pos 113-132), XXDES2 (abbreviated description, pos 133-142), XXDATE (date, pos 145-150), XXYY (year, pos 145-146), XXMMDD (month/day, pos 147-150), XXTIME (time, pos 151-154), XXMINQ (minimum quantity, pos 155-161), XXDIV (division, pos 163-164), XXPRCL (product class, pos 165-167), XXRKRQ (rack required, pos 168, per JB04), XXINAC (inactive flag, pos 169, per JB04).
    • BICONT: Defines BCNAME (company name, pos 4-33).
    • GSTABL: Defines TBDES1 (complete description, pos 14-33) and TBDESC (complete description, pos 14-43).
    • INLOC: Defines ILDEL (delete flag), ILCONO (company), ILLOC (location), ILNAME (location name).
    • GSCNTR1: Defines TCDESC (container description, pos 14-33, per JK01).
    • Data Structures (DS): Define QTYHDR, QTH, ENDQTY, EQT, BEGQTY, BQT for quantity formatting.
  6. Initialization (Lines 0086-0089):

  7. ONCE Check:

    • If ONCE = *ZERO (first run), initializes SEP array with -- for location separators and executes ONETIM subroutine.
    • Sets ONCE to prevent re-execution.
  8. ONETIM Subroutine (Not shown in truncated code but referenced):

  9. Likely initializes variables, such as page counters, date/time fields (SYDATEY, SYTIME), and other report formatting data.

  10. Main Processing Loop (Lines 0091-0123):

  11. Level Breaks:
    • L5 (Company): Chains to BICONT using XXCO to retrieve BCNAME (company name). If not found (indicator 91), sets BCNAME to blanks.
    • L4 (Location): Builds LOCKEY (company + location) and chains to INLOC to retrieve ILNAME (location name). If found (N91), sets LOCNAM; otherwise, sets to blanks.
    • L3 (Division): If XXDIV = *ZEROS, sets DIVNAM to COM,1 (REFINERY); otherwise, sets to COM,2 (BLENDED LUBES).
    • L2 (Product Class): Builds TBLKEY with 'PRODCL' and XXCO + XXPRCL, chains to GSTABL to retrieve TBDESC (product class description). If not found (93), sets PRCLDS to ERR,1 (NO PRODUCT CLASS LISTED); otherwise, sets to TBDESC. Prints headers (PRTHDR) and detail line (PRTLN2).
    • L1 (Product/Container/Unit): Builds TBLKEY with 'PRODGR' and XXCO + XXPRGR, chains to GSTABL to retrieve TBDES1 (product group description). If not found (93), sets GRPDSC to blanks. Processes quantity and price data.
  12. Container Description Lookup:
    • Chains to GSCNTR1 (per JK01) to retrieve TCDESC (container description).
  13. Rack Required and Inactive Flags (per JB04):

    • Compares XXRKRQ to 'N' (sets indicator 21 if true, indicating no rack price required).
    • Compares XXINAC to 'I' (sets indicator 22 if true, indicating inactive).
    • Compares XXINAC to 'B' (sets indicator 23 if true, indicating inactive but specific condition).
  14. Quantity and Price Formatting (Lines 0106-0218, partial in truncated code):

  15. REMBEG Subroutine (Lines 0221-0243):
    • Removes leading zeros from quantity fields (XXQT) to format QTY,1-4 for printing.
    • Loops through BQT array, skipping zeros, and constructs QT array for display.
    • Calculates dash position for quantity ranges.
  16. Formats quantities into QTY array for printing, ensuring clear presentation (e.g., QTY,1 to QTY,4).
  17. Processes XXPR,1-4 (current prices) and XXMINQ (minimum quantity) for output.

  18. Output Processing:

  19. Printer Output (LIST):
    • Headers (PRTHDR):
    • Prints program name (BB953), page number (PAGE), company name (BCNAME), report title (RACK PRICE LISTING), division (DIVNAM), location (XXLOC, LOCNAM), date (SYDATEY), time (SYTIME), and column headings (QUANTITY 1, PRICE 1, etc.).
    • Uses indicators 02, 03, 04, 05, 0, 1 to control header printing at different levels (overflow, company, location, division, etc.).
    • Detail Lines (PRTLN1, PRTLN2):
    • PRTLN1: Prints product details (XXPROD, XXDES1, XXCNTR, CNTDSC, XXUNMS), effective date (CURDAT), time (CURTIM), quantities (QTY,1-4), prices (XXPR,1-4), minimum quantity (XXMINQ), and flags (XXRKRQ, XXINAC with labels like RACK NOT REQ'D, INACTIVE, INACTIV BUT).
    • PRTLN2: Prints product class (XXPRCL, PRCLDS) at level L2.
    • Separator (PRTSEP): Prints SEP (--) between locations.
  20. Disk Output (OUTFILE):

    • Writes records with fields like XXCO, XXLOC, XXPRCL, XXPROD, XXDES1, XXCNTR, XXUNMS, CURDT8, CURTIM, QTY,1-4, XXPR,1-4, XXMINQ, XXRKRQ, XXINAC.
  21. Termination:

  22. The program ends after processing all records, closing the printer and disk files.

Business Rules

The BB953 program enforces the following business rules for the rack price list report:

  1. Report Formatting:
  2. Displays the last two price changes for each product/container/unit of measure combination within two print lines for easy customer quoting.
  3. Includes company, location, division, product class, product, container, unit of measure, quantities, prices, effective date, time, minimum quantity, and rack/inactive flags.

  4. Data Enrichment:

  5. Retrieves company name (BCNAME) from BICONT using XXCO.
  6. Retrieves location name (ILNAME) from INLOC using XXCO + XXLOC, skipping deleted records (ILDEL = 'D').
  7. Retrieves product class description (TBDESC) from GSTABL using 'PRODCL' + XXCO + XXPRCL. If not found, uses error message (NO PRODUCT CLASS LISTED).
  8. Retrieves product group description (TBDES1) from GSTABL using 'PRODGR' + XXCO + XXPRGR. If not found, sets to blanks.
  9. Retrieves container description (TCDESC) from GSCNTR1 using XXCNTR.

  10. Division Handling:

  11. If XXDIV = *ZEROS, uses COM,1 (REFINERY); otherwise, uses COM,2 (BLENDED LUBES) for division name.

  12. Quantity and Price Formatting:

  13. Formats up to 4 quantity levels (XXQT,1-4) and prices (XXPR,1-4) per record.
  14. Removes leading zeros from quantities for clear presentation.
  15. Prints minimum quantity (XXMINQ) and flags (XXRKRQ, XXINAC) to indicate special conditions.

  16. Special Flags (per JB04):

  17. If XXRKRQ = 'N', prints RACK NOT REQ'D.
  18. If XXINAC = 'I', prints INACTIVE.
  19. If XXINAC = 'B', prints INACTIV BUT.

  20. Error Handling:

  21. If lookups fail (e.g., company, location, product class, product group), uses default values (blanks or error messages).
  22. Ensures invalid data does not halt the report but is flagged appropriately.

  23. Output Consistency:

  24. Writes to both LIST (printer) for human-readable output and OUTFILE (disk) for data retention.
  25. Uses level breaks (L1-L5) to organize output by company, location, division, and product class.

Tables (Files) Used

The RPG program uses the following files (tables): 1. BB9531: Primary input file (169 bytes), containing sorted rack price data (labeled BB953S in the OCL). Fields include XXCO, XXLOC, XXPRGR, XXPROD, XXCNTR, XXUNMS, XXQT, XXPR, XXDES1, XXDES2, XXDATE, XXTIME, XXMINQ, XXDIV, XXPRCL, XXRKRQ, XXINAC. 2. BICONT: Input file for company data (e.g., BCNAME). 3. INLOC: Input file for location data (e.g., ILCONO, ILLOC, ILNAME, ILDEL). 4. GSTABL: Input file for product class and group descriptions (e.g., TBDES1, TBDESC). 5. GSCNTR1: Input file for container descriptions (e.g., TCDESC, added per JK01). 6. OUTFILE: Output file (121 bytes) for storing report data. 7. LIST: Printer file (164 bytes) for the formatted rack price list report.


External Programs Called

No external programs are explicitly called within the BB953 RPG program. It operates independently, processing input from BB9531, performing lookups in BICONT, INLOC, GSTABL, and GSCNTR1, and writing to OUTFILE and LIST. The program is invoked by the OCL program BB953.ocl36.txt.


Summary

The BB953 RPG program generates the final rack price list by: - Reading sorted records from BB9531 (labeled BB953S). - Enriching data with company (BICONT), location (INLOC), product class/group (GSTABL), and container (GSCNTR1) descriptions. - Formatting quantities and prices, removing leading zeros, and handling special flags (XXRKRQ, XXINAC). - Printing headers and detail lines to LIST (printer) and writing records to OUTFILE (disk). - Using level breaks to organize output by company, location, division, and product class.

Tables (Files) Used: - BB9531 (input) - BICONT (input) - INLOC (input) - GSTABL (input) - GSCNTR1 (input) - OUTFILE (output) - LIST (printer output)

External Programs Called: - None

This program completes the rack price list workflow by producing a user-friendly report that summarizes the latest price changes, optimized for customer quoting.