The provided call stack (BB715.ocl36.txt
, BB715P.rpg36.txt
, BB713.rpg36.txt
, BB714.rpg36.txt
, BB714A.rpg36.txt
, and BB715.rpg36.txt
) orchestrates the generation of a "Daily Requirements Report" on an IBM System/36 or AS/400 system. Below, I will identify the use cases implemented by this call stack and then provide a function requirement document for a large function that processes inputs to produce the report without screen interaction, focusing on business requirements and necessary calculations.
List of Use Cases Implemented¶
The call stack implements the following use cases, each representing a distinct business function within the process of generating the Daily Requirements Report:
- Input Validation for Report Parameters:
- Description: Validates user-provided parameters (company number, start date, job queue option, and number of report copies) to ensure they meet the requirements for report generation.
- Program:
BB715P.rpg36.txt
. -
Details:
- Validates the company number against
BICONT
, ensuring it exists and is not marked as deleted. - Ensures the start date is valid (MMDDYY format, month 01–12, day 01–31, not a weekend unless allowed).
- Verifies the job queue parameter is ' ', 'N', or 'Y'.
- Defaults the number of copies to 1 if zero.
- Displays errors on a screen (
BB715PFM
) if validation fails, looping until corrected or canceled.
- Validates the company number against
-
Preprocessing Multi-Load and Non-Multi-Load Orders:
- Description: Processes order data to handle multi-load orders (splitting loads across days) and non-multi-load orders, creating an intermediate file for further processing.
- Program:
BB713.rpg36.txt
. -
Details:
- Reads order headers (
BBORDR
) and details (BBORDR2
). - For multi-load orders with a request date, calculates daily loads, skips weekends unless allowed, and writes daily records to
BB713M
. - For multi-load orders without a request date, writes a single record.
- For non-multi-load orders, copies all detail lines to
BB713M
.
- Reads order headers (
-
Unit Conversion (Pounds to Gallons):
- Description: Converts order quantities from pounds to gallons for specific products and container codes, updating the unit of measure and container code.
- Program:
BB714.rpg36.txt
. -
Details:
- Processes
BB713M
records withBDUM = 'LBS'
andBDCNTR = '001'
, converting quantities usingGSUMCV
conversion factors. - Updates
BDUM
to 'GAL' andBDCNTR
to '001'. - For
BDUM = 'GAL'
andBDCNTR = '002'
, updatesBDCNTR
to '001' without conversion. - Flags product '4317' with 49,000 LBS for special handling.
- Processes
-
Adding Sort Codes for Report Organization:
- Description: Enhances
BB713M
records by adding container type (bulk/packaged) and customer sort codes for sorting and grouping in the report. - Program:
BB714A.rpg36.txt
. -
Details:
- Retrieves container type (
TCCNTY
, 'B' or 'P') fromGSCNTR1
usingBDCNTR
. - Retrieves product class (
TPPRCL
) fromGSPROD
and customer sort code (TBCSRT
) fromGSTABL
using company and product class. - Updates
BB713M
withCNTY
(position 521) andCSRT
(position 523).
- Retrieves container type (
-
Sorting Order Data:
- Description: Sorts the preprocessed order data by specified fields to organize the report by company, location, and other criteria.
- Program:
#GSORT
(called inBB715.ocl36.txt
). -
Details:
- Sorts
BB713M
intoBB715S
by company, status code, location, bulk/packaged, container, unit of measure, and product. - Filters out deleted records and applies range checks (positions 10–12 between '000' and '900') and company code matches.
- Sorts
-
Generating the Daily Requirements Report:
- Description: Produces a formatted report showing daily and weekly order quantities, tank inventory, and available balance, grouped by company, location, and other criteria.
- Program:
BB715.rpg36.txt
. - Details:
- Reads sorted
BB715S
(mapped asBBORDR
), retrieves inventory fromINTKRY
/INTKRW
andINCHRT
, and company/location names fromBICONT
/INLOC
. - Calculates daily quantities (five days), weekly totals, and overage.
- Computes tank inventory and available balance using tank measurements and capacities.
- Outputs a printer file (
LIST
) with headers, detail lines, and totals.
- Reads sorted
Function Requirement Document¶
Below is a function requirement document for a large function that encapsulates the entire report generation process, taking inputs programmatically (instead of via screen interaction) and producing the report. The function consolidates the use cases into a single process, focusing on business requirements and calculations.
Daily Requirements Report Function Requirements¶
Function Overview¶
The GenerateDailyRequirementsReport
function generates a formatted report detailing daily and weekly order quantities, tank inventory, and available balance for a specified company and start date. It processes order data, converts units, adds sort codes, sorts records, and produces a printer-compatible output without screen interaction.
Inputs¶
- Company Number (
KYCO
, 2 characters): A valid company code from theBICONT
file. - Start Date (
KYSTDT
, 6 digits, MMDDYY): The start date for the report, in Gregorian format. - Job Queue Option (
KYJOBQ
, 1 character): ' ', 'N', or 'Y' to indicate job queue handling. - Number of Copies (
KYCOPY
, numeric): Number of report copies (defaults to 1 if 0). - File Inputs:
BBORDR
,BBORDR2
: Order header and detail files.BICONT
: Company data.INLOC
: Location data.INTKRY
,INTKRW
: Inventory transaction files.GSCTUM
: Unit of measure data.INCHRT
: Tank chart data.GSCNTR1
: Container type data.GSPROD
: Product data.GSUMCV
: Unit conversion factors.GSTABL
: Table data for sort codes.
Outputs¶
- Report File (
LIST
, printer format, 164 bytes): A formatted report with: - Headers: Company name, location, date, time, page number.
- Detail Lines: Container, product, description, unit of measure, daily quantities (5 days), weekly total, overage, tank inventory, balance.
- Totals: Unit of measure totals and differences.
- Temporary Files:
BB713M
(intermediate),BB715S
(sorted).
Process Steps¶
- Validate Inputs:
- Check
KYCO
exists inBICONT
and is not deleted (BCDEL ≠ 'D'
). - Validate
KYSTDT
is a valid date (month 01–12, day 01–31, considering leap years). - Ensure
KYSTDT
is not a Saturday or Sunday (unless allowed). - Verify
KYJOBQ
is ' ', 'N', or 'Y'. - Set
KYCOPY
to 1 if 0. -
Return error if validation fails (e.g., "INVALID COMPANY NUMBER", "INVALID DATE ENTERED", "CANNOT START ON SATURDAY OR SUNDAY", "INVALID PARAMETER ENTERED").
-
Preprocess Orders:
- Read
BBORDR
(headers) andBBORDR2
(details). - For multi-load orders (
BOMULO = 'Y'
):- If
BORQDT ≠ 0
, calculate daily loads (BOTOLO / BOLODA
, round up if remainder), skip weekends unlessBOWEPU = 'Y'
, and write daily records toBB713M
with calculated volume (BOLOVO * loads
) and dates. - If
BORQDT = 0
, write a single record withBORQD8
.
- If
- For non-multi-load orders (
BOMULO ≠ 'Y'
), write all matching detail lines toBB713M
. -
Account for shipped loads (
(BOTOLO * BOLOVO - BDQTY) / BOLOVO
). -
Convert Units:
- For
BB713M
records withBDUM = 'LBS'
andBDCNTR = '001'
:- Chain
GSUMCV
with key (BDCO
,BDPROD
, 'LBSGAL') to get conversion factor (UCCVFA
). - Convert quantity (
BDQTY / UCCVFA
) to gallons, updateBDUM = 'GAL'
,BDCNTR = '001'
.
- Chain
- For
BDUM = 'GAL'
andBDCNTR = '002'
, updateBDCNTR = '001'
. -
Flag product '4317' with
BDQTY = 49000
andBDUM = 'LBS'
for special handling (no conversion). -
Add Sort Codes:
- Chain
GSCNTR1
withBDCNTR
to get container type (TCCNTY
, 'B' or 'P'), write to position 521 (CNTY
). - Chain
GSPROD
withBDCO
andBDPROD
to get product class (TPPRCL
). -
Chain
GSTABL
withBDCO
andTPPRCL
(type 'PRODCL') to get customer sort code (TBCSRT
), write to position 523 (CSRT
). -
Sort Data:
- Sort
BB713M
intoBB715S
by:- Company (2–3).
- Status code (522–523).
- Location (22–24).
- Bulk/packaged (521).
- Container (121–123).
- Unit of measure (51–53).
- Product (25–28).
-
Exclude deleted records (
position 1 ≠ 'D'
) and records outside range (10–12 not between '000' and '900') or non-matching company. -
Generate Report:
- Read
BB715S
(asBBORDR
), group by company (BDCO
), location (BDLOC
), sort code (REFBLD
), bulk/packaged (BLKPKG
), container (BDCNTR
), unit of measure (BDUM
), and product (BDPROD
). - Retrieve company name (
BCNAME
) fromBICONT
and location name (ILNAME
) fromINLOC
. - For each group:
- Chain
INTKRY
/INTKRW
withIXCO
,IXLOC
,IXPRCD
,IXTANK
,IXCNTR
to get inventory quantities (IXQTFT
,IXQTSE
) and measurements (IXTOFT
,IXTOIN
). - Chain
INCHRT
to get tank capacity (TCSP1
). - Calculate available inches (
AVALIN = IXTOFT - TCSP1
). - Calculate available product (
FACT2 = (AVALIN * IXQTTA) / IXTOFT
). - If
INCHRT
lookup fails, useIXQTSE
for inventory. - Accumulate daily quantities (
D1QTY
toD5QTY
) for five days fromKYSTDT
based onBDRQD8
. - Compute weekly total (
L1QTY
,L2QTY
) and overage (OVQTY
,L2VQTY
). - Calculate balance (
L1DIFF = L1XINV - L1QTY - OVQTY
,L2DIFF = L2XINV - L2QTY - L2VQTY
).
- Chain
-
Output to
LIST
:- Headers: Company, location, date, time, page, day names, and column labels.
- Detail Lines: Container, product, description, unit of measure, daily quantities, weekly total, overage, tank inventory, balance.
- Totals: Unit of measure totals and differences.
-
Cleanup:
- Delete temporary files
BB713M
andBB715S
.
Business Rules¶
- Input Validation:
- Company must exist in
BICONT
and not be deleted. - Start date must be valid (MMDDYY, month 01–12, day 01–31, not Saturday/Sunday unless allowed).
- Job queue must be ' ', 'N', or 'Y'.
-
Copies default to 1 if 0.
-
Order Processing:
- Multi-load orders (
BOMULO = 'Y'
) with a request date are split into daily records, skipping weekends unlessBOWEPU = 'Y'
. - Multi-load orders without a request date produce one record.
- Non-multi-load orders include all detail lines.
-
Account for shipped loads in calculations.
-
Unit Conversion:
- Convert
LBS
toGAL
forBDCNTR = '001'
usingGSUMCV
factor. - Standardize
BDCNTR = '002'
to '001' for gallons. -
Flag product '4317' with 49,000 LBS for special handling.
-
Sorting:
- Group by company, status, location, bulk/packaged, container, unit of measure, and product.
-
Exclude deleted records and invalid ranges.
-
Report Generation:
- Group by company, location, sort code, bulk/packaged, container, unit of measure, and product.
- Include inventory from
INTKRY
/INTKRW
andINCHRT
. - Calculate available product based on tank capacity and measurements.
- Report daily quantities (5 days), weekly totals, overage, tank inventory, and balance.
Calculations¶
- Daily Loads:
REMDYS = BOTOLO / BOLODA
, round up if remainder. - Load Volume:
LOVO = BOLODA * BOLOVO
. - Shipped Loads:
SHLO = (BOTOLO * BOLOVO - BDQTY) / BOLOVO
. - Gallons Conversion:
QTY = BDQTY / UCCVFA
(fromGSUMCV
). - Available Inches:
AVALIN = IXTOFT - TCSP1
(fromINCHRT
). - Available Product:
FACT2 = (AVALIN * IXQTTA) / IXTOFT
. - Balance:
L1DIFF = L1XINV - L1QTY - OVQTY
,L2DIFF = L2XINV - L2QTY - L2VQTY
.
Error Handling¶
- Return specific error messages for invalid inputs (company, date, job queue).
- Skip records with missing reference data (
GSCNTR1
,GSPROD
,GSTABL
,INCHRT
) or use defaults (e.g.,IXQTSE
for inventory). - Log failures for missing files or records.
Assumptions¶
- Input files are pre-populated and accessible.
- Dates are processed in Gregorian and Julian formats for calculations.
- The report covers a five-day period starting from
KYSTDT
. - Inventory data is reliable; fallback to
IXQTSE
ifINCHRT
is unavailable.
Notes¶
- The function assumes programmatic input, bypassing the interactive screen (
BB715PFM
) used inBB715P
. - The call stack’s modularity (
BB713
,BB714
,BB714A
,#GSORT
,BB715
) is consolidated into a single function for simplicity. - The
MINCHT
program (implied in OCL) is assumed to be part of inventory processing withinBB715
, but its specifics are not detailed due to missing code. - The report format is preserved from
BB715.rpg36.txt
, with headers and totals as specified.
If you need further clarification, additional use cases, or specific code implementations (e.g., in a modern language), let me know!