Skip to content

MINLBGL1 RPGLE

The MINLBGL1.rpgle is an RPGLE program (converted from RPG, as implied by its structure and the use of /FREE syntax) called from the BB502.ocl36.txt OCL program or other programs like BB110 and MBBQTY (as referenced in MBBQTY.rpgle.txt). It is a utility module designed to convert between pounds (KYLBS) and net gallons (KYGAL) using the API gravity (KYGRAV) based on a standardized formula. Below, I’ll explain the process steps, business rules, tables used, and external programs called based on the provided RPG source code.


Process Steps of the RPG Program

The MINLBGL1 program converts between pounds and net gallons using two subroutines: LBGL11 (pounds to gallons) and GLLB11 (gallons to pounds). It also includes a legacy subroutine (CALC) for calculating a conversion factor, though this appears deprecated in favor of the updated formula (JB01). Here’s a step-by-step breakdown of the process:

  1. Program Initialization:
  2. The program defines input and output parameters via a parameter list (*ENTRY PLIST):
    • KYGRAV (3-digit signed decimal with 1 decimal place, API gravity).
    • KYLBS (7-digit signed integer, pounds, input/output).
    • KYGAL (7-digit signed integer, net gallons, input/output).
    • KYFACT (7-digit signed decimal with 3 decimal places, conversion factor, commented out per JB01).
  3. Work fields are defined for calculations:
    • w@wrk1 (12-digit, 10 decimal places): Intermediate specific gravity calculation.
    • w@wrk2 (15-digit, 10 decimal places): Intermediate factor calculation.
    • w@LBS (15-digit integer): Temporary pounds result.
    • w@GAL (15-digit integer): Temporary gallons result.
  4. The legacy CALC subroutine uses additional work fields: WRK62 (6-digit, 2 decimal places) and WRK73 (7-digit, 3 decimal places).

  5. Input Validation and Subroutine Selection:

  6. The program checks the input parameters:

    • If KYLBS is non-zero, it calls the LBGL11 subroutine to convert pounds to net gallons (JB01).
    • If KYGAL is non-zero, it calls the GLLB11 subroutine to convert net gallons to pounds (JB01).
    • If neither condition is met, it falls back to the legacy CALC subroutine (though this is likely unused due to the 1 ifne 1 condition, which is always false).
  7. Pounds to Gallons Conversion (LBGL11 Subroutine):

  8. The subroutine uses the API standard formula (JB01):
    • Calculate specific gravity: w@wrk1 = 141.5 / (131.5 + KYGRAV).
    • Calculate factor: w@wrk2 = w@wrk1 * 999.01599999999996.
    • Calculate net gallons: w@gal = KYLBS / w@wrk2 * 119.8.
  9. The result (w@gal) is moved to KYGAL for output.
  10. Calculations are performed in /FREE syntax for precision (high-precision work fields like w@wrk1 and w@wrk2).

  11. Gallons to Pounds Conversion (GLLB11 Subroutine):

  12. The subroutine uses the inverse API standard formula (JB01):
    • Calculate specific gravity: w@wrk1 = 141.5 / (131.5 + KYGRAV).
    • Calculate factor: w@wrk2 = w@wrk1 * 999.01599999999996.
    • Calculate pounds: w@lbs = KYGAL * w@wrk2 / 119.8.
  13. The result (w@lbs) is moved to KYLBS for output.

  14. Legacy Conversion Factor Calculation (CALC Subroutine):

  15. This subroutine (likely deprecated per JB01) calculates a conversion factor (KYFACT) using an older formula:
    • Calculate denominator: WRK62 = 131.5 + KYGRAV.
    • Calculate specific gravity: WRK73 = 141.5 / WRK62.
    • Calculate factor: KYFACT = WRK73 * 8.337193 (density in pounds per gallon).
  16. This factor was used for conversions (pounds / factor = gallons, gallons * factor = pounds) but is no longer used in favor of direct calculations in LBGL11 and GLLB11.

  17. Program Termination:

  18. The program sets the LR (Last Record) indicator and returns the updated KYLBS or KYGAL to the calling program via the parameter list.

Business Rules

The program enforces the following business rules, based on the code and change history:

  1. API Standard Formula (JB01):
  2. The program uses the API standard formula for converting between pounds and net gallons:
    • Pounds to gallons: Gallons = Pounds / ((141.5 / (131.5 + Gravity)) * 999.01599999999996) * 119.8.
    • Gallons to pounds: Pounds = Gallons * ((141.5 / (131.5 + Gravity)) * 999.01599999999996) / 119.8.
  3. This replaces the older formula (used in CALC) to ensure accuracy per API standards.

  4. Input-Driven Conversion:

  5. If KYLBS is non-zero, the program converts pounds to net gallons.
  6. If KYGAL is non-zero, the program converts net gallons to pounds.
  7. The program assumes only one of KYLBS or KYGAL is provided as input to avoid ambiguity.

  8. Precision in Calculations:

  9. High-precision work fields (w@wrk1, w@wrk2, w@LBS, w@GAL) ensure accurate results, with w@wrk1 and w@wrk2 using 10 decimal places for intermediate calculations.
  10. The constants 999.01599999999996 and 119.8 are used to align with API standards.

  11. Legacy Code Handling:

  12. The CALC subroutine, which computes a conversion factor (KYFACT), is included but likely unused due to the 1 ifne 1 condition (always false) and the revision in JB01 favoring direct calculations.

  13. No Database Access:

  14. The program relies entirely on input parameters (KYGRAV, KYLBS, KYGAL) and does not access any database files, making it a pure calculation module.

  15. No Error Handling:

  16. The program does not explicitly check for invalid inputs (e.g., negative gravity or zero values), assuming the calling program validates inputs.

Tables (Files) Used

The program does not use any database files. It is a standalone calculation module that operates solely on input parameters and internal variables.


External Programs Called

The program does not call any external programs. It performs all calculations internally using the LBGL11, GLLB11, and CALC subroutines.


Summary

The MINLBGL1 RPGLE program is a utility called from BB502, MBBQTY, or other programs like BB110 to convert between pounds (KYLBS) and net gallons (KYGAL) using the API gravity (KYGRAV). It implements the API standard formula (JB01) for accurate conversions, using subroutines LBGL11 (pounds to gallons) and GLLB11 (gallons to pounds). The legacy CALC subroutine for computing a conversion factor is likely deprecated. The program uses no database files or external programs, relying on high-precision internal calculations to return results to the calling program.

If you need further details on specific calculations, integration with MBBQTY or BB502, or additional analysis (e.g., X posts or web searches), let me know!