MBBQTY RPGLE
The MBBQTY.rpgle.txt RPGLE program is a module, not a standalone program, called by other programs (e.g., BB113) within the invoice posting workflow on an IBM System/36 or AS/400 environment. Its primary function is to convert order quantities to pounds (LBS) and gallons (GAL), calculate net and gross gallons, and determine shipping weight for invoice processing. The program includes revisions to improve conversion accuracy, handle specific units of measure (e.g., kilograms, liters, milliliters, ounces), and support viscosity barcode calculations. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.
Process Steps of the MBBQTY RPGLE Program¶
The MBBQTY program takes input parameters (e.g., company, product, container, order quantity, unit of measure) and converts the order quantity to pounds (NETLBS), net gallons (NGAL), gross gallons (GGAL), and shipping weight (SHPLBS). It uses data from the GSCTUM and GSCTWT files for conversion factors and weights, and calls the MINLBGL1 program for specific conversions.
Process Steps:¶
- Program Initialization:
- The program receives input parameters:
CO: Company number.PROD: Product code.CNTR: Container code (alpha/numeric, perJB09).CTQT: Order quantity.UM: Unit of measure (e.g.,LBS,GAL,KG,LI,ML,OZ).GRAV: Specific gravity for conversions.
- Output parameters:
NETLBS: Net weight in pounds (7 digits, 0 decimals).NGAL: Net gallons (7 digits, 2 decimals).GGAL: Gross gallons (7 digits, 2 decimals).SHPLBS: Shipping weight in pounds (7 digits, 0 decimals).
-
The program opens two input files:
GSCTUM: Unit of measure conversion file (256 bytes per record, input fileIF).GSCTWT: Container weight file (256 bytes per record, input fileIF).
-
Unit of Measure Conversion (GSCTUM):
- The program constructs a key (
UMKEY) usingCO,PROD, andCNTRto chain toGSCTUM. - If a matching record is found and not deleted (
UMDEL ≠ 'D'), it retrieves:UMFACT: Conversion factor to convert fromUMto gallons.T6DFAC: Conversion factor for gross gallons (if applicable).
- If no record is found or the record is deleted,
UMFACTis set to 1 (perJB01), assuming no conversion is needed. -
The program handles specific units of measure:
- LBS: Sets
NETLBS = CTQT, no further conversion needed. - GAL: Sets
NGAL = CTQT, calculatesNETLBSusingMINLBGL1. - KG (per
JB10): Converts kilograms to pounds (KG * 2.20462 = NETLBS), then to gallons usingMINLBGL1. - LI, ML, OZ (per
JB11): Does not requireGSCTUMrecord; uses predefined formulas (not detailed in the snippet) to convert to gallons and pounds. - Other units: Uses
UMFACTto convertCTQTtoNGAL(NGAL = CTQT * UMFACT).
- LBS: Sets
-
Gross Gallons Calculation (per JB03):
- For gross vehicle weight minus tare (GVW-TARE) calculations:
- Converts
CTQTtoNETLBSfirst, then toGGAL(gross gallons) usingT6DFACorMINLBGL1. - Calculates
NGAL(net gallons) fromNETLBSto ensure accuracy (avoids direct conversion to net gallons).
- Converts
-
For non-
LBS,GAL,ECHunits, convertsNGALtoCTQTusing the gallon-to-unit factor (perJB07). -
Net Gallons to Pounds Conversion:
-
For units requiring conversion to pounds (e.g.,
GAL,KG,LI,ML,OZ):- Initializes
KYGRAV(specific gravity),KYFACT(factor, set to 0),P@LBS(pounds, set to 0), andP@GAL(gallons, set toNGAL). - Calls
MINLBGL1with parametersKYGRAV,P@LBS, andP@GAL. MINLBGL1calculatesP@LBSbased on the formula (likelyP@LBS = P@GAL * KYGRAV * conversion factor).- Sets
NETLBS = P@LBS.
- Initializes
-
Shipping Weight Calculation (per JB02, JB05):
-
The program calculates the shipping weight (
SHPLBS) including packaging:- Constructs a key (
WTKEY) usingCO,PROD, andCNTRto chain toGSCTWT. - If a matching record is found, not deleted (
WTDEL ≠ 'D'or'I', perJB14), multiplies container quantity (CTQT) by gross weight (WTGROS) to setSHPLBS. - If no
GSCTWTrecord exists or is deleted/invalid, usesNETLBSasSHPLBSfor: UM = 'LBS':SHPLBS = NETLBS.UM = 'GAL':SHPLBS = NETLBS(perJB05).- Other units:
SHPLBS = NETLBS(default).
- Constructs a key (
-
Program Termination:
- The program jumps to the
ENDQTYtag after completing conversions. - Returns
NETLBS,NGAL,GGAL, andSHPLBSto the calling program. - Closes all files and ends the subroutine (
ENDSR).
Business Rules¶
- Unit of Measure Conversion:
- Converts order quantity (
CTQT) to pounds (NETLBS) and gallons (NGAL,GGAL) based on the unit of measure (UM). - Uses
GSCTUMfor conversion factors (UMFACT,T6DFAC); defaults to 1 if no record is found (perJB01). -
Supports specific units:
LBS:NETLBS = CTQT, no further conversion.GAL:NGAL = CTQT, converts toNETLBSviaMINLBGL1.KG: Converts to pounds (NETLBS = CTQT * 2.20462), then to gallons viaMINLBGL1(perJB10).LI,ML,OZ: Uses predefined formulas, does not requireGSCTUMrecord (perJB11).
-
Gross vs. Net Gallons (per JB03, JB06):
- For GVW-TARE calculations:
- Converts to
NETLBSfirst, then toGGAL(gross gallons). - Derives
NGAL(net gallons) fromNETLBSto ensure accuracy. - If possible, converts from pounds to unit of measure (
UM); if not, converts from gallons toUM(perJB06).
- Converts to
-
For non-
LBS,GAL,ECHunits, convertsNGALtoCTQTusing gallon-to-unit factor (perJB07). -
Shipping Weight Calculation (per JB02, JB05):
- Uses
GSCTWTfor gross weight (WTGROS) including packaging if available and valid (WTDEL ≠ 'D','I'). -
Defaults to
NETLBSforSHPLBSif no validGSCTWTrecord or forLBS,GAL, or other units. -
Kilogram Conversion (per JB10):
- Converts kilograms (
KG) to pounds using a fixed factor (KG * 2.20462 = NETLBS). -
Uses
MINLBGL1to convert pounds to gallons, reducing user errors from manual conversion factors. -
No GSCTUM Requirement for Certain Units (per JB11):
-
Units
LI(liters),ML(milliliters), andOZ(ounces) do not require aGSCTUMrecord; uses predefined formulas for conversion. -
Error Handling:
- If no
GSCTUMrecord is found, defaults to a conversion factor of 1 (perJB01). -
If no valid
GSCTWTrecord is found, usesNETLBSasSHPLBS. -
Integration with Calling Programs:
- Designed to be called by programs like
BB113for order quantity conversions during invoice processing. - Returns converted values (
NETLBS,NGAL,GGAL,SHPLBS) to the caller.
Tables (Files) Used¶
- GSCTUM:
- Description: Unit of measure conversion file.
- Attributes: 256 bytes per record, input file (
IF), disk-based. - Fields Used:
UMFACT: Conversion factor to gallons.T6DFAC: Conversion factor for gross gallons.UMDEL: Delete flag ('D'for deleted records).
- Purpose: Provides conversion factors for units of measure.
-
Usage: Chained using
UMKEY(company, product, container) to retrieve conversion factors. -
GSCTWT:
- Description: Container weight file.
- Attributes: 256 bytes per record, input file (
IF), disk-based. - Fields Used:
WTGROS: Gross weight including packaging.WTDEL: Delete flag ('D'or'I'for invalid/deleted records).
- Purpose: Provides gross weight for shipping calculations.
- Usage: Chained using
WTKEY(company, product, container) to calculateSHPLBS.
External Programs Called¶
- MINLBGL1:
- Description: Program to convert between pounds and gallons.
- Parameters:
KYGRAV: Specific gravity.P@LBS: Pounds (output).P@GAL: Gallons (input/output).
- Purpose: Calculates pounds from gallons (or vice versa) using specific gravity and conversion factors.
- Usage: Called to convert
NGALtoNETLBSfor units likeGAL,KG,LI,ML,OZ.
Summary¶
The MBBQTY RPGLE program, called by programs like BB113, converts order quantities to pounds (NETLBS), net gallons (NGAL), gross gallons (GGAL), and shipping weight (SHPLBS) by:
- Reading conversion factors from GSCTUM and weights from GSCTWT.
- Converting quantities based on unit of measure (UM), with special handling for LBS, GAL, KG, LI, ML, OZ.
- Calculating gross gallons from pounds (per JB03, JB06) and shipping weight from GSCTWT or NETLBS (per JB02, JB05).
- Using MINLBGL1 for pounds-to-gallons conversions (per JB04).
- Supporting kilograms with a fixed conversion factor (per JB10) and predefined formulas for LI, ML, OZ (per JB11).
- Returning converted values to the calling program.
Tables Used: GSCTUM (unit of measure conversions), GSCTWT (container weights).
External Programs Called: MINLBGL1 (pounds-to-gallons conversion).
This program ensures accurate quantity conversions for invoice processing, supporting the broader invoice posting workflow with robust handling of various units of measure and weight calculations.