The call stack for the Billing and Invoicing system consists of four RPG programs: BB905, BB9054, BB9055, and BB9059. These programs collectively handle various aspects of carrier code management and reporting. Below is a comprehensive list of use cases implemented by these programs, followed by a function requirement document for each use case, reimagined as a large function that processes inputs programmatically rather than through screen interactions.
List of Use Cases Implemented in the Call Stack¶
Based on the provided RPG programs (BB905, BB9054, BB9055, BB9059), the following use cases are implemented:
- Carrier Code Entry Maintenance (BB905):
- Description: Allows the creation or update of carrier ID records, including validation of inputs and synchronization with related tables. Handles both maintenance (
MNT) and inquiry (INQ) modes. -
Details: Validates carrier description (must not be blank), temporarily allows multiple carrier IDs to share the same Fuel Facs ID (per revision
JB02), populates creation date for new records (perJK01), and supports replacement carrier ID capture by callingBB9059. Updatesbbcaidand, for company10,gstabl. -
Carrier Code Inactivation/Reactivation (BB9054):
- Description: Manages the inactivation or reactivation of existing carrier ID records.
-
Details: Toggles the status (
cidel) between active (A) and inactive (I), updatesbbcaidandgstabl(for company10), and allows inactivation even if the carrier is linked to a vendor (per revisionjb01). Uses F22 for reactivation and F23 for inactivation. -
Carrier Code Listing Report (BB9055):
- Description: Generates a printed report listing all carrier ID records for a specified file group.
-
Details: Reads all records from
bbcaid, formats a report with headers and detail lines (company number, carrier ID, carrier name, EIN, Fuel Facs number, status), and handles page overflows. Configures output to be held and saved in the job’s output queue. -
Capture Replacing Carrier ID (BB9059):
- Description: Captures a "From" carrier ID when creating a new carrier ID, storing the relationship in
bbfx62w. - Details: Validates the "From" carrier ID (must exist in
bbcaidand not be linked to a vendor inapveny), allows blank entries, and sends confirmation messages to usersJLBITandCAPOupon successful update.
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, detailing inputs, outputs, process steps, and business rules.
Function Requirement Documents for Carrier Code Management¶
1. Carrier Code Entry Maintenance Function¶
Purpose¶
Create or update carrier ID records in the bbcaid and gstabl tables, validating inputs and handling replacement carrier relationships.
Inputs¶
- Company Number (
p$co): Integer, company identifier. - Carrier ID (
p$caid): String, carrier identifier. - Mode (
p$mode): String (MNTfor maintenance,INQfor inquiry). - File Group (
p$fgrp): String (ZorGfor database overrides). - Carrier Name (
cicanm): String, carrier description. - EIN (
ciein): Numeric, Employer Identification Number. - Fuel Facs ID (
ciffid): Numeric, Fuel Facility ID. - Delete Flag (
cidel): String (Afor active,Ifor inactive).
Outputs¶
- Return Flag (
p$flag): String (1for success,2for no creation,Efor error). - Error Messages: Array of strings, validation errors if any.
Process Steps¶
- Validate Inputs:
- Ensure
p$coexists inbicont. - In
MNTmode, ensurecicanmis not blank (else return errorERR0012). - (Disabled per
JB02) Ensureciffidis unique inbbcaid1unless it matchesp$caid. - Check Record Existence:
- Chain to
bbcaidusingp$coandp$caid. - If found, mark as existing; else, treat as new.
- Handle Replacement Carrier:
- If new record, call
CaptureReplacingCarrierIDfunction withp$co,p$caid,p$fgrp. - If returned
p$flag = '2', return errorERR0000("New Carrier Not Created"). - Update Database:
- For existing records in
MNTmode:- If fields changed, update
bbcaidpfwithcicanm,ciein,ciffid,cidel. - Set
p$flag = '1'.
- If fields changed, update
- For new records:
- Set creation date (
cidate) to current date (perJK01). - Write to
bbcaidpfwithp$co,p$caid,cicanm,ciein,ciffid,cidel. - Set
p$flag = '1'.
- Set creation date (
- For company
10, updategstabl:- Chain to
gstablwithtype = 'BBCAID'andp$caid. - If found, update
tbdel = cidel,tbdesc = cicanm,tbein = ciein. - If not found, write new record with
tbtype = 'BBCAID',tbcode = p$caid,tbdel = cidel,tbdesc = cicanm,tbein = ciein.
- Chain to
- Return Outputs: Return
p$flagand any error messages.
Business Rules¶
- Mode Restriction: In
INQmode, no updates are allowed; return existing record data. - Validation:
- Carrier name must not be blank in
MNTmode. - (Disabled per
JB02) Fuel Facs ID must be unique unless updating the same carrier. - Creation Date: Set
cidatefor newbbcaidrecords using the current date. - Replacement: New records require checking for a replacement carrier via
CaptureReplacingCarrierID. - GSTABL Sync: For company
10, synchronizegstablwithbbcaidupdates.
2. Carrier Code Inactivation/Reactivation Function¶
Purpose¶
Toggle the active/inactive status of a carrier ID in bbcaid and gstabl tables.
Inputs¶
- Company Number (
p$co): Integer, company identifier. - Carrier ID (
p$caid): String, carrier identifier. - File Group (
p$fgrp): String (ZorGfor database overrides). - Action (
action): String (INACTIVATEorREACTIVATE).
Outputs¶
- Return Flag (
p$flag): String (Afor reactivated,Ifor inactivated,Efor error). - Error Messages: Array of strings, validation errors if any.
Process Steps¶
- Validate Inputs:
- Ensure
p$coandp$caidexist inbbcaid(else return error). - Check Current Status:
- Chain to
bbcaidusingp$coandp$caid. - If
action = 'REACTIVATE', ensurecidel = 'I'(else return error). - If
action = 'INACTIVATE', ensurecidel ≠ 'I'(else return error). - Update Database:
- For
REACTIVATE: Setcidel = 'A', updatebbcaidpf, setp$flag = 'A'. - For
INACTIVATE: Setcidel = 'I', updatebbcaidpf, setp$flag = 'I'. - For company
10, updategstabl:- Chain to
gstablwithtype = 'BBCAID'andp$caid. - If found, update
tbdel = p$flag.
- Chain to
- Return Outputs: Return
p$flagand any error messages.
Business Rules¶
- Status Transition:
- Only inactive records (
cidel = 'I') can be reactivated. - Only active records (
cidel ≠ 'I') can be inactivated. - Vendor Linkage: (Disabled per
jb01) Inactivation is allowed even if the carrier is linked to a vendor inapveny. - GSTABL Sync: For company
10, synchronizetbdelingstablwithcidel.
3. Carrier Code Listing Report Function¶
Purpose¶
Generate a report of all carrier ID records for a specified file group.
Inputs¶
- File Group (
p$fgrp): String (ZorGfor database overrides).
Outputs¶
- Report Data: Array of records containing company number, carrier ID, carrier name, EIN, Fuel Facs number, and status.
- Report Metadata: Object with job name, program name, user, date, time, and file group.
Process Steps¶
- Initialize Report:
- Set report header with "American Refining Group", "Carrier Id Listing By Co#/Carrier Id", job name, program name, user, current date, time, and file group.
- Set column headings: "Co", "Carr Id", "Carrier Name", "Ein #", "Fuel Facs #", "Del".
- Read Records:
- Sequentially read all records from
bbcaid(overridden togbbcaidorzbbcaidbased onp$fgrp). - Format Report:
- For each record, output:
cico(company number).cicaid(carrier ID).cicanm(carrier name).ciein(EIN, 4 decimal places).ciffid(Fuel Facs number, 4 decimal places).cidel(delete/inactive flag).
- Track page breaks at line 62, reprinting headers as needed.
- Return Outputs: Return the formatted report data and metadata.
Business Rules¶
- Report Scope: Include all
bbcaidrecords without filtering. - Formatting: Use 68 lines, 164 characters, 8 lines per inch, 15 characters per inch, with overflow at line 62.
- Output: Report is held and saved in the job’s output queue.
4. Capture Replacing Carrier ID Function¶
Purpose¶
Capture a "From" carrier ID for a new carrier ID, storing the relationship in bbfx62w and notifying users.
Inputs¶
- Company Number (
p$co): Integer, company identifier. - To Carrier ID (
p$caid): String, new carrier ID. - File Group (
p$fgrp): String (ZorGfor database overrides). - From Carrier ID (
w$cifr): String, optional replacement carrier ID.
Outputs¶
- Return Flag (
p$flag): String (1for success,2for cancellation). - Error Messages: Array of strings, validation errors if any.
Process Steps¶
- Validate Inputs:
- If
w$cifris blank, returnp$flag = '1'without updatingbbfx62w. - Chain to
bbcaidusingp$coandw$cifr. If not found, return errorERR0000("Invalid Carrier ID"). - Check
apvenyusingp$coandw$cifr. If found, return errorERR0000("Code [w$cifr] is linked to a vendor for ARGLMS. Contact IT to convert."). - Update Database:
- If valid, write to
bbfx62wwithw1cifr = w$cifrandw1cito = p$caid. - Set
p$flag = '1'. - Notify Users:
- Send messages: "BBFX62W Entry Created. From Carrier [w$cifr] To Carrier [p$caid].)" to users
JLBITandCAPO. - Return Outputs: Return
p$flagand any error messages.
Business Rules¶
- Optional Input: Blank
w$cifris allowed, skippingbbfx62wupdate. - Validation:
w$cifrmust exist inbbcaid.w$cifrmust not be linked to a vendor inapveny.- Notification: Successful updates trigger messages to
JLBITandCAPO.
Summary¶
The call stack (BB905, BB9054, BB9055, BB9059) implements four distinct use cases: carrier code entry maintenance, inactivation/reactivation, listing report generation, and replacement carrier ID capture. Each use case has been reimagined as a programmatic function that processes inputs directly, focusing on business requirements and calculations. The functions validate inputs, update relevant tables (bbcaid, gstabl, bbfx62w), and enforce rules such as unique carrier descriptions, status transitions, and vendor linkage checks (some disabled per revisions). The report function generates a comprehensive listing, and notifications are sent for replacement carrier entries. These functions ensure data integrity and synchronization across related tables while providing clear outputs for downstream processing.