Skip to content

MINT6D RPGLE

The MINT6D.rpgle.txt is an RPGLE program (converted from RPG, as implied by its structure and comments) called from the BB502.ocl36.txt OCL program or other programs like IN080. It is a utility module designed to calculate the Table 6D factor (T6DFAC) used to convert gross quantities to net quantities (and vice versa) based on temperature (T6DTEM), gravity (T6DGRA), and volume correction factor code (T6DVCF). 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 MINT6D program calculates the Table 6D factor (T6DFAC) for converting gross gallons to net gallons (or vice versa) using a mathematical formula based on temperature, gravity, and predefined VCF (Volume Correction Factor) codes. It does not access any database files, relying solely on input parameters and internal calculations. Here’s a step-by-step breakdown of the process:

  1. Program Initialization:
  2. The program defines input parameters via a parameter list (*ENTRY PLIST):
    • T6DTEM (3-digit signed integer, temperature).
    • T6DGRA (3-digit signed decimal with 1 decimal place, gravity).
    • T6DVCF (2-character, VCF code).
    • T6DFAC (6-digit signed decimal with 5 decimal places, output factor).
  3. Additional variables are defined for calculations:
    • K0, K1 (10-digit, 4 decimal places), K2 (10-digit, 8 decimal places): Constants for VCF-based calculations.
    • P3, KX, DIF, DIFX, X1, X3, E, EXSUM: Intermediate variables for the formula.
  4. A debug flag (printbugs) is set to 'N' to disable debug output (commented-out printer file sysprt).

  5. Execute Table 6D Subroutine (TABL6D):

  6. The program immediately calls the TABL6D subroutine to perform the factor calculation.

  7. VCF Code and Temperature Checks:

  8. If the temperature (T6DTEM) is exactly 60°F, the factor (T6DFAC) is set to 1.000 and the program jumps to T6DEND (JB02).
  9. If the VCF code (T6DVCF) is blank or 'NA' (not applicable), the factor is set to 1.000 and the program jumps to T6DEND (JB01, line 0070).
  10. For valid VCF codes, the program assigns values to K0, K1, and K2 based on the VCF code:
    • 'CR' (Crude Oil): K0 = 341.0957, K1 = 0.0, K2 = 0.0.
    • 'FO' (Fuel Oil): K0 = 103.8720, K1 = 0.2701, K2 = 0.0.
    • 'JF' (Jet Fuel): K0 = 330.3010, K1 = 0.0, K2 = 0.0.
    • 'TZ' (Transition Zone): K0 = 1489.0670, K1 = 0.0, K2 = -0.00186840.
    • 'GA' (Gasoline): K0 = 192.4571, K1 = 0.2438, K2 = 0.0.
    • 'LU' (Lubricating Oil): K0 = 0.0, K1 = 0.34878, K2 = 0.0.
  11. If the VCF code is invalid (not listed above), the factor is set to 0.0 (line 0067).

  12. Calculate Intermediate Values:

  13. If a valid VCF code is found, the program jumps to the K0K1 tag and performs calculations:

    • Calculate P3 using the formula: P3 = (141.5 * 999.016) / (T6DGRA + 131.5) (line 0041, using /FREE syntax).
    • Calculate KX using: KX = ((K0 / P3) + K1) / P3 + K2 (line 0072, using /FREE syntax).
    • Calculate temperature difference: DIF = T6DTEM - 60.0068749 and DIFX = DIF + 0.013749795 (line 0087).
    • Calculate X1: X1 = KX * DIF (line 0088).
    • Calculate X3: X3 = X1 * (1 + (0.8 * KX * DIFX)) (line 0089, using /FREE syntax).
    • Calculate E: E = -X3 (line 0092).
  14. Calculate Exponential Sum (EXSUM):

  15. The program computes the exponential of E using a Taylor series approximation for exp(E) up to 10 terms:
    • EXSUM = 1 + E + (E²/2) + (E³/6) + (E⁴/24) + (E⁵/120) + (E⁶/720) + (E⁷/5040) + (E⁸/40320) + (E⁹/362880) + (E¹⁰/3628800) (line 0093, using /FREE syntax).
  16. The result is stored in EXSUM.

  17. Set Output Factor:

  18. The factor T6DFAC is set to EXSUM (line 0110).
  19. The program jumps to the T6DEND tag to complete the subroutine.

  20. Program Termination:

  21. The program sets the LR (Last Record) indicator and returns the T6DFAC value 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. Default Factor for Non-Temperature-Corrected Products (JB01):
  2. If the VCF code (T6DVCF) is blank, indicating the product does not require temperature correction, the factor (T6DFAC) is set to 1.000.

  3. Standard Temperature Rule (JB02):

  4. If the temperature (T6DTEM) is exactly 60°F, the factor is set to 1.000, as no correction is needed at the standard temperature.

  5. VCF Code-Based Calculations:

  6. The program supports specific VCF codes (CR, FO, JF, TZ, GA, LU, NA) with predefined constants (K0, K1, K2) for accurate volume correction based on product type (e.g., crude oil, fuel oil, gasoline).
  7. Invalid or unrecognized VCF codes result in a factor of 0.0, indicating a calculation failure.

  8. Precision in Calculations:

  9. The program uses high-precision variables (e.g., T6DFAC as 6S 5, KX as 10S 8) to ensure accurate volume corrections.
  10. The exponential calculation uses a 10-term Taylor series for precision (line 0093).

  11. No Database Access:

  12. The program relies entirely on input parameters (T6DTEM, T6DGRA, T6DVCF) and does not access any database files, making it a pure calculation module.

  13. Debug Output:

  14. Debug output to a printer file (sysprt) is commented out but can be enabled by setting printbugs = 'Y', logging intermediate values (P3, K0, K1, K2, KX, DIF, DIFX, X1, X3, E, EXSUM, T6DFAC).

Tables (Files) Used

The program does not use any database files. The commented-out sysprt printer file (132 bytes) is defined for potential debug output but is not active in the provided code.


External Programs Called

The program does not call any external programs. It is a standalone calculation module that performs all computations internally.


Summary

The MINT6D RPGLE program is a utility called from BB502 or other programs like IN080 to calculate the Table 6D factor (T6DFAC) for converting gross to net quantities (or vice versa) based on temperature (T6DTEM), gravity (T6DGRA), and VCF code (T6DVCF). It uses predefined constants (K0, K1, K2) for specific product types and a Taylor series approximation for exponential calculations. The program enforces rules for default factors (e.g., 1.000 for blank VCF or 60°F) and handles invalid VCF codes by returning 0.0. It uses no database files or external programs, relying solely on input parameters and internal math.

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