Skip to content

BB932 RPG36

The provided document is an RPG (Report Program Generator) program named BB932 for the IBM System/36, called from the OCL program described earlier. This program is designed to print a freight table code file. Below, I’ll explain the process steps, business rules, tables used, and any external programs called, based on the RPG code.

Process Steps of the RPG Program (BB932)

The RPG program processes data from input files, performs lookups, and generates a formatted report for the freight table. Here’s a detailed breakdown of the process steps:

  1. File Definitions:
  2. Input Files:
    • BBFRTB (Input Primary, Fixed-length 60 bytes): The freight table file containing freight codes, rates, and unit of measure (U/M) data.
    • BICONT (Input Full-Procedural, Fixed-length 256 bytes, Indexed): A control file with company information, accessed via a CHAIN operation.
    • GSTABL (Input Full-Procedural, Fixed-length 256 bytes, Indexed): A general system table, likely containing unit of measure descriptions, accessed via a CHAIN operation.
  3. Output File:

    • PRINT (Output, Fixed-length 132 bytes, Printer): The output file for generating the printed freight table report.
  4. Data Structure and Field Definitions:

  5. BBFRTB Fields:
    • BFDEL (1 char, pos 1): Delete code (likely indicates if the record is marked for deletion).
    • BFCONO (2 chars, pos 2-3): Company code (misaligned in comment as pos 2-30; likely a typo).
    • BFFRCD (2 chars, pos 4-5): Freight code.
    • BFRATE (6 chars, pos 6-11): Freight rate per gallon.
    • BFFRLB (6 chars, pos 12-17): Freight rate per pound.
    • BFFRUM (3 chars, pos 18-20): Freight rate unit of measure.
    • BFFRPU (6 chars, pos 21-26): Freight rate per unit of measure.
  6. BICONT Fields:
    • BCNAME (30 chars, pos 4-33): Company name.
  7. GSTABL Fields:
    • TBTYPE (6 chars, pos 2-7): Table type.
    • TBCODE (6 chars, pos 8-13): Table code.
    • TBDESC (30 chars, pos 14-43): Table description.
  8. Data Structure:
    • KLFRUM (12 chars): Composite key for GSTABL lookup, split into:
    • K$UNMS (6 chars): Table type, set to 'BIUNMS'.
    • K$FRUM (6 chars): Table code, populated from BFFRUM.
  9. Other Variables:

    • W$ONCE (1 char): Flag to ensure one-time initialization.
    • TIME12 (12 chars): System time.
    • TIME (6 chars): Formatted time.
    • DATE (6 chars): Formatted date.
    • PAGE (Numeric): Page number for the report.
    • R$UMDS (30 chars): Unit of measure description.
    • ERR (Array, 1 element, 80 chars): Error message for invalid U/M code.
  10. Initialization (One-Time Setup):

  11. Check W$ONCE (C-spec, W$ONCE IFNE 'Y'): Ensures initialization occurs only once.
    • Sets K$UNMS to 'BIUNMS' (table type for unit of measure lookup).
    • Sets W$ONCE to 'Y' to prevent re-execution.
  12. This block (B1-E1) runs once to initialize the lookup key for GSTABL.

  13. Main Processing Loop (Level 1, L1):

  14. Company Lookup:
    • For each record in BBFRTB (indicator 01), perform a CHAIN operation on BICONT using BFCONO (company code) to retrieve BCNAME (company name).
    • If the lookup fails (indicator 99 on), set BCNAME to blanks.
  15. Time and Date Setup:
    • Retrieve system time into TIME12 (12 chars).
    • Move TIME12 to TIME (6 chars) and DATE (6 chars) for report formatting.
    • Initialize PAGE to 0 for pagination.
  16. Record Processing (DO Loop):

    • For each BBFRTB record (indicator 01):
    • Clear R$UMDS (U/M description) to blanks.
    • If BFFRUM (unit of measure) is not blank:
      • Move BFFRUM to K$FRUM (table code in the key).
      • Perform a CHAIN on GSTABL using KLFRUM (K$UNMS + K$FRUM) to retrieve TBDESC (U/M description).
      • If the lookup succeeds (indicator 98 off), move TBDESC to R$UMDS.
      • If the lookup fails (indicator 98 on), move error message (ERR,01: "INVALID U/M CODE") to R$UMDS.
  17. Report Output (OPRINT Specifications):

  18. Header Lines (H):
    • Printed at level 1 (L1) with overflow (OF) or no overflow (NL1).
    • Line 1: Company name (BCNAME, pos 1-30), "PAGE" (pos 104), page number (PAGE, pos 108, zero-suppressed), date (DATE, pos 120, formatted).
    • Line 2: Report title " FREIGHT TABLE CODE FILE " (pos 73-77), time (TIME, pos 120, formatted as "HH.MM.SS").
  19. Detail Lines (D):
    • Printed at level 1 (L1) with overflow (OF) or no overflow (NL1).
    • Separator lines with asterisks (pos 24, 48, 72, 96, 120, 132).
    • Column headers:
    • "FREIGHT TABLE CODE" (pos 10)
    • "FREIGHT RATE PER GAL" (pos 22)
    • "FREIGHT RATE PER LBS" (pos 35)
    • "U/M" (pos 39)
    • "U/M DESCRIPTION" (pos 55)
    • "FREIGHT RATE PER U/M" (pos 84)
  20. Data Lines (D, Indicator 01):
    • Printed for each BBFRTB record (indicator 01).
    • Fields:
    • BFDEL (pos 1): Delete code.
    • BFFRCD (pos 8): Freight code.
    • BFRATE (pos 21): Freight rate per gallon (likely reformatted as BFRATE3 for output).
    • BFFRLB (pos 34): Freight rate per pound (likely reformatted as BFFRLB3).
    • BFFRUM (pos 39): Unit of measure.
    • R$UMDS (pos 70): Unit of measure description.
    • BFFRPU (pos 83): Freight rate per unit of measure (likely reformatted as BFFRPU3).

