BB9054 RPGLE
The RPGLE program BB9054
, titled "Carrier Code Entry InActivate/ReActivate," is a component of a billing and invoicing system designed to handle the inactivation or reactivation of carrier ID records. It is called by the main program BB905P
(as described in the first query) to perform the specific task of toggling the status of a carrier ID between active and inactive states. Below, I’ll explain the process steps, business rules, database tables used, and external programs called by BB9054
.
Process Steps of the RPGLE Program (BB9054
)¶
The program manages a window-based interface (actwdw
) to allow users to inactivate or reactivate a carrier ID record. It operates on the bbcaid
file and, for specific cases, the gstabl
file, and checks for dependencies in the apveny
file. Here’s a detailed breakdown of the process steps:
- Program Initialization (
*inzsr
Subroutine): - Receives Input Parameters: The program accepts four parameters:
p$co
: Company number.p$caid
: Carrier ID.p$fgrp
: File group (Z
orG
for database file overrides).p$flag
: Return flag to indicate the outcome (I
for inactivated,A
for reactivated, orE
for error).
- Initializes Fields: Moves input parameters to display file fields (
f$co
,f$caid
), sets up message handling fields (dspmsg
,m@pgmq
,m@key
), and initializes the window processing flag (winagn = *on
). -
Defines Key Lists: Sets up
klcaid
(forbbcaid
access withf$co
,f$caid
) andklapveny
(forapveny
access withf$co
,f$caid
). -
Open Database Tables (
opntbl
Subroutine): - Applies File Overrides: Based on the
p$fgrp
parameter (Z
orG
), executesOVRDBF
commands to override the database files (apveny
,bbcaid
,gstabl
) to the appropriate library (e.g.,gapveny
orzapveny
). -
Opens Files: Opens the database files
apveny
(input-only),bbcaid
(update/add), andgstabl
(update/add). -
Retrieve Data (
rtvdta
Subroutine): - Chains to
bbcaid
: Uses the key listklcaid
(f$co
,f$caid
) to retrieve the carrier ID record. -
Sets Display Based on Status:
- If the record exists (
*in99 = *off
): - Inactive Record (
cidel = 'I'
): Sets the header to "Carrier Id Entry ReActivate" (hdr(01)
), sets the function key label toF22=ReActivate
(fky(01)
), and activates indicator*in72
(likely for display formatting, e.g., blue color). - Active Record (
cidel ≠ 'I'
):- Checks if the carrier ID exists in the vendor file (
apveny
) usingklapveny
. - Sets the header to "Carrier Id Entry InActivate" (
hdr(02)
), sets the function key label toF23=InActivate
(fky(02)
), and activates indicator*in73
. - Note: The check for vendor linkage setting
p$flag = 'E'
is commented out (per revisionjb01
), allowing inactivation even if linked to a vendor.
- Checks if the carrier ID exists in the vendor file (
- If the record exists (
-
Process Window (
prcwdw
Subroutine): -
Main Processing Loop:
- Displays Message Subfile: If
dspmsg = *on
, callswrtmsg
to display messages; otherwise, writesmsgclr
to clear the message area. - Displays Window: Executes
EXFMT actwdw
to display the inactivation/reactivation window. - Clears Messages and Indicators: Clears the message subfile if needed and resets error indicators (
*in50
to*in69
). - Processes User Input:
- F12 (Exit): Sets
winagn = *off
to exit the loop. - F22 (ReActivate) or F23 (InActivate): Calls
winedt
to validate input, and if no errors (*in50 = *off
), callswinupd
to update the database and exits the loop. - Other Inputs (e.g., Enter): Calls
winedt
to validate input.
- Displays Message Subfile: If
-
Edit Window Input (
winedt
Subroutine): -
Calls
chkact
to perform activity checks (currently empty, indicating no specific validation is implemented). -
Check Activity (
chkact
Subroutine): -
Placeholder for pre-inactivation checks, but no logic is implemented, suggesting validation may occur elsewhere or was deemed unnecessary.
-
Update Database from Window Input (
winupd
Subroutine): - ReActivate (F22):
- Chains to
bbcaid
usingklcaid
. - If the record exists and is inactive (
cidel = 'I'
), setscidel = 'A'
, updatesbbcaidpf
, setsp$flag = 'A'
, and callsupdtables
to updategstabl
if needed.
- Chains to
-
InActivate (F23):
- Chains to
bbcaid
usingklcaid
. - If the record exists and is not inactive (
cidel ≠ 'I'
), setscidel = 'I'
, updatesbbcaidpf
, setsp$flag = 'I'
, and callsupdtables
.
- Chains to
-
Update
gstabl
Table (updtables
Subroutine): -
For company 10, updates the
gstabl
file:- Chains to
gstabl
usingtype
(BBCAID
) andp$caid
. - If found, updates
tbdel
withp$flag
(A
orI
) and updatesgstablpf
.
- Chains to
-
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
. Note: The code to save/restorercdnam
andpagrrn
is commented out, as no subfile is used. -
Program Termination:
- Closes all files and sets
*inlr = *on
to end the program.
- Closes all files and sets
Business Rules¶
The program enforces the following business rules:
- Inactivation/Reactivation:
- A carrier ID can be toggled between inactive (
cidel = 'I'
) and active (cidel = 'A'
) states using F23 and F22, respectively. -
Inactivation is allowed even if the carrier ID is linked to a vendor in
apveny
(revisionjb01
, 06/05/2024, comments out the error flagp$flag = 'E'
). -
Database Consistency:
- Updates the
cidel
field inbbcaid
to reflect the inactivation (I
) or reactivation (A
) status. -
For company number 10, synchronizes the
tbdel
field ingstabl
with thep$flag
value to maintain consistency. -
Vendor Linkage:
-
Previously, inactivation was blocked if the carrier ID was linked to a vendor in
apveny
(would setp$flag = 'E'
and exit). This restriction was removed (revisionjb01
), allowing inactivation regardless of vendor linkage. -
User Interface:
- Displays a window (
actwdw
) with dynamic headers and function key labels based on the record’s status:- Inactive records show "Carrier Id Entry ReActivate" and
F22=ReActivate
. - Active records show "Carrier Id Entry InActivate" and
F23=InActivate
.
- Inactive records show "Carrier Id Entry ReActivate" and
-
Uses indicators
*in72
(for inactive) and*in73
(for active) for display formatting. -
Error Handling:
- Minimal validation is performed (
chkact
is empty), relying on the calling program (BB905P
) for input validation. - Uses a message subfile to display errors or confirmations, though no specific error messages are defined in the provided code (only a placeholder
com(01)
).
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).
- Key field modified: cidel
(deletion/inactivation status, set to A
or I
).
2. apveny:
- Input-only file to check for vendor linkage.
- Key fields: Likely f$co
(company) and f$caid
(carrier ID), based on klapveny
.
3. gstabl:
- Update/add file for company 10, storing carrier ID status.
- Key fields: tbtype
(BBCAID
), tbcode
(carrier ID).
- Field updated: tbdel
(set to A
or I
).
External Programs Called¶
The program calls the following external programs:
1. QCMDEXC:
- Executes file override commands (OVRDBF
) in the opntbl
subroutine.
- Parameters: dbov##
(override command string), dbol##
(length of command).
2. 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
.
3. QMHRMVPM:
- Clears messages from the message subfile in the clrmsg
subroutine.
- Parameters: m@pgmq
, m@scnt
, m@rmvk
, m@rmv
, m@errc
.
Additional Notes¶
- Window-Based Interface: Unlike
BB905P
(subfile-based) orBB905
(format-based),BB9054
uses a single window (actwdw
) for a simple inactivation/reactivation action. - Function Keys:
- F12: Exits the program.
- F22: Reactivates an inactive carrier ID.
- F23: Inactivates an active carrier ID.
- Indicators: Consistent with
BB905P
, indicators control screen errors (*in50
to*in69
), input protection (*in70
to*in79
), and display formatting (*in72
,*in73
). - Revision:
- jb01 (06/05/2024): Removed the restriction preventing inactivation of carrier IDs linked to vendors, allowing such actions without requiring AP (Accounts Payable) intervention.
- Minimal Validation: The
chkact
subroutine is empty, suggesting that validation is handled by the calling program or not required.
This program is a focused utility for toggling carrier ID status, complementing the broader functionality of BB905P
and BB905
. It ensures database consistency and provides a user-friendly interface for status changes. Let me know if you need further clarification or additional details!