Below is a detailed analysis of the use cases implemented by the BB911 and GB730P RPG programs, followed by a function requirement document for a non-interactive version of the primary use cases, focusing on business requirements and calculations.
List of Use Cases Implemented¶
The call stack consists of two programs: BB911 (National Diesel Fuel Index Maintenance and Inquiry) and GB730P (Global File Tracking History Inquiry). Together, they support multiple use cases related to managing and querying fuel index data. The use cases are derived from the functionality described in the program specifications and code.
- Use Case 1: Inquire National Diesel Fuel Index Records
- Description: Allows users to view existing National Diesel Fuel Index records for a specified company and effective date in inquiry mode ('INQ').
- Program: BB911
-
Details:
- Displays records in subfile SFL1, showing effective date, time, retail price, and occurrence count.
- Supports direct access to specific records by entering company code, effective date, and time.
- Allows navigation through records using page down and refresh (F5).
- Validates company code against
bicontand effective date usingGSDTEDIT.
-
Use Case 2: Maintain National Diesel Fuel Index Records
- Description: Enables users to create, update, or delete National Diesel Fuel Index records in maintenance mode ('MNT').
- Program: BB911
-
Details:
- Create (Option 1): Adds new records to
bbrcscwith validated company code, effective date, time, and retail price. - Update (Option 2): Modifies existing records in
bbrcsc, updating fields like retail price. - Delete: Sets retail price to zero to mark records for deletion.
- Logs all changes to the history file
bbrcschusing thewritehistsubroutine. - Validates inputs (e.g., non-zero retail price, valid date/time) and checks for record existence to prevent duplicates or invalid updates.
- Uses subfile SFL2 for detailed record maintenance, supporting All or Review modes.
- Create (Option 1): Adds new records to
-
Use Case 3: View History of National Diesel Fuel Index Changes
- Description: Allows users to inquire about historical changes to National Diesel Fuel Index records, including change date, time, user, and modified fields.
- Program: BB911 and GB730P
-
Details:
- Initiated via F9 in BB911’s SFL2, calling GB730P with parameters (
x$hist) specifying the file (BBNDFI), company code, effective date, and time. - GB730P displays historical records from
bbndfihxin a subfile, showing change details like date (lhchd8), time (lhchtm), user (lhuser), and retail price (lhrprc). - Supports navigation through historical records and displays the most recent change date/time initially.
- Initiated via F9 in BB911’s SFL2, calling GB730P with parameters (
-
Use Case 4: Validate Input Data for Fuel Index Records
- Description: Ensures that input data (company code, effective date, time, retail price) is valid before creating or updating records.
- Program: BB911
-
Details:
- Validates company code against
bicont(errorERR0021if invalid). - Validates effective date using
GSDTEDIT(errorERR0020if invalid). - Validates effective time for valid hours and minutes (error
ERR0019if invalid). - Ensures retail price is non-zero for create/update operations (error
ERR0012if zero). - Checks for record existence to prevent duplicates on create (
ERR0101) or missing records on update (ERR0102).
- Validates company code against
-
Use Case 5: Log Changes to Fuel Index History
- Description: Automatically logs all create, update, and delete operations on National Diesel Fuel Index records to a history file.
- Program: BB911
- Details:
- Writes history records to
bbrcschwith details like company code, effective date, time, retail price, change date, change time, user, and delete flag (lhdel = 'D'for deletions). - Ensures auditability of all changes for tracking purposes.
- Writes history records to
Function Requirement Document¶
Function Name: ManageNationalDieselFuelIndex
Purpose: To provide a non-interactive function that manages (creates, updates, deletes) and inquires about National Diesel Fuel Index records, including logging changes to a history file and retrieving historical data, without requiring screen interaction.
Inputs: - FileGroup: String (1 char, 'G' or 'Z') – Specifies the library group for file overrides. - CompanyCode: Integer (2 digits) – Company identifier. - Mode: String (3 chars, 'INQ' or 'MNT') – Inquiry or maintenance mode. - Operation: String (6 chars, 'INQUIRE', 'CREATE', 'UPDATE', 'DELETE') – Specifies the action to perform. - EffectiveDate: Integer (8 digits, YYYYMMDD) – Effective date of the fuel index record. - EffectiveTime: Integer (4 digits, HHMM) – Effective time of the record. - Region: String (3 chars) – Region code for the fuel index (required for CREATE/UPDATE). - RetailPrice: Decimal (9.4) – Retail price per gallon (required for CREATE/UPDATE). - UserID: String (8 chars) – User performing the operation (for history logging).
Outputs: - Status: String – 'SUCCESS' or 'ERROR' indicating operation outcome. - ErrorMessage: String – Description of any error (e.g., 'Invalid company code'). - Records (for INQUIRE): Array of records containing: - EffectiveDate: Integer (8 digits, YYYYMMDD) - EffectiveTime: Integer (4 digits, HHMM) - Region: String (3 chars) - RetailPrice: Decimal (9.4) - OccurrenceCount: Integer (number of records for the effective date/time) - HistoryRecords (for INQUIRE with history): Array of history records containing: - ChangeDate: Integer (8 digits, YYYYMMDD) - ChangeTime: Integer (6 digits, HHMMSS) - UserID: String (8 chars) - RetailPrice: Decimal (9.4) - DeleteFlag: String (1 char, 'D' for deleted, blank otherwise)
Process Steps:
1. Validate Inputs:
- Check if FileGroup is 'G' or 'Z'; return error 'Invalid file group' if not.
- Validate CompanyCode against bicont table; return error 'Invalid company code (ERR0021)' if not found.
- If Mode = 'MNT' and Operation = 'INQUIRE', return error 'Inquiry not allowed in maintenance mode'.
- Validate EffectiveDate using date validation logic (similar to GSDTEDIT); return error 'Invalid effective date (ERR0020)' if invalid.
- Validate EffectiveTime for valid hours (00-23) and minutes (00-59); return error 'Invalid effective time (ERR0019)' if invalid.
- For CREATE/UPDATE, ensure RetailPrice is non-zero and Region is provided; return error 'Retail price cannot be zero (ERR0012)' or 'Region required' if invalid.
- For CREATE, check if a record exists in bbrcsc with CompanyCode, EffectiveDate, EffectiveTime, Region; return error 'Record already exists (ERR0101)' if found.
- For UPDATE/DELETE, check if a record exists; return error 'Record does not exist (ERR0102)' if not found.
- Apply File Overrides:
-
Based on
FileGroup, apply overrides to accessbbrcsc,bbrcsch,bbndfi,bbndfihx,bicont,gstabl, andbbrcscrdin the appropriate library (e.g.,gbbndfifor 'G',zbbndfifor 'Z'). -
Process Operation:
- INQUIRE:
- Retrieve records from
bbrcscmatchingCompanyCode,EffectiveDate, and optionallyEffectiveTime. - For each record, fetch the occurrence count by counting matching records in
bbrcscrdfor the sameEffectiveDateandEffectiveTime. - If history is requested, retrieve records from
bbndfihxfor the specified key fields. - Return an array of records with
EffectiveDate,EffectiveTime,Region,RetailPrice, andOccurrenceCount(for main records) orChangeDate,ChangeTime,UserID,RetailPrice,DeleteFlag(for history).
- Retrieve records from
- CREATE:
- Insert a new record into
bbrcscwithCompanyCode,EffectiveDate,EffectiveTime,Region, andRetailPrice. - Log the change to
bbrcschwithChangeDate(current date),ChangeTime(current time),UserID,RetailPrice, andDeleteFlag= blank. - Return 'SUCCESS'.
- Insert a new record into
- UPDATE:
- Update the existing record in
bbrcscwith the newRetailPricefor the specifiedCompanyCode,EffectiveDate,EffectiveTime, andRegion. - Log the change to
bbrcschwith current date, time,UserID,RetailPrice, andDeleteFlag= blank. - Return 'SUCCESS'.
- Update the existing record in
-
DELETE:
- Update the record in
bbrcscby settingRetailPriceto zero for the specifiedCompanyCode,EffectiveDate,EffectiveTime, andRegion. - Log the change to
bbrcschwith current date, time,UserID,RetailPrice= 0, andDeleteFlag= 'D'. - Return 'SUCCESS'.
- Update the record in
-
Log History (for CREATE/UPDATE/DELETE):
-
Write a history record to
bbrcschwith:lhco:CompanyCodelhefdt:EffectiveDatelheftm:EffectiveTimelhrprc:RetailPricelhchd8: Current date (YYYYMMDD)lhchtm: Current time (HHMMSS)lhuser:UserIDlhdel: 'D' for DELETE, blank otherwise.
-
Return Results:
- Return
Status,ErrorMessage(if any), andRecordsorHistoryRecordsarrays for INQUIRE operations.
Business Rules:
- Only valid company codes from bicont are allowed.
- Effective dates must be in YYYYMMDD format and pass date validation.
- Effective times must be in HHMM format with valid hours (00-23) and minutes (00-59).
- Retail price must be non-zero for CREATE and UPDATE operations.
- CREATE operations fail if a record with the same key (CompanyCode, EffectiveDate, EffectiveTime, Region) already exists.
- UPDATE and DELETE operations fail if the record does not exist.
- All changes (CREATE, UPDATE, DELETE) are logged to the history file for auditability.
- History inquiries retrieve all changes for the specified key fields, sorted by change date and time.
- File overrides ensure data is accessed from the correct library ('G' or 'Z').
- Inquiry mode ('INQ') restricts operations to read-only; maintenance mode ('MNT') allows CREATE, UPDATE, and DELETE.
Calculations:
- Date Conversion: For history inquiries, convert change date from YYYYMMDD to MMDDYY format for output (e.g., datymd * 100.0001 = datmdy, then %editc(datmdy: 'Y')).
- Occurrence Count: Count the number of records in bbrcscrd matching the EffectiveDate and EffectiveTime to provide the occurrence count for inquiry results.
- Current Date/Time for History: Use system date and time (e.g., JBDT## for date, time12 for time) to populate lhchd8 and lhchtm in history records.
Dependencies:
- Tables:
- bicont: Validates company code.
- gstabl: Provides region reference data.
- bbrcsc: Stores fuel index records (update/add).
- bbrcsch: Stores history records (output).
- bbrcsc1: Input for inquiry (renamed format).
- bbrcscrd: Input for detailed inquiry.
- bbndfi/bbndfihx: Used by GB730P for history inquiries.
- External Programs:
- GSDTEDIT: Validates dates (input: p#mdy, output: p#cymd, p#err).
- QCMDEXC: Executes file override commands.
- QMHSNDPM/QMHRMVPM: Handles error message queuing and removal.
Error Handling: - Return specific error messages for validation failures (e.g., 'ERR0021', 'ERR0012'). - Ensure all database operations are atomic to maintain data integrity. - Log errors to the message queue for traceability.
Function Requirement Document: ManageNationalDieselFuelIndex¶
Purpose¶
To manage and inquire about National Diesel Fuel Index records (create, update, delete, inquire) and log changes to a history file without screen interaction.
Inputs¶
- FileGroup: String (1 char, 'G' or 'Z') – Library group for file overrides.
- CompanyCode: Integer (2 digits) – Company identifier.
- Mode: String (3 chars, 'INQ' or 'MNT') – Inquiry or maintenance mode.
- Operation: String (6 chars, 'INQUIRE', 'CREATE', 'UPDATE', 'DELETE') – Action to perform.
- EffectiveDate: Integer (8 digits, YYYYMMDD) – Record effective date.
- EffectiveTime: Integer (4 digits, HHMM) – Record effective time.
- Region: String (3 chars) – Region code (required for CREATE/UPDATE).
- RetailPrice: Decimal (9.4) – Retail price per gallon (required for CREATE/UPDATE).
- UserID: String (8 chars) – User performing the operation.
Outputs¶
- Status: String – 'SUCCESS' or 'ERROR'.
- ErrorMessage: String – Error description (e.g., 'Invalid company code').
- Records (INQUIRE): Array of {EffectiveDate, EffectiveTime, Region, RetailPrice, OccurrenceCount}.
- HistoryRecords (INQUIRE with history): Array of {ChangeDate, ChangeTime, UserID, RetailPrice, DeleteFlag}.
Process Steps¶
- Validate Inputs:
- Check
FileGroup('G' or 'Z'); error if invalid. - Validate
CompanyCodeinbicont; error 'ERR0021' if not found. - Ensure
ModeandOperationcompatibility; error if 'INQUIRE' in 'MNT' mode. - Validate
EffectiveDate(YYYYMMDD) via date validation; error 'ERR0020' if invalid. - Validate
EffectiveTime(HHMM, 00-23:00-59); error 'ERR0019' if invalid. - For CREATE/UPDATE, ensure
RetailPrice> 0 andRegionprovided; error 'ERR0012' or 'Region required' if invalid. - For CREATE, check
bbrcscfor existing record; error 'ERR0101' if found. -
For UPDATE/DELETE, check
bbrcscfor record; error 'ERR0102' if not found. -
Apply File Overrides:
-
Override
bbrcsc,bbrcsch,bbndfi,bbndfihx,bicont,gstabl,bbrcscrdto 'G' or 'Z' library based onFileGroup. -
Process Operation:
- INQUIRE:
- Fetch records from
bbrcscmatchingCompanyCode,EffectiveDate,EffectiveTime. - Calculate occurrence count from
bbrcscrd. - For history, fetch records from
bbndfihx. - Return
RecordsorHistoryRecords.
- Fetch records from
- CREATE:
- Insert record into
bbrcscwith input fields. - Log to
bbrcschwith current date/time,UserID,DeleteFlag= blank.
- Insert record into
- UPDATE:
- Update
bbrcscrecord with newRetailPrice. - Log to
bbrcschwith current date/time,UserID,DeleteFlag= blank.
- Update
-
DELETE:
- Set
RetailPrice= 0 inbbrcsc. - Log to
bbrcschwith current date/time,UserID,DeleteFlag= 'D'.
- Set
-
Log History (CREATE/UPDATE/DELETE):
-
Write to
bbrcsch:lhco,lhefdt,lheftm,lhrprc,lhchd8(current date),lhchtm(current time),lhuser,lhdel. -
Return Results:
- Return
Status,ErrorMessage, andRecords/HistoryRecords.
Business Rules¶
- Valid
CompanyCoderequired frombicont. EffectiveDatemust be valid YYYYMMDD.EffectiveTimemust be valid HHMM.RetailPricemust be non-zero for CREATE/UPDATE.- No duplicate records for CREATE.
- Existing record required for UPDATE/DELETE.
- All changes logged to
bbrcsch. - History inquiries sorted by change date/time.
- File overrides applied based on
FileGroup. - 'INQ' mode is read-only; 'MNT' allows modifications.
Calculations¶
- Date Conversion: YYYYMMDD to MMDDYY for output (
datymd * 100.0001 = datmdy). - Occurrence Count: Count
bbrcscrdrecords forEffectiveDateandEffectiveTime. - History Date/Time: Use system date (
JBDT##) and time (time12).
Dependencies¶
- Tables:
bicont,gstabl,bbrcsc,bbrcsch,bbrcsc1,bbrcscrd,bbndfi,bbndfihx. - Programs:
GSDTEDIT(date validation),QCMDEXC(file overrides),QMHSNDPM/QMHRMVPM(messages).
Error Handling¶
- Return specific error messages (e.g., 'ERR0021', 'ERR0012').
- Ensure atomic database operations.
- Log errors to message queue.