Business Rules

The program enforces the following business rules: 1. Company Name Lookup: - For each freight table record, the program retrieves the company name from BICONT using the company code (BFCONO). If no match is found, the company name is blank. 2. Unit of Measure Validation: - If a freight record has a non-blank unit of measure (BFFRUM), the program looks up its description in GSTABL using the composite key (K$UNMS='BIUNMS', K$FRUM=BFFRUM). - If the lookup fails, an error message ("INVALID U/M CODE") is displayed in the report. 3. Report Formatting: - The report includes a header with company name, page number, date, and time. - Freight data is organized by code, rates (per gallon, pound, and unit of measure), and unit of measure description. - Records marked with a delete code (BFDEL) are included in the report, allowing visibility of potentially inactive records. 4. Pagination: - The program tracks page numbers (PAGE) and includes them in the header. - Overflow handling ensures proper formatting across pages.

Tables (Files) Used

The program uses the following files: 1. BBFRTB (Input Primary): - Purpose: Contains freight table data (codes, rates, units of measure). - Fields: BFDEL, BFCONO, BFFRCD, BFRATE, BFFRLB, BFFRUM, BFFRPU. 2. BICONT (Input Full-Procedural, Indexed): - Purpose: Stores company information. - Field: BCNAME (company name). 3. GSTABL (Input Full-Procedural, Indexed): - Purpose: Stores unit of measure descriptions. - Fields: TBTYPE, TBCODE, TBDESC. 4. PRINT (Output): - Purpose: Printer file for generating the freight table report.

External Programs Called

  • None: The RPG program does not explicitly call any external programs (e.g., via CALL operations). It operates self-contained, relying on file I/O and internal logic.

Additional Notes

  • Field Formatting: The output fields BFRATE3, BFFRLB3, and BFFRPU3 suggest reformatted versions of BFRATE, BFFRLB, and BFFRPU (likely with decimal places or specific formatting), but the RPG code does not show explicit conversion. This might be handled implicitly by RPG or defined elsewhere.
  • Error Handling: The program handles invalid unit of measure codes gracefully by outputting an error message in the report.
  • System/36 Context: The program assumes a System/36 environment with specific file structures and indexing. The ?9? labels from the OCL are not reflected in the RPG but are likely resolved at runtime.
  • Potential Enhancements: If you have additional code (e.g., for field formatting or subroutines), I can provide a more detailed analysis. If you need clarification on specific RPG operations or System/36 behavior, let me know!

Summary

  • Process Steps: Initialize lookup key, read freight table records, lookup company name and unit of measure descriptions, format and print a report with headers and data lines.
  • Business Rules: Lookup company names, validate unit of measures, include delete codes, and format reports with pagination.
  • Tables Used: BBFRTB (freight data), BICONT (company data), GSTABL (U/M descriptions), PRINT (output).
  • External Programs: None.

If you have further details or related code, please share for a deeper analysis!