The call stack involves two RPG programs: BB910 (main program for National Diesel Fuel Index maintenance and inquiry) and GB730P (called for history inquiry). Below, I identify the use cases implemented by this call stack and provide a function requirement document for each, assuming they are large functions that process inputs programmatically rather than through screen interactions.
Use Cases Implemented¶
Based on the functionality of BB910 and GB730P, the following use cases are implemented:
- Maintain National Diesel Fuel Index Records:
- Allows users to create, update, or delete National Diesel Fuel Index records for a given company, effective date, time, and region, with changes logged in the history file.
-
Implemented in BB910 (subroutines
srsfl1,srsfl2,sf1prc,sf2prc,sf2upd). -
Inquire National Diesel Fuel Index Records:
- Enables users to view National Diesel Fuel Index records without modification, displaying records by company, effective date, time, and region.
-
Implemented in BB910 (subroutines
srsfl1,srsfl2,sf1s05). -
View History of National Diesel Fuel Index Records:
- Displays historical changes (create, update, delete) for National Diesel Fuel Index records, including details like change date, time, user, region, and price.
- Implemented in GB730P (called via F09 in
srsfl2of BB910).
Function Requirement Documents¶
Each use case is reimagined as a large function that takes inputs programmatically and returns outputs, focusing on business requirements and calculations where applicable. The documents are concise, outlining process steps, inputs, outputs, and business rules.
Use Case 1: Maintain National Diesel Fuel Index Records¶
Function Requirement Document: MaintainDieselFuelIndex¶
Purpose¶
Create, update, or delete National Diesel Fuel Index records for a company, effective date, time, and region, logging changes to the history file.
Inputs¶
- CompanyCode: 2-digit numeric company code.
- FileGroup: Single character (
ZorG) for file overrides. - Records: Array of records, each containing:
- EffectiveDate: 8-digit numeric date (YYYYMMDD).
- EffectiveTime: 4-digit numeric time (HHMM).
- Region: 3-character region code.
- Price: 9.4 packed decimal price (or 0 for deletion).
- Action: String (
CREATE,UPDATE,DELETE). - UserID: 8-character user identifier.
Outputs¶
- Status: String (
SUCCESS,ERROR). - ErrorMessages: Array of error messages (if any).
- UpdatedRecords: Array of updated records with occurrence count.
Process Steps¶
- Validate Inputs:
- Verify
CompanyCodeexists inbicontfile. - Validate
EffectiveDateusing date validation logic. - Ensure
EffectiveTimeis valid (00:00–23:59). - Check
Regionexists ingstabl(forCREATE/UPDATE). - For
CREATE, ensure record does not exist inbbndfi. - For
UPDATE/DELETE, ensure record exists inbbndfi. - Apply File Overrides:
- Use
FileGroupto override files (gbbndfi/zbbndfi,gbicont/zbicont, etc.). - Process Records:
- For each record in
Records:- CREATE: Write new record to
bbndfiwithCompanyCode,EffectiveDate,EffectiveTime,Region,Price. - UPDATE: Update existing record in
bbndfiwith newPrice. - DELETE: Delete record from
bbndfi(set price to 0). - Write history record to
bbndfihwith action details (deletion flag, company, date, time, region, price, change date, change time,UserID). - Update occurrence count for the effective date/time.
- CREATE: Write new record to
- Return Results:
- If successful, return
SUCCESSand updated records. - If errors occur, return
ERRORwith error messages.
Business Rules¶
- Company Validation:
CompanyCodemust exist inbicont, else return errorERR0021. - Date Validation:
EffectiveDatemust be valid (YYYYMMDD format), else return errorERR0020. - Time Validation:
EffectiveTimemust be valid (HHMM, 00:00–23:59). - Record Existence:
CREATEfails if record exists (ERR0101).UPDATE/DELETEfails if record does not exist (ERR0102).- Region Validation: For
CREATE/UPDATE,Regionmust exist ingstabl. - History Logging: Every action (create, update, delete) must log to
bbndfihwith change date, time, andUserID. - Price Handling: Price is 9.4 packed decimal; deletion sets price to 0.
Calculations¶
- Occurrence Count: Increment count for each unique
EffectiveDate/EffectiveTimecombination after processing. - Change Date/Time: Use system date (YYYYMMDD) and time (HHMMSS) for history records.
Use Case 2: Inquire National Diesel Fuel Index Records¶
Function Requirement Document: InquireDieselFuelIndex¶
Purpose¶
Retrieve and return National Diesel Fuel Index records for a company, optionally filtered by effective date, time, or region.
Inputs¶
- CompanyCode: 2-digit numeric company code.
- FileGroup: Single character (
ZorG) for file overrides. - EffectiveDate: 8-digit numeric date (YYYYMMDD, optional).
- EffectiveTime: 4-digit numeric time (HHMM, optional).
- Region: 3-character region code (optional).
Outputs¶
- Status: String (
SUCCESS,ERROR). - ErrorMessages: Array of error messages (if any).
- Records: Array of records, each containing:
- EffectiveDate: 8-digit numeric date (YYYYMMDD).
- EffectiveTime: 4-digit numeric time (HHMM).
- Region: 3-character region code.
- Price: 9.4 packed decimal price.
- OccurrenceCount: Numeric count of records for the date/time.
Process Steps¶
- Validate Inputs:
- Verify
CompanyCodeexists inbicontfile. - If provided, validate
EffectiveDateusing date validation logic. - If provided, ensure
EffectiveTimeis valid (00:00–23:59). - If provided, check
Regionexists ingstabl. - Apply File Overrides:
- Use
FileGroupto override files (gbbndfi/zbbndfi,gbicont/zbicont,gbbndfird/zbndfird). - Retrieve Records:
- Query
bbndfiusingCompanyCodeand optional filters (EffectiveDate,EffectiveTime,Region). - For each matching record, retrieve
EffectiveDate,EffectiveTime,Region,Price, and calculateOccurrenceCount. - If
Regionis provided, filter by region usingbbndfird. - Return Results:
- Return
SUCCESSand retrieved records, orERRORwith error messages if validation fails.
Business Rules¶
- Company Validation:
CompanyCodemust exist inbicont, else return errorERR0021. - Date Validation: If provided,
EffectiveDatemust be valid (YYYYMMDD), else return errorERR0020. - Time Validation: If provided,
EffectiveTimemust be valid (HHMM, 00:00–23:59). - Region Validation: If provided,
Regionmust exist ingstabl. - Read-Only: No modifications to data are allowed.
- Occurrence Count: Count unique records for each
EffectiveDate/EffectiveTimecombination.
Calculations¶
- Occurrence Count: Count records in
bbndfifor the sameEffectiveDateandEffectiveTime.
Use Case 3: View History of National Diesel Fuel Index Records¶
Function Requirement Document: ViewDieselFuelIndexHistory¶
Purpose¶
Retrieve and return historical changes (create, update, delete) for National Diesel Fuel Index records for a company, effective date, time, and region.
Inputs¶
- CompanyCode: 2-digit numeric company code.
- FileGroup: Single character (
ZorG) for file overrides. - EffectiveDate: 8-digit numeric date (YYYYMMDD).
- EffectiveTime: 4-digit numeric time (HHMM).
- Region: 3-character region code.
Outputs¶
- Status: String (
SUCCESS,ERROR). - ErrorMessages: Array of error messages (if any).
- HistoryRecords: Array of history records, each containing:
- ChangeDate: 8-digit numeric date (YYYYMMDD).
- ChangeTime: 6-digit numeric time (HHMMSS).
- UserID: 8-character user identifier.
- Region: 3-character region code.
- Price: 9.4 packed decimal price.
- Action: String (
CREATE,UPDATE,DELETE).
Process Steps¶
- Validate Inputs:
- Verify
CompanyCodeexists inbicontfile. - Validate
EffectiveDateusing date validation logic. - Ensure
EffectiveTimeis valid (00:00–23:59). - Check
Regionexists ingstabl. - Apply File Overrides:
- Use
FileGroupto override files (gbbndfihx/zbbndfihx,gbicont/zbicont). - Retrieve History Records:
- Query
bbndfihxusingCompanyCode,EffectiveDate,EffectiveTime, andRegion. - For each matching record, retrieve
ChangeDate,ChangeTime,UserID,Region,Price, and determineActionbased on deletion flag (lhdel). - Return Results:
- Return
SUCCESSand history records, orERRORwith error messages if validation fails.
Business Rules¶
- Company Validation:
CompanyCodemust exist inbicont, else return errorERR0021. - Date Validation:
EffectiveDatemust be valid (YYYYMMDD), else return errorERR0020. - Time Validation:
EffectiveTimemust be valid (HHMM, 00:00–23:59). - Region Validation:
Regionmust exist ingstabl. - Read-Only: No modifications to data are allowed.
- Action Determination: Map
lhdelflag toAction: Y→DELETE.N→CREATEorUPDATE(based on context inbbndfihx).
Calculations¶
- None required; data is retrieved directly from
bbndfihx.
Summary¶
The call stack implements three use cases: maintaining (create/update/delete) National Diesel Fuel Index records, inquiring records, and viewing their history. Each function requirement document reimagines the interactive processes in BB910 and GB730P as programmatic functions, focusing on business rules like input validation, file overrides, and history logging. Calculations are minimal, primarily involving occurrence counts and date/time formatting. The functions ensure data integrity and provide clear outputs for integration into larger systems.