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 (
*inzsr
Subroutine): - Parameter Reception: The program receives four parameters:
p$co
: Company number (input).p$crid
: CSR ID (input).p$fgrp
(1 character): File group (Z
orG
) for database overrides.p$flag
(1 character): Return flag (output, set toA
for reactivation orI
for inactivation).
- Field Initialization:
- Moves input parameters
p$co
andp$crid
to display file fieldsf$co
andf$crid
. - Defines key list
klcsr
for accessing thebbcsr
file usingf$co
andf$crid
. - Sets
winagn
to*ON
to control the window processing loop. - Initializes message handling fields (
dspmsg
to blank,m@pgmq
to*
,m@key
to 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 (
opntbl
Subroutine): - File Overrides: Based on
p$fgrp
(Z
orG
), applies a database override using theQCMDEXC
API to redirect access to thebbcsr
file to eithergbbcsr
orzbcsr
. -
File Opening: Opens the
bbcsr
file (update/add, keyed access). -
Retrieve Data (
rtvdta
Subroutine): - Chains to
bbcsr
usingklcsr
(f$co
,f$crid
) to retrieve the CSR record. -
If the record exists (
*IN99
is*OFF
):- If
crdel
isI
(inactive): - Sets the header
f$hdr
to "CSR Id Entry ReActivate" (hdr(01)
). - Sets the function key label
f$fkyd
to "F22=ReActivate" (fky(01)
). - Sets
*IN72
to*ON
(likely for display formatting, e.g., color). - If
crdel
is notI
(active or other status): - Sets
f$hdr
to "CSR Id Entry InActivate" (hdr(02)
). - Sets
f$fkyd
to "F23=InActivate" (fky(02)
). - Sets
*IN73
to*ON
.
- If
-
Process Window (
prcwdw
Subroutine): -
Main Loop (
winagn
):- Display Messages: If
dspmsg
is*ON
, callswrtmsg
to display the message subfile; otherwise, writesmsgclr
to clear messages. - Display Window: Executes
exfmt actwdw
to display the window format and accept user input. - Clear Messages: If
dspmsg
is*ON
, callsclrmsg
to clear the message subfile. - Clear Error Indicators: Resets indicators
*IN50
to*IN69
to zero. - Cursor Positioning: Contains commented-out code for calculating cursor position (
row
,col
) usingcsrloc
. - Process User Input:
- F12 (Exit): Sets
winagn
to*OFF
to exit the loop. - F22 or F23 (ReActivate/InActivate):
- Calls
winedt
to validate input (which callschkact
). - If no errors (
*IN50
is*OFF
), callswinupd
to update the database and setswinagn
to*OFF
to exit.
- Calls
- Other (e.g., Enter): Calls
winedt
to validate input (no further action unless F22/F23 is pressed). - The loop continues until
winagn
is*OFF
.
- Display Messages: If
-
Edit Window Input (
winedt
Subroutine): -
Calls
chkact
to check activity prior to status change (no logic implemented inchkact
). -
Check Activity (
chkact
Subroutine): -
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
E
flag inBB929P
). -
Update Database (
winupd
Subroutine): - ReActivate (F22):
- Chains to
bbcsr
usingklcsr
. - If the record exists (
*IN99
is*OFF
) andcrdel
isI
(inactive): - Sets
crdel
toA
(active). - Updates the
bbcsrpf
record. - Sets
p$flag
toA
to indicate successful reactivation.
- Chains to
-
InActivate (F23):
- Chains to
bbcsr
usingklcsr
. - If the record exists (
*IN99
is*OFF
) andcrdel
is notI
(e.g., active): - Sets
crdel
toI
(inactive). - Updates the
bbcsrpf
record. - Sets
p$flag
toI
to indicate successful inactivation.
- Chains to
-
Message Handling (
addmsg
,wrtmsg
,clrmsg
Subroutines): - Add Message (
addmsg
):- Sets
dspmsg
to*ON
. - Calculates the length of
m@data
and sends a message to the program message queue usingQMHSNDPM
. - Clears message data fields.
- Sets
- Write Message Subfile (
wrtmsg
):- Sets
*IN49
to*ON
and writes themsgctl
format to display messages.
- Sets
-
Clear Message Subfile (
clrmsg
):- Sets
dspmsg
to*OFF
. - Calls
QMHRMVPM
to clear messages (note: saving/restoringrcdnam
andpagrrn
is commented out, suggesting a simplified message clearing process).
- Sets
-
Program Termination:
- Closes all files.
- Sets
*INLR
to*ON
and 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
bbcsr
file by updating thecrdel
field betweenA
(active) andI
(inactive). -
Input Parameters:
- Requires
p$co
(company number) andp$crid
(CSR ID) to identify the record. - Uses
p$fgrp
to determine the file library (Z
orG
). -
Returns
p$flag
asA
(reactivated),I
(inactivated), or unchanged if no action is taken. -
Status Toggle:
- ReActivate (F22): Only allowed if the record exists and
crdel
isI
. Setscrdel
toA
and updates the record. - InActivate (F23): Only allowed if the record exists and
crdel
is notI
. Setscrdel
toI
and updates the record. -
If the record does not exist (
*IN99
is*ON
), no update is performed, andp$flag
remains unchanged. -
Activity Check:
-
The
chkact
subroutine is a placeholder, suggesting a business rule to check for dependencies (e.g., CSR ID used in a vendor table, as indicated by theE
flag 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
GSMSGF
message file (though no specific error messages are used in the provided code). -
File Overrides:
-
Uses
p$fgrp
to apply overrides, redirectingbbcsr
togbbcsr
orzbcsr
based on the file group. -
Message Handling:
- Displays messages in a message subfile (
msgctl
) and clears them as needed. Thecom
array 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.