BB905 RPGLE
The RPGLE program BB905, titled "Carrier Code Id Entry Maintenance/Inquiry," is a component of a billing and invoicing system designed to handle the maintenance and inquiry of carrier ID records. It is called by the main program BB905P (as described in the previous query) to perform specific operations such as creating, updating, or displaying carrier ID details. Below, I’ll explain the process steps, business rules, database tables used, and external programs called by BB905.
Process Steps of the RPGLE Program (BB905)¶
The program manages a display file interface for maintaining or inquiring about carrier ID records, operating in either maintenance (MNT) or inquiry (INQ) mode. It processes a single panel format (FMT01) and interacts with database files to validate and update carrier data. Here’s a detailed breakdown of the process steps:
- Program Initialization (
*inzsrSubroutine): - Receives Input Parameters: The program accepts five parameters:
p$co: Company number.p$caid: Carrier ID.p$mode: Run mode (MNTfor maintenance,INQfor inquiry).p$fgrp: File group (ZorGfor database file overrides).p$flag: Return flag to indicate the outcome of processing.
- Initializes Fields: Moves input parameters to display file fields (
f$co,f$caid), sets up output parameters (o$co,o$caid,o$fgrp,o$mode,o$flag), and initializes work fields, message handling fields (dspmsg,m@pgmq,m@key), and key lists (klcaidfor database access). -
Sets Defaults: Initializes flags like
fmtagn(to control format processing) and work fields (w$wk54,w$wk92). -
Open Database Tables (
opntblSubroutine): - Applies File Overrides: Based on the
p$fgrpparameter (ZorG), executesOVRDBFcommands to override the database files (bbcaid,bicont,bbcaid1,gstabl) to the appropriate library (e.g.,gbbcaidorzbbcaid). - Opens Files: Opens the database files
bbcaid(update/add),bicont(input),bbcaid1(input with renamed format), andgstabl(update/add). -
Validates Company Number: Chains to
bicontusingf$coto ensure the company number is valid. -
Retrieve Data for Passed Parameters (
rt LillrtvdtaSubroutine): - Chains to
bbcaid: Uses the key listklcaid(f$co,f$caid) to retrieve the carrier ID record. - Handles Record Existence: If the record exists (
*in99 = *off), setsw$exists = *on; otherwise, clears the record and setsw$exists = *off. -
Sets Display Headers and Protection: Sets the display header (
c$hdr1) based on the mode (MNTfor maintenance,INQfor inquiry) and sets*in70to protect input fields in inquiry mode. -
Process Panel Formats (
srfmtSubroutine): - Clears Screen: Writes the
clrscrformat to clear the display. - Initializes Format: Calls
f01movto initialize fields forFMT01and setsw$fmt = 'FMT01'. -
Main Processing Loop:
- Displays Message Subfile: If
dspmsg = *on, callswrtmsgto display messages; otherwise, clears the screen. - Handles Format Change: Resets
*in19(format change indicator). - Displays Format: Processes
FMT01(the only active format) by callingf01proand executingEXFMT fmt01. - Clears Indicators and Messages: Resets error indicators (
*in50to*in69) and clears the message subfile if needed. - Processes User Input: Calls
f01srto handle user input for the current format. - Loop Control: Continues until
fmtagn = *off.
- Displays Message Subfile: If
-
Process Format Input (
f01srSubroutine): - Handles Function Keys:
- F04 (Field Prompting): Calls
promptto handle field prompting. - F10 (Position Cursor Home): Clears cursor coordinates (
row,col). - F12 (Exit): Sets
fmtagn = *offto exit the program.
- F04 (Field Prompting): Calls
- Inquiry Mode: If
p$mode = 'INQ', callsf01nxtto determine the next format (though onlyFMT01is active). -
Enter Key:
- Validates input by calling
f01edt. - If
p$mode = 'MNT'and no errors (*in50 = *off), captures replacement carrier ID information by callingrtvrplcar. - Updates the database if no errors (
upddbf). - Calls
f01nxtif no input changes occur.
- Validates input by calling
-
Edit Format Input (
f01edtSubroutine): - Validates Carrier Description: Ensures
cicanmis not blank; if blank, sets errorERR0012and indicators*in50and*in51. - Validates Fuel Facs ID (Commented Out): Temporarily disabled (per revision
JB02) to allow multiple carrier IDs with the same Fuel Facs ID (ciffid). If enabled, it checks ifciffidexists inbbcaid1and ensures it’s unique unless it matches the currentp$caid. -
Inquiry Mode: Clears error indicators and messages in inquiry mode.
-
Initialize Format Field Values (
f01movSubroutine): -
Calls
f01edtto validate fields and clears error indicators/messages if validation fails. -
Format Protection Schemes (
f01proSubroutine): - Sets Protection Indicators: Resets indicators
*in70to*in74to*off. - Inquiry Mode: Sets
*in70to*in73to*onto protect fields in inquiry mode. -
Existing Record: If
w$exists = *on, protects key fields (*in71 = *on). -
Update Database Files (
upddbfSubroutine): - Saves Current Data: Stores the current record in
svds. - Chains to
bbcaid: Usesklcaidto check if the record exists. - Updates Existing Record:
- If the record exists and data has changed (
svds ≠ wkds01), updatesbbcaidpf. - If company number is 10 (
p$co = 10), callsupdtablesto updategstabl. - Sets
p$flag = '1'to indicate success.
- If the record exists and data has changed (
- Creates New Record:
- Clears
bbcaidpf, populates fields (cico,cicaid), and sets creation date (cidate) to the current date (per revisionJK01). - Writes to
bbcaidpfand updatesgstablifp$co = 10. - Sets
p$flag = '1'.
- Clears
-
Forces End of Data: Uses
FEODto ensure proper file handling for updates. -
Capture Replacement Carrier ID (
rtvrplcarSubroutine):- Checks for New Entries: Ensures the record does not exist (
*in99 = *off). - Calls
BB9059: Passesf$co,f$caid,o$flag, andp$fgrpto handle replacement carrier ID logic. - Handles Cancellation: If
o$flag = '2', displays a "New Carrier Not Created" message and sets error indicator*in50.
- Checks for New Entries: Ensures the record does not exist (
-
Update
gstablTable (updtablesSubroutine):- For Company 10: If
p$co = 10, updates or adds a record togstabl: - Chains to
gstablusingtype(BBCAID) andcicaid. - If found, updates
tbdel,tbdesc, andtbein. - If not found, creates a new record with
tbdel,tbtype,tbcode,tbdesc, andtbein.
- For Company 10: If
-
Field Prompting (
promptSubroutine):- Determines cursor location (
row,col) and sets*in19to indicate a format change.
- Determines cursor location (
-
Message Handling:
- Add Message (
addmsg): Sends messages to the program message queue usingQMHSNDPM, setsdspmsg = *on. - Write Message Subfile (
wrtmsg): Displays the message subfile (msgctl) with*in49. - Clear Message Subfile (
clrmsg): Clears messages usingQMHRMVPM, preserving the current record format and page number.
- Add Message (
-
Program Termination:
- Closes all files and sets
*inlr = *onto end the program.
- Closes all files and sets
Business Rules¶
The program enforces the following business rules:
- Input Validation:
- Carrier Description: Must not be blank (
ERR0012). - Fuel Facs ID: Temporarily allows multiple carrier IDs to share the same Fuel Facs ID (revision
JB02). If validation is enabled, the Fuel Facs ID must be unique unless it matches the current carrier ID (ERR0018). -
Company Number: Must exist in the
bicontfile (validated inopntbl). -
Mode-Based Access:
- Maintenance Mode (
MNT): Allows creating and updating carrier ID records. Key fields are protected for existing records (*in71). -
Inquiry Mode (
INQ): Protects all input fields (*in70to*in73), allowing only viewing of records. -
Database Updates:
- Updates or creates records in
bbcaidbased on whether the record exists. - For company number 10, synchronizes data with the
gstabltable, ensuring consistency in deletion status, description, and EIN fields. -
Sets a creation date (
cidate) for new records (revisionJK01). -
Replacement Carrier ID:
- For new carrier IDs, checks for replacement logic via
BB9059to populatexBBFX62Wwith From/To Carrier IDs (revisionDC01). -
Cancels creation if the user opts not to proceed (
o$flag = '2'). -
Error Handling:
- Displays error messages for invalid inputs or existing/non-existent records.
-
Uses a message subfile to communicate errors and confirmations to the user.
-
Inactivation/Reactivation:
- Referred to as "Inactivate/Reactivate" instead of "Delete/Reactivate" (revision
DC01).
Database Tables Used¶
The program interacts with the following database files:
1. bbcaid:
- Update/add file for carrier ID records.
- Key fields: cico (company), cicaid (carrier ID).
- Fields include cicanm (description), ciffid (Fuel Facs ID), ciein (EIN), cidel (deletion status), cidate (creation date).
2. bicont:
- Input-only file to validate company numbers (f$co).
3. bbcaid1:
- Input-only file with renamed record format (bbcaidpf to bbcaidlf, prefixed with l_) for Fuel Facs ID validation.
4. gstabl:
- Update/add file for company 10, storing carrier ID data.
- Key fields: tbtype (BBCAID), tbcode (carrier ID).
- Fields: tbdel (deletion status), tbdesc (description), tbein (EIN).
External Programs Called¶
The program calls the following external programs:
1. BB9059:
- Handles replacement carrier ID logic in the rtvrplcar subroutine.
- Parameters: o$co (company), o$caid (carrier ID), o$flag (return flag), o$fgrp (file group).
2. QCMDEXC:
- Executes file override commands (OVRDBF) in the opntbl subroutine.
- Parameters: dbov## (override command string), dbol## (length of command).
3. QMHSNDPM:
- Sends messages to the program message queue in the addmsg subroutine.
- Parameters: m@id, m@msgf, m@data, m@l, m@type, m@pgmq, m@scnt, m@key, m@errc.
4. QMHRMVPM:
- Clears messages from the message subfile in the clrmsg subroutine.
- Parameters: m@pgmq, m@scnt, m@rmvk, m@rmv, m@errc.
Additional Notes¶
- Single Format Processing: Only
FMT01is actively processed, withFMT02commented out, indicating a simplified interface compared toBB905P. - Function Keys:
- F04: Field prompting.
- F10: Positions cursor to the home position.
- F12: Exits the program.
- Indicators: Similar to
BB905P, indicators control screen errors (*in50to*in69,*in21to*in39), input protection (*in70to*in79), and subfile operations. - Revisions:
- DC01 (08/2013): Updated terminology to "Inactivate/Reactivate" and added logic for populating
xBBFX62Wfor carrier replacement. - JB02 (08/05/13): Temporarily disabled unique Fuel Facs ID validation.
- JK01 (05/04/16): Added creation date (
cidate) for newbbcaidrecords.
This program complements BB905P by providing detailed maintenance and inquiry functions for individual carrier ID records, with a focus on validation, database updates, and user interaction via a display file. Let me know if you need further details or clarification!