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
srsfl2
of 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 (
Z
orG
) 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
CompanyCode
exists inbicont
file. - Validate
EffectiveDate
using date validation logic. - Ensure
EffectiveTime
is valid (00:00–23:59). - Check
Region
exists ingstabl
(forCREATE
/UPDATE
). - For
CREATE
, ensure record does not exist inbbndfi
. - For
UPDATE
/DELETE
, ensure record exists inbbndfi
. - Apply File Overrides:
- Use
FileGroup
to override files (gbbndfi
/zbbndfi
,gbicont
/zbicont
, etc.). - Process Records:
- For each record in
Records
:- CREATE: Write new record to
bbndfi
withCompanyCode
,EffectiveDate
,EffectiveTime
,Region
,Price
. - UPDATE: Update existing record in
bbndfi
with newPrice
. - DELETE: Delete record from
bbndfi
(set price to 0). - Write history record to
bbndfih
with 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
SUCCESS
and updated records. - If errors occur, return
ERROR
with error messages.
Business Rules¶
- Company Validation:
CompanyCode
must exist inbicont
, else return errorERR0021
. - Date Validation:
EffectiveDate
must be valid (YYYYMMDD format), else return errorERR0020
. - Time Validation:
EffectiveTime
must be valid (HHMM, 00:00–23:59). - Record Existence:
CREATE
fails if record exists (ERR0101
).UPDATE
/DELETE
fails if record does not exist (ERR0102
).- Region Validation: For
CREATE
/UPDATE
,Region
must exist ingstabl
. - History Logging: Every action (create, update, delete) must log to
bbndfih
with 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
/EffectiveTime
combination 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 (
Z
orG
) 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
CompanyCode
exists inbicont
file. - If provided, validate
EffectiveDate
using date validation logic. - If provided, ensure
EffectiveTime
is valid (00:00–23:59). - If provided, check
Region
exists ingstabl
. - Apply File Overrides:
- Use
FileGroup
to override files (gbbndfi
/zbbndfi
,gbicont
/zbicont
,gbbndfird
/zbndfird
). - Retrieve Records:
- Query
bbndfi
usingCompanyCode
and optional filters (EffectiveDate
,EffectiveTime
,Region
). - For each matching record, retrieve
EffectiveDate
,EffectiveTime
,Region
,Price
, and calculateOccurrenceCount
. - If
Region
is provided, filter by region usingbbndfird
. - Return Results:
- Return
SUCCESS
and retrieved records, orERROR
with error messages if validation fails.
Business Rules¶
- Company Validation:
CompanyCode
must exist inbicont
, else return errorERR0021
. - Date Validation: If provided,
EffectiveDate
must be valid (YYYYMMDD), else return errorERR0020
. - Time Validation: If provided,
EffectiveTime
must be valid (HHMM, 00:00–23:59). - Region Validation: If provided,
Region
must exist ingstabl
. - Read-Only: No modifications to data are allowed.
- Occurrence Count: Count unique records for each
EffectiveDate
/EffectiveTime
combination.
Calculations¶
- Occurrence Count: Count records in
bbndfi
for the sameEffectiveDate
andEffectiveTime
.
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 (
Z
orG
) 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
CompanyCode
exists inbicont
file. - Validate
EffectiveDate
using date validation logic. - Ensure
EffectiveTime
is valid (00:00–23:59). - Check
Region
exists ingstabl
. - Apply File Overrides:
- Use
FileGroup
to override files (gbbndfihx
/zbbndfihx
,gbicont
/zbicont
). - Retrieve History Records:
- Query
bbndfihx
usingCompanyCode
,EffectiveDate
,EffectiveTime
, andRegion
. - For each matching record, retrieve
ChangeDate
,ChangeTime
,UserID
,Region
,Price
, and determineAction
based on deletion flag (lhdel
). - Return Results:
- Return
SUCCESS
and history records, orERROR
with error messages if validation fails.
Business Rules¶
- Company Validation:
CompanyCode
must exist inbicont
, else return errorERR0021
. - Date Validation:
EffectiveDate
must be valid (YYYYMMDD), else return errorERR0020
. - Time Validation:
EffectiveTime
must be valid (HHMM, 00:00–23:59). - Region Validation:
Region
must exist ingstabl
. - Read-Only: No modifications to data are allowed.
- Action Determination: Map
lhdel
flag toAction
: Y
→DELETE
.N
→CREATE
orUPDATE
(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.