The call stack consists of three components: the OCL procedure (IN873.ocl36.txt
), the main RPG program (IN873.rpg36.txt
), and the called RPGLE module (MINLBGL1.rpgle.txt
). These components work together in an IBM System/36 or AS/400 environment to convert between pounds and net gallons for inventory or production purposes. Below, I will first identify the use cases implemented by this call stack and then provide a function requirement document for a non-interactive version of the primary use case, focusing on business requirements and calculations.
List of Use Cases¶
The call stack implements the following use cases, derived from the functionality of the IN873
program and its interaction with MINLBGL1
:
- Convert Pounds to Net Gallons Interactively
- Description: Allows a user to input a company number, product code, specific gravity (optional), and a quantity in pounds via a workstation interface. The program validates the inputs, retrieves product data if needed, and converts the pounds to net gallons using an API-standard formula.
- Components Involved:
IN873.ocl36.txt
: Loads theIN873
program and allocatesINCONT
andGSPROD
files.IN873.rpg36.txt
: Provides the interactive interface (screensIN873S1
andIN873S2
), validates inputs, retrieves specific gravity fromGSPROD
if not provided, and callsMINLBGL1
for the conversion.MINLBGL1.rpgle.txt
: Performs the pounds-to-gallons conversion using the formula:(Pounds / ((141.5 / (131.5 + API Gravity)) * 999.01599999999996)) * 119.8
.
-
Key Features:
- Validates company number against
INCONT
. - Validates product code and retrieves specific gravity from
GSPROD
if not provided. - Ensures only pounds are entered (not both pounds and gallons).
- Displays the product description and conversion result (gallons and pounds) on the screen.
- Validates company number against
-
Convert Net Gallons to Pounds Interactively
- Description: Allows a user to input a company number, product code, specific gravity (optional), and a quantity in gallons via a workstation interface. The program validates the inputs, retrieves product data if needed, and converts the gallons to pounds using an API-standard formula.
- Components Involved:
- Same as above (
IN873.ocl36.txt
,IN873.rpg36.txt
,MINLBGL1.rpgle.txt
). MINLBGL1.rpgle.txt
: Performs the gallons-to-pounds conversion using the formula:(Gallons * ((141.5 / (131.5 + API Gravity)) * 999.01599999999996)) / 119.8
.
- Same as above (
-
Key Features:
- Same validation and data retrieval as the pounds-to-gallons use case.
- Ensures only gallons are entered (not both pounds and gallons).
- Displays the product description and conversion result (pounds and gallons) on the screen.
-
Validate Company and Product Data Interactively
- Description: Validates the company number and product code entered by the user against the
INCONT
andGSPROD
files, respectively, and displays error messages if invalid. This is a supporting use case for the conversion process, ensuring data integrity before performing calculations. - Components Involved:
IN873.ocl36.txt
: AllocatesINCONT
andGSPROD
files.IN873.rpg36.txt
: Performs validation usingCHAIN
operations onINCONT
(for company number) andGSPROD
(for product code).
- Key Features:
- Displays "INVALID COMPANY NO" if the company number is not found in
INCONT
. - Displays "INVALID PRODUCT CODE" if the product code is not found in
GSPROD
. - Retrieves product description and specific gravity from
GSPROD
for valid product codes.
- Displays "INVALID COMPANY NO" if the company number is not found in
Function Requirement Document¶
The function requirement document assumes a non-interactive function that encapsulates the primary use case (bidirectional conversion between pounds and net gallons) without screen interaction. It takes all necessary inputs as parameters, performs validations and calculations, and returns the results. The document focuses on business requirements and concisely explains the process steps and calculations.
Function Requirement: Convert Pounds to Gallons or Gallons to Pounds¶
Purpose¶
Provide a non-interactive function to convert between pounds and net gallons for a specified company and product, using API gravity, with validation against inventory and product data.
Inputs¶
- Company Number (
KCO
, 2-digit numeric): Identifies the company, validated against theINCONT
file. - Product Code (
KPROD
, 4-character): Identifies the product, validated against theGSPROD
file. - Specific Gravity (
KGRAV
, 3.1 numeric): API gravity for the product; if zero, retrieved fromGSPROD
. - Pounds (
KLBS
, 7.0 numeric): Input quantity in pounds (for pounds-to-gallons conversion); must be zero if gallons provided. - Gallons (
KGAL
, 7.0 numeric): Input quantity in gallons (for gallons-to-pounds conversion); must be zero if pounds provided.
Outputs¶
- Output Pounds (
OLBS
, 9.0 numeric): Converted pounds (for gallons-to-pounds) or input pounds (for pounds-to-gallons). - Output Gallons (
OGAL
, 9.0 numeric): Converted gallons (for pounds-to-gallons) or input gallons (for gallons-to-pounds). - Product Description (
PRDS
, 30-character): Description of the product fromGSPROD
. - Error Code (numeric): Indicates success (0) or error (1: Invalid company, 2: Invalid product, 3: Both pounds and gallons provided).
- Error Message (35-character): Descriptive error message if applicable.
Process Steps¶
- Validate Company Number:
- Perform a lookup in the
INCONT
file usingKCO
. -
If not found, return error code 1 and message "INVALID COMPANY NO".
-
Validate Product Code:
- Construct a 6-byte key (
KCO + KPROD
) and perform a lookup in theGSPROD
file. - If not found, return error code 2 and message "INVALID PRODUCT CODE".
-
Retrieve product description (
TPDESC
) and specific gravity (TPGRAV
) fromGSPROD
. -
Validate Input Quantities:
-
If both
KLBS
andKGAL
are non-zero, return error code 3 and message "ENTER EITHER POUNDS OR GALLONS". -
Determine Specific Gravity:
- If
KGRAV
is zero, useTPGRAV
fromGSPROD
. -
If
KGRAV
is non-zero, use the provided value. -
Perform Conversion:
- If
KLBS
is non-zero (pounds-to-gallons):- Calculate specific gravity:
SG = 141.5 / (131.5 + KGRAV)
. - Calculate gallons:
OGAL = (KLBS / (SG * 999.01599999999996)) * 119.8
. - Set
OLBS = KLBS
.
- Calculate specific gravity:
-
If
KGAL
is non-zero (gallons-to-pounds):- Calculate specific gravity:
SG = 141.5 / (131.5 + KGRAV)
. - Calculate pounds:
OLBS = (KGAL * (SG * 999.01599999999996)) / 119.8
. - Set
OGAL = KGAL
.
- Calculate specific gravity:
-
Return Results:
- Return
OLBS
,OGAL
,PRDS
, error code (0 for success), and empty error message if no errors.
Business Rules¶
- Company Validation: The company number must exist in the
INCONT
file. - Product Validation: The product code must exist in the
GSPROD
file for the specified company. - Input Exclusivity: Either pounds or gallons can be provided, but not both.
- Specific Gravity Source: Use the provided
KGRAV
if non-zero; otherwise, useTPGRAV
fromGSPROD
. - Conversion Accuracy: Use the API-standard formula for conversions, applicable to petroleum or similar liquids.
- Error Handling: Return specific error codes and messages for invalid inputs to guide corrective action.
Calculations¶
- Specific Gravity:
SG = 141.5 / (131.5 + API Gravity)
. - Pounds to Gallons:
Net Gallons = (Pounds / (SG * 999.01599999999996)) * 119.8
. - Gallons to Pounds:
Pounds = (Gallons * (SG * 999.01599999999996)) / 119.8
. - Constants:
999.01599999999996
and119.8
are industry-specific adjustments for API gravity-based conversions.
Dependencies¶
- Files:
INCONT
: Inventory control file for company validation.GSPROD
: Product master file for product validation, description, and specific gravity.- External Modules: None (conversion logic is self-contained, adapted from
MINLBGL1
).
Additional Notes¶
- Use Case Selection: The function requirement document focuses on the primary use case (bidirectional conversion), combining both pounds-to-gallons and gallons-to-pounds into a single function for simplicity. The validation use case is incorporated as part of the input validation steps.
- Non-Interactive Design: The function eliminates screen interactions, taking all inputs as parameters and returning results directly, suitable for batch processing or integration with other systems.
- Calculation Details: The formulas are retained from
MINLBGL1
, with constants (999.01599999999996
,119.8
) specific to the API standard, likely for petroleum products. - Error Handling: The function includes robust error handling to ensure data integrity, aligning with the interactive program’s validation logic.
- Assumptions: The document assumes the function is called with valid numeric formats and that the
INCONT
andGSPROD
files are accessible in the same library as specified in the OCL procedure.
If you need further refinements or additional use cases documented as separate functions, please let me know!