Skip to content

BB714 RPG36

The provided BB714.rpg36.txt is an RPG program (for IBM System/36 or AS/400) called by the BB715.ocl36.txt OCL program as part of the preprocessing for the "Daily Requirements Report." Its primary function is to convert quantities from pounds (LBS) to gallons (GAL) for specific orders in the BB713M file, using conversion factors from the GSUMCV file, and update the unit of measure and container code as needed. Below, I’ll explain the process steps, business rules, tables (files) used, and external programs called.

Process Steps of the RPG Program

The BB714 RPG program processes records from BB713M, applies unit conversions for specific conditions, and updates the output file. Here’s a step-by-step breakdown:

  1. Program Initialization:
  2. Header (H-spec): Line 0002 defines the program name (BB714) and page length (P064).
  3. File Definitions (F-spec):
    • BB713M: Update file (input/output, 530 bytes, disk, Line 0008).
    • GSUMCV: Input file (64 bytes, indexed with 12 keys, disk, Line 0010).
  4. Input Definitions (I-spec):
    • BB713M (Lines 0017–0029):
    • BDDEL (1): Delete flag ('D' for deleted).
    • BDCO (2–3): Company number.
    • BDORD# (4–9): Order number.
    • BDSEQ (10–12): Detail line sequence.
    • BDLOC (22–24): Location.
    • BDPROD (25–28): Product code.
    • BDTANK (29–32): Tank code.
    • BDQTY (35–41): Container quantity.
    • BDPRCE (42–50): Price.
    • BDUM (51–53): Unit of measure (e.g., 'LBS', 'GAL').
    • BDCSTK (54–73): Customer stock number.
    • BDDESC (75–104): Description.
    • BDCNTR (121–123): Container code.
    • GSUMCV (Lines 0016–0025):
    • UCKEY (2–13): Key field.
    • UCDEL (1): Delete flag ('D' for deleted).
    • UCCONO (2–3): Company number.
    • UCPROD (4–7): Product code.
    • UCFUNM (8–10): From unit of measure.
    • UCTUNM (11–13): To unit of measure.
    • UCOPER (14): Operand ('M' for multiply, 'D' for divide).
    • UCCVFA (15–26): Conversion factor.
  5. Indicators:

    • 01: Triggers record processing.
    • 02: Skips to program end.
    • 78: Set for specific condition (BDPROD = '4317', BDUM = 'LBS', BDQTY = 49000).
    • 99: Indicates chain failure on GSUMCV.
  6. Main Processing Loop (Lines 0043–end of C-specs):

  7. Condition: Indicator 02 on skips to END tag, terminating the program (Line 0043).
  8. Processing for Indicator 01 (Line 0045):

    • Special Case Check (Lines 0045–0049):
    • If BDPROD = '4317', BDUM = 'LBS', and BDQTY = 49000, sets indicator 78 and skips further processing for the record.
    • Pounds to Gallons Conversion (Lines 0050–0058):
    • If BDUM = 'LBS' and BDCNTR = '001':
      • Builds a key (KEY12) combining BDCO and BDPROD with 'LBSGAL' (Lines 0052–0055).
      • Chains GSUMCV using KEY12 to find a conversion factor (Line 0056).
      • If found (N99):
      • Divides BDQTY by UCCVFA to get QTY (gallons, Line 0057).
      • Writes an exception output ONE to BB713M, updating:
        • BDUM to 'GAL' (position 51–53).
        • BDQTY to QTY (position 35–41).
        • BDCNTR to '001' (position 121–123).
      • Jumps to END to process the next record (Line 0058).
    • Gallons with Container Code '002' (Lines 0059–0062):
    • If BDUM = 'GAL' and BDCNTR = '002':
      • Writes an exception output TWO to BB713M, updating:
      • BDCNTR to '001' (position 121–123).
      • No quantity conversion is performed.
    • End of Loop: Continues to the next BB713M record until indicator 02 is set or end-of-file.
  9. Output to BB713M:

  10. Exception Output ONE (Lines post-0062):
    • Updates BB713M record with:
    • BDUM = 'GAL' (position 53).
    • BDQTY = QTY (position 41, converted quantity).
    • BDCNTR = '001' (position 123).
  11. Exception Output TWO (Lines post-0062):

    • Updates BB713M record with:
    • BDCNTR = '001' (position 123).
  12. Program Termination:

  13. The END tag is reached when indicator 02 is set or all records are processed, ending the program.

