BB912 RPGLE
The RPG program BB912 is designed for Carrier Fuel Surcharge Maintenance/Inquiry within the Brandford Order Entry/Invoices system. It manages fuel surcharge data through a display file with subfiles, allowing users to create, update, copy, delete, or inquire about surcharge records. Below is a detailed explanation of the process steps, followed by a list of external programs called and tables used.
Process Steps of the BB912 RPG Program¶
- Initialization (*INZSR Subroutine):
- Receives input parameters: company code (
p$co), carrier code (p$caid), run mode (p$mode: 'MNT' for maintenance or 'INQ' for inquiry), and file group (p$fgrp: 'G' or 'Z'). - Sets default values for company code if not provided (defaults to 10).
- Initializes subfile control fields, message handling fields, and date/time stamps.
- Configures headers and function key labels based on the mode ('MNT' or 'INQ').
-
Defines key lists for database access and initializes work fields.
-
Open Database Tables (opntbl Subroutine):
- Applies file overrides based on the file group (
p$fgrp) to point to the correct library ('G' or 'Z') for files likebicont,gstabl,bbcfsh, etc. -
Opens input files (
bicont,gstabl,bbcaid,bbcfsh1,bbcfsdrd) and update/output files (bbcfsh,bbcfsd,bbcfshh,bbcfsdh). -
Process Subfile 1 (srsfl1 Subroutine):
- Clear Message Subfile: Clears any existing messages in the message subfile.
- Position File: Repositions the
bbcfsh1file based on user input (company code, carrier code, effective date). - Suppress Initial Errors: On first display, suppresses error messages to present a clean interface.
-
Main Loop:
- Repositions the subfile if requested (
repsfl = *on). - Displays the command line and message subfile.
- Checks for existing subfile records to enable/disable display control (
*in41). - Displays the subfile control record (
sflctl1) usingEXFMT. - Processes user input based on function keys:
- F03: Exits the program.
- F04: Prompts for field input (e.g., region or carrier code).
- F05: Refreshes the subfile, clearing positioning fields.
- F07: Calls
BB910for National Diesel Fuel Index Maintenance/Inquiry. - F09: Calls
GB730Pfor historical inquiry of header records. - F10: Positions the cursor to the control record.
- Page Down: Loads additional subfile records.
- Enter: Processes subfile changes (
sf1prc). - Handles user positioning requests by validating and repositioning the subfile.
- Repositions the subfile if requested (
-
Process Subfile 1 Records on Enter (sf1prc Subroutine):
- Reads changed subfile records (
readc sfl1) and processes each changed record (sf1chg). -
Updates the database if no errors are found and the mode is 'MNT'.
-
Process Subfile 1 Record Change (sf1chg Subroutine):
- Retains selected values (effective date).
- Validates input (
sf1edt):- Checks region code against
gstablto ensure validity. - Displays error message (
ERR0010) if invalid.
- Checks region code against
- Updates the database (
sf1upd) if no errors and in maintenance mode. -
Processes subfile options (1=Create, 2=Change, 3=Copy, 4=Delete, 5=Display):
- Create (sf1s01): Opens a window (
sflcrt1) to input new header record data, validates, and writes tobbcfshandbbcfshh. - Change (sf1s02): Calls
srsfl2in maintenance mode to update detail records. - Copy (sf1s03): Opens a window (
sflcpy1) to copy header and detail records to a new effective date. - Delete (sf1s04): Opens a window (
sfldel1) to confirm deletion of header and detail records. - Display (sf1s05): Calls
srsfl2in inquiry mode to view detail records.
- Create (sf1s01): Opens a window (
-
Reposition Subfile 1 (sf1rep Subroutine):
- Clears the subfile (
sf1clr) and resets relative record number (rrn1). - Validates control record input (
sf1cte):- Checks company code against
bicont. - Validates carrier code against
bbcaid. - Validates effective date using
GSDTEDIT.
- Checks company code against
-
Positions the
bbcfsh1file and loads subfile records (sf1lod). -
Load Subfile 1 Records (sf1lod Subroutine):
- Loads records from
bbcfsh1into the subfile up to the page size (pagsz1). - Formats each record (
sf1fmt):- Sets effective date, region, and occurrence count.
- Retrieves region description from
gstabl.
-
Applies protection schemes (
sf1pro) based on inquiry mode. -
Process Subfile 2 (srsfl2 Subroutine):
- Handles detail records for a selected header record.
- Sets protection indicators based on mode (
*in71). - Initializes to update mode and sets function key labels.
-
Main loop processes user input similarly to
srsfl1:- F03: Exits the program.
- F05: Refreshes the subfile.
- F06: Toggles between add and update modes.
- F09: Calls
GB730Pfor historical inquiry of detail records. - F12: Cancels and returns to subfile 1.
- F23: Deletes a detail record.
- Page Down: Loads additional detail records.
- Enter: Processes subfile changes (
sf2prc).
-
Process Subfile 2 Records on Enter (sf2prc Subroutine):
- Reads changed subfile records (
readc sfl2) and processes each changed record (sf2chg). -
Updates the database if no errors and in maintenance mode.
-
Process Subfile 2 Record Change (sf2chg Subroutine):
- Validates input (
sf2edt): - Ensures all or no fields (
s2frpc,s2topc,s2fspc) are entered. - Validates price ranges and fuel surcharge percentages against existing records.
- Updates the database (
sf2upd) by adding or updating records inbbcfsdandbbcfsdh. - Applies protection schemes (
sf2pro).
- Validates input (
-
Reposition Subfile 2 (sf2rep Subroutine):
- Clears the subfile (
sf2clr) and resetsrrn2. - Validates control record input (
sf2cte) and loads detail records (sf2lod).
- Clears the subfile (
-
Field Prompting (prompt Subroutine):
- Handles F04 key for field prompting:
- For
S1REGN: CallsMGSTABLto select a region code. - For
C1CAID: CallsLBBCAIDto select a carrier code.
-
Message Handling (addmsg, wrtmsg, clrmsg Subroutines):
- Adds error messages to the program message queue (
QMHSNDPM). - Writes messages to the message subfile (
msgctl). - Clears the message subfile (
QMHRMVPM).
- Adds error messages to the program message queue (
-
History Logging (writehdrhist, writedtlhist Subroutines):
- Logs changes to header (
bbcfshh) and detail (bbcfsdh) history files with timestamps and user information.
- Logs changes to header (
-
Program Termination:
- Closes all files and sets
*inlr = *onto end the program.
- Closes all files and sets
External Programs Called¶
- BB910: National Diesel Fuel Index Maintenance/Inquiry, called when F07 is pressed.
- GB730P: Historical inquiry program for header and detail records, called when F09 is pressed.
- GSDTEDIT: Date validation module, used to validate effective dates.
- MGSTABL: Table lookup program for region codes, called during prompting for
S1REGN. - LBBCAID: Carrier ID lookup program, called during prompting for
C1CAID(replacedBB912Aper revision JK02). - QCMDEXC: Executes file override commands.
- QMHSNDPM: Sends messages to the program message queue.
- QMHRMVPM: Removes messages from the program message queue.
Tables Used¶
- bicont: Input file for company code validation (read-only).
- gstabl: Input file for region code validation (read-only).
- bbcaid: Input file for carrier code validation (read-only, added per JK03).
- bbcfsh: Update file for header records (add/update).
- bbcfsd: Update file for detail records (add/update).
- bbcfsh1: Input file for header records (read-only, renamed format
bbcfhpr). - bbcfsdrd: Input file for detail records (read-only, renamed format
bbcfdpr). - bbcfshh: Output file for header history records (write-only, added per JK01).
- bbcfsdh: Output file for detail history records (write-only, added per JK01).
This program is structured to handle complex data maintenance tasks with robust error checking, user interaction through subfiles, and integration with external lookup and validation programs.