BB9294 RPGLE
The BB9294 RPGLE program is part of the Billing and Invoicing system and is designed to handle the Inactivation and Reactivation of Customer Service Representative (CSR) IDs. It is called by the main program BB929P to toggle the status of a CSR record between active (A) and inactive (I). Below, I will explain the process steps, outline the business rules, list the tables used, and identify any external programs called.
Process Steps of the RPGLE Program (BB9294)¶
The program is an interactive workstation-based application that uses a display file (bb9294d) to present a window format (actwdw) for confirming the inactivation or reactivation of a CSR record. It updates the crdel field in the bbcsr file to reflect the status change. Below is a step-by-step explanation of its process flow, based on the mainline logic and subroutines:
- Program Initialization (
*inzsrSubroutine): - Parameter Reception: The program receives four parameters:
p$co: Company number (input).p$crid: CSR ID (input).p$fgrp(1 character): File group (ZorG) for database overrides.p$flag(1 character): Return flag (output, set toAfor reactivation orIfor inactivation).
- Field Initialization:
- Moves input parameters
p$coandp$cridto display file fieldsf$coandf$crid. - Defines key list
klcsrfor accessing thebbcsrfile usingf$coandf$crid. - Sets
winagnto*ONto control the window processing loop. - Initializes message handling fields (
dspmsgto blank,m@pgmqto*,m@keyto blanks). - Defines a parameter list (
pld010) for date validation (not used in the provided code).
- Moves input parameters
-
Commented Test Code: Includes commented-out code for testing with hardcoded values (e.g.,
p$co = '10',p$crid = 'JGK'). -
Open Database Tables (
opntblSubroutine): - File Overrides: Based on
p$fgrp(ZorG), applies a database override using theQCMDEXCAPI to redirect access to thebbcsrfile to eithergbbcsrorzbcsr. -
File Opening: Opens the
bbcsrfile (update/add, keyed access). -
Retrieve Data (
rtvdtaSubroutine): - Chains to
bbcsrusingklcsr(f$co,f$crid) to retrieve the CSR record. -
If the record exists (
*IN99is*OFF):- If
crdelisI(inactive): - Sets the header
f$hdrto "CSR Id Entry ReActivate" (hdr(01)). - Sets the function key label
f$fkydto "F22=ReActivate" (fky(01)). - Sets
*IN72to*ON(likely for display formatting, e.g., color). - If
crdelis notI(active or other status): - Sets
f$hdrto "CSR Id Entry InActivate" (hdr(02)). - Sets
f$fkydto "F23=InActivate" (fky(02)). - Sets
*IN73to*ON.
- If
-
Process Window (
prcwdwSubroutine): -
Main Loop (
winagn):- Display Messages: If
dspmsgis*ON, callswrtmsgto display the message subfile; otherwise, writesmsgclrto clear messages. - Display Window: Executes
exfmt actwdwto display the window format and accept user input. - Clear Messages: If
dspmsgis*ON, callsclrmsgto clear the message subfile. - Clear Error Indicators: Resets indicators
*IN50to*IN69to zero. - Cursor Positioning: Contains commented-out code for calculating cursor position (
row,col) usingcsrloc. - Process User Input:
- F12 (Exit): Sets
winagnto*OFFto exit the loop. - F22 or F23 (ReActivate/InActivate):
- Calls
winedtto validate input (which callschkact). - If no errors (
*IN50is*OFF), callswinupdto update the database and setswinagnto*OFFto exit.
- Calls
- Other (e.g., Enter): Calls
winedtto validate input (no further action unless F22/F23 is pressed). - The loop continues until
winagnis*OFF.
- Display Messages: If
-
Edit Window Input (
winedtSubroutine): -
Calls
chkactto check activity prior to status change (no logic implemented inchkact). -
Check Activity (
chkactSubroutine): -
Currently empty, likely intended as a placeholder for checking if the CSR ID is used in other tables (e.g., vendor table, as indicated by the
Eflag inBB929P). -
Update Database (
winupdSubroutine): - ReActivate (F22):
- Chains to
bbcsrusingklcsr. - If the record exists (
*IN99is*OFF) andcrdelisI(inactive): - Sets
crdeltoA(active). - Updates the
bbcsrpfrecord. - Sets
p$flagtoAto indicate successful reactivation.
- Chains to
-
InActivate (F23):
- Chains to
bbcsrusingklcsr. - If the record exists (
*IN99is*OFF) andcrdelis notI(e.g., active): - Sets
crdeltoI(inactive). - Updates the
bbcsrpfrecord. - Sets
p$flagtoIto indicate successful inactivation.
- Chains to
-
Message Handling (
addmsg,wrtmsg,clrmsgSubroutines): - Add Message (
addmsg):- Sets
dspmsgto*ON. - Calculates the length of
m@dataand sends a message to the program message queue usingQMHSNDPM. - Clears message data fields.
- Sets
- Write Message Subfile (
wrtmsg):- Sets
*IN49to*ONand writes themsgctlformat to display messages.
- Sets
-
Clear Message Subfile (
clrmsg):- Sets
dspmsgto*OFF. - Calls
QMHRMVPMto clear messages (note: saving/restoringrcdnamandpagrrnis commented out, suggesting a simplified message clearing process).
- Sets
-
Program Termination:
- Closes all files.
- Sets
*INLRto*ONand returns.
Business Rules¶
The BB9294 program enforces the following business rules for inactivating or reactivating CSR IDs:
- Purpose:
-
The program toggles the status of a CSR record in the
bbcsrfile by updating thecrdelfield betweenA(active) andI(inactive). -
Input Parameters:
- Requires
p$co(company number) andp$crid(CSR ID) to identify the record. - Uses
p$fgrpto determine the file library (ZorG). -
Returns
p$flagasA(reactivated),I(inactivated), or unchanged if no action is taken. -
Status Toggle:
- ReActivate (F22): Only allowed if the record exists and
crdelisI. SetscrdeltoAand updates the record. - InActivate (F23): Only allowed if the record exists and
crdelis notI. SetscrdeltoIand updates the record. -
If the record does not exist (
*IN99is*ON), no update is performed, andp$flagremains unchanged. -
Activity Check:
-
The
chkactsubroutine is a placeholder, suggesting a business rule to check for dependencies (e.g., CSR ID used in a vendor table, as indicated by theEflag inBB929P). However, no logic is implemented, so no validation occurs. -
User Interface:
- Displays a window (
actwdw) with a header and function key label that reflect the current record status:- If inactive (
crdel = 'I'), shows "CSR Id Entry ReActivate" and "F22=ReActivate". - If active, shows "CSR Id Entry InActivate" and "F23=InActivate".
- If inactive (
- Supports function keys:
- F12: Exits the program without changes.
- F22: Triggers reactivation.
- F23: Triggers inactivation.
-
Provides message feedback using the
GSMSGFmessage file (though no specific error messages are used in the provided code). -
File Overrides:
-
Uses
p$fgrpto apply overrides, redirectingbbcsrtogbbcsrorzbcsrbased on the file group. -
Message Handling:
- Displays messages in a message subfile (
msgctl) and clears them as needed. Thecomarray includes a placeholder error message, but it is not used in the code.
Tables (Files) Used¶
The program uses the following files:
1. bb9294d:
- Type: Workstation file (display file).
- Usage: Contains the actwdw format for the inactivation/reactivation window, along with a message subfile (msgctl) and clear message format (msgclr).
- Handler: PROFOUNDUI(HANDLER) for Profound UI integration.
2. bbcsr:
- Type: Physical file (update/add, keyed access).
- Usage: Stores CSR records, used to retrieve and update the crdel field for status changes. Accessed using the key list klcsr (f$co, f$crid).
- Override: Redirected to gbbcsr or zbcsr based on p$fgrp.
External Programs Called¶
The program calls the following external program (an IBM i API):
1. QCMDEXC:
- Purpose: Executes the file override command to redirect bbcsr to the appropriate library.
- Parameters:
- dbov## (80 characters, override command).
- dbol## (15.5, command length).
2. QMHSNDPM:
- Purpose: Sends messages to the program message queue for display in the message subfile.
- Parameters: Message ID, message file, message data, data length, message type, program queue, stack counter, message key, error code.
3. QMHRMVPM:
- Purpose: Clears messages from the program message queue.
- Parameters: Program queue, stack counter, message key, remove option, error code.
Summary¶
The BB9294 RPGLE program, called by BB929P, is responsible for toggling the status of CSR ID records between active (A) and inactive (I) in the bbcsr file. It presents a confirmation window (actwdw) with dynamic headers and function key labels based on the current record status, allowing users to reactivate (F22) or inactivate (F23) a record. The program enforces rules to ensure status changes are only applied to existing records with the appropriate current status, and it uses file overrides to access the correct library (Z or G). It interacts with two files: bb9294d (display) and bbcsr (CSR data), and relies on IBM i APIs (QCMDEXC, QMHSNDPM, QMHRMVPM) for file overrides and message handling. The chkact subroutine suggests a potential business rule for dependency checking, but it is not implemented in the provided code.