Business Rules

  1. Special Case for Product 4317:
  2. If the product code is '4317', unit of measure is 'LBS', and quantity is exactly 49,000, indicator 78 is set, and no further conversion is performed for that record.
  3. This likely flags a specific condition (e.g., a standard batch size) that bypasses conversion.

  4. Pounds to Gallons Conversion:

  5. For records with BDUM = 'LBS' and BDCNTR = '001':
    • Looks up a conversion factor in GSUMCV using a key combining company number (BDCO), product code (BDPROD), and 'LBSGAL'.
    • Converts quantity (BDQTY) to gallons by dividing by the conversion factor (UCCVFA).
    • Updates the record to BDUM = 'GAL' and BDCNTR = '001'.
  6. If no conversion factor is found (99 on), skips conversion and moves to the next record.

  7. Gallons with Container Code '002':

  8. For records with BDUM = 'GAL' and BDCNTR = '002':

    • Updates the container code to '001' without changing the quantity.
    • This ensures consistency in container codes for gallon-based records.
  9. Record Skipping:

  10. Records not matching the above conditions (e.g., BDUM ≠ 'LBS' or 'GAL', or BDCNTR ≠ '001' or '002') are not updated and pass through unchanged.

Tables (Files) Used

  • Input Files:
  • BB713M: Update file (530 bytes), contains order data to be processed.
    • Fields: BDDEL (1), BDCO (2–3), BDORD# (4–9), BDSEQ (10–12), BDLOC (22–24), BDPROD (25–28), BDTANK (29–32), BDQTY (35–41), BDPRCE (42–50), BDUM (51–53), BDCSTK (54–73), BDDESC (75–104), BDCNTR (121–123).
  • GSUMCV: Input file (64 bytes, indexed with 12 keys), contains unit conversion factors.

    • Fields: UCKEY (2–13), UCDEL (1), UCCONO (2–3), UCPROD (4–7), UCFUNM (8–10), UCTUNM (11–13), UCOPER (14), UCCVFA (15–26).
  • Output File:

  • BB713M: Updated with exception outputs ONE and TWO:
    • ONE: Sets BDUM = 'GAL', BDQTY = QTY, BDCNTR = '001'.
    • TWO: Sets BDCNTR = '001'.

External Programs Called

  • None: The BB714 program does not explicitly call other programs. It performs all processing internally using file I/O and exception outputs.

Notes

  • Integration with OCL: The BB715.ocl36.txt calls BB714 after BB713 to convert quantities in BB713M from pounds to gallons, preparing data for subsequent steps (BB714A, #GSORT, BB715).
  • Error Handling: Uses indicator 99 to handle missing conversion factors in GSUMCV. No explicit error messages are output, as this is a preprocessing step.
  • Limited Scope: The program only processes records with specific conditions (BDUM = 'LBS' or 'GAL', BDCNTR = '001' or '002'), leaving others unchanged.
  • Conversion Logic: Assumes UCOPER = 'D' (divide) for LBS-to-GAL conversion, as implied by the division operation (BDQTY / UCCVFA).

Summary

The BB714 RPG program processes BB713M records to convert quantities from pounds to gallons for specific conditions (BDUM = 'LBS', BDCNTR = '001') using conversion factors from GSUMCV, updates the unit of measure to 'GAL', and standardizes container codes to '001'. It also handles a special case for product '4317' with 49,000 LBS. The program uses BB713M and GSUMCV files, updates BB713M, and calls no external programs.

Files Used: BB713M, GSUMCV. External Programs: None.

If you need further details (e.g., conversion factor format, subsequent programs like BB714A), or additional files, let me know!