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
. Updatesbbcaid
and, 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
), updatesbbcaid
andgstabl
(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
bbcaid
and not be linked to a vendor inapveny
), allows blank entries, and sends confirmation messages to usersJLBIT
andCAPO
upon 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 (MNT
for maintenance,INQ
for inquiry). - File Group (
p$fgrp
): String (Z
orG
for 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 (A
for active,I
for inactive).
Outputs¶
- Return Flag (
p$flag
): String (1
for success,2
for no creation,E
for error). - Error Messages: Array of strings, validation errors if any.
Process Steps¶
- Validate Inputs:
- Ensure
p$co
exists inbicont
. - In
MNT
mode, ensurecicanm
is not blank (else return errorERR0012
). - (Disabled per
JB02
) Ensureciffid
is unique inbbcaid1
unless it matchesp$caid
. - Check Record Existence:
- Chain to
bbcaid
usingp$co
andp$caid
. - If found, mark as existing; else, treat as new.
- Handle Replacement Carrier:
- If new record, call
CaptureReplacingCarrierID
function withp$co
,p$caid
,p$fgrp
. - If returned
p$flag = '2'
, return errorERR0000
("New Carrier Not Created"). - Update Database:
- For existing records in
MNT
mode:- If fields changed, update
bbcaidpf
withcicanm
,ciein
,ciffid
,cidel
. - Set
p$flag = '1'
.
- If fields changed, update
- For new records:
- Set creation date (
cidate
) to current date (perJK01
). - Write to
bbcaidpf
withp$co
,p$caid
,cicanm
,ciein
,ciffid
,cidel
. - Set
p$flag = '1'
.
- Set creation date (
- For company
10
, updategstabl
:- Chain to
gstabl
withtype = '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$flag
and any error messages.
Business Rules¶
- Mode Restriction: In
INQ
mode, no updates are allowed; return existing record data. - Validation:
- Carrier name must not be blank in
MNT
mode. - (Disabled per
JB02
) Fuel Facs ID must be unique unless updating the same carrier. - Creation Date: Set
cidate
for newbbcaid
records using the current date. - Replacement: New records require checking for a replacement carrier via
CaptureReplacingCarrierID
. - GSTABL Sync: For company
10
, synchronizegstabl
withbbcaid
updates.
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 (Z
orG
for database overrides). - Action (
action
): String (INACTIVATE
orREACTIVATE
).
Outputs¶
- Return Flag (
p$flag
): String (A
for reactivated,I
for inactivated,E
for error). - Error Messages: Array of strings, validation errors if any.
Process Steps¶
- Validate Inputs:
- Ensure
p$co
andp$caid
exist inbbcaid
(else return error). - Check Current Status:
- Chain to
bbcaid
usingp$co
andp$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
gstabl
withtype = 'BBCAID'
andp$caid
. - If found, update
tbdel = p$flag
.
- Chain to
- Return Outputs: Return
p$flag
and 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
, synchronizetbdel
ingstabl
withcidel
.
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 (Z
orG
for 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 togbbcaid
orzbbcaid
based 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
bbcaid
records 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 (Z
orG
for database overrides). - From Carrier ID (
w$cifr
): String, optional replacement carrier ID.
Outputs¶
- Return Flag (
p$flag
): String (1
for success,2
for cancellation). - Error Messages: Array of strings, validation errors if any.
Process Steps¶
- Validate Inputs:
- If
w$cifr
is blank, returnp$flag = '1'
without updatingbbfx62w
. - Chain to
bbcaid
usingp$co
andw$cifr
. If not found, return errorERR0000
("Invalid Carrier ID"). - Check
apveny
usingp$co
andw$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
bbfx62w
withw1cifr = w$cifr
andw1cito = p$caid
. - Set
p$flag = '1'
. - Notify Users:
- Send messages: "BBFX62W Entry Created. From Carrier [w$cifr] To Carrier [p$caid].)" to users
JLBIT
andCAPO
. - Return Outputs: Return
p$flag
and any error messages.
Business Rules¶
- Optional Input: Blank
w$cifr
is allowed, skippingbbfx62w
update. - Validation:
w$cifr
must exist inbbcaid
.w$cifr
must not be linked to a vendor inapveny
.- Notification: Successful updates trigger messages to
JLBIT
andCAPO
.
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.