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:
- Program Initialization:
- 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).
- 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.
-
The legacy
CALCsubroutine uses additional work fields:WRK62(6-digit, 2 decimal places) andWRK73(7-digit, 3 decimal places). -
Input Validation and Subroutine Selection:
-
The program checks the input parameters:
- If
KYLBSis non-zero, it calls theLBGL11subroutine to convert pounds to net gallons (JB01). - If
KYGALis non-zero, it calls theGLLB11subroutine to convert net gallons to pounds (JB01). - If neither condition is met, it falls back to the legacy
CALCsubroutine (though this is likely unused due to the1 ifne 1condition, which is always false).
- If
-
Pounds to Gallons Conversion (
LBGL11Subroutine): - 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.
- Calculate specific gravity:
- The result (
w@gal) is moved toKYGALfor output. -
Calculations are performed in
/FREEsyntax for precision (high-precision work fields likew@wrk1andw@wrk2). -
Gallons to Pounds Conversion (
GLLB11Subroutine): - 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.
- Calculate specific gravity:
-
The result (
w@lbs) is moved toKYLBSfor output. -
Legacy Conversion Factor Calculation (
CALCSubroutine): - 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).
- Calculate denominator:
-
This factor was used for conversions (pounds / factor = gallons, gallons * factor = pounds) but is no longer used in favor of direct calculations in
LBGL11andGLLB11. -
Program Termination:
- The program sets the
LR(Last Record) indicator and returns the updatedKYLBSorKYGALto the calling program via the parameter list.
Business Rules¶
The program enforces the following business rules, based on the code and change history:
- API Standard Formula (JB01):
- 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.
- Pounds to gallons:
-
This replaces the older formula (used in
CALC) to ensure accuracy per API standards. -
Input-Driven Conversion:
- If
KYLBSis non-zero, the program converts pounds to net gallons. - If
KYGALis non-zero, the program converts net gallons to pounds. -
The program assumes only one of
KYLBSorKYGALis provided as input to avoid ambiguity. -
Precision in Calculations:
- High-precision work fields (
w@wrk1,w@wrk2,w@LBS,w@GAL) ensure accurate results, withw@wrk1andw@wrk2using 10 decimal places for intermediate calculations. -
The constants
999.01599999999996and119.8are used to align with API standards. -
Legacy Code Handling:
-
The
CALCsubroutine, which computes a conversion factor (KYFACT), is included but likely unused due to the1 ifne 1condition (always false) and the revision in JB01 favoring direct calculations. -
No Database Access:
-
The program relies entirely on input parameters (
KYGRAV,KYLBS,KYGAL) and does not access any database files, making it a pure calculation module. -
No Error Handling:
- 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!