BB9284 RPGLE
The RPGLE program BB9284 is a specialized module within a billing and invoicing system, designed to handle the inactivation and reactivation of salesman ID entries. It is called by the main program BB928P (as referenced in the earlier document) to perform these specific operations. The program uses a display file (bb9284d) to present a window (actwdw) for user interaction and updates the salesman ID record status in the database. Below, I’ll explain the process steps, outline the business rules, list the database tables used, and identify any external programs called.
Process Steps of the BB9284 Program¶
The program is structured to display a window for confirming the inactivation or reactivation of a salesman ID record and update the database accordingly. It operates in a single mode, focusing on toggling the record’s status (smdel) between active (A) and inactive (I). Here’s a detailed breakdown of the process steps:
- Initialization (
*inzsrSubroutine): - Parameters: Receives input parameters:
p$co: Company number.p$smid: Salesman ID.p$fgrp: File group (ZorG).p$flag: Return flag to indicate the outcome (e.g.,Ifor inactivated,Afor reactivated).
- Field Setup: Moves input parameters
p$coandp$smidto display file fields (f$co,f$smid). Initializeswinagnto*onto control the window processing loop, and sets up message handling fields (dspmsg,m@pgmq,m@key). - Keylist: Defines
klslsmkeylist usingf$coandf$smidfor database access. -
Date Validation: Defines a parameter list (
pld010) for a potential date validation module (dtp010r), though it is not used in the provided code. -
Open Database Tables (
opntblSubroutine): - File Overrides: Based on
p$fgrp(GorZ), applies a database override fromovgorovzarrays to point to the correct file (gbbslsmorzbbslsm) using theQCMDEXCprogram. -
File Open: Opens
bbslsmin update/add mode (uf a) withusropn. -
Retrieve Data (
rtvdtaSubroutine): -
Record Retrieval: Chains to
bbslsmusingklslsm(company and salesman ID) to retrieve the record.- If the record exists (
*in99 = *off): - If
smdel = 'I'(inactive), sets the display header (f$hdr) to "Salesman Id Entry ReActivate" (hdr(01)), function key label (f$fkyd) to "F22=ReActivate" (fky(01)), and*in72to*on(indicating reactivation is available). - Otherwise, sets
f$hdrto "Salesman Id Entry InActivate" (hdr(02)),f$fkydto "F23=InActivate" (fky(02)), and*in73to*on(indicating inactivation is available).
- If the record exists (
-
Process Window (
prcwdwSubroutine): - Main Loop: Runs while
winagn = *on:- Display Messages: If
dspmsg = *on, callswrtmsgto display the message subfile; otherwise, writesmsgclrto clear the message area. - Display Window: Displays the
actwdwwindow usingexfmt. - Clear Messages: If
dspmsg = *on, callsclrmsgto clear the message subfile. - Clear Indicators: Clears error indicators (
*in50–*in69) usingzero20. - Process User Input:
- F12 (Exit): Sets
winagnto*offto exit the loop without changes. - F22 (ReActivate) or F23 (InActivate):
- Calls
winedtto validate input (which callschkact). - If no errors (
*in50 = *off), callswinupdto update the database and setswinagnto*offto exit.
- Calls
- Other (e.g., Enter): Calls
winedtto validate input but does not update the database.
- Display Messages: If
-
Cursor Positioning: Commented-out code suggests cursor location (
row,col) could be calculated fromcsrloc, but it is not currently used. -
Edit Window Input (
winedtSubroutine): -
Calls
chkactto perform validation, thoughchkactis currently empty, indicating no specific input validation is implemented. -
Check Activity (
chkactSubroutine): -
Currently empty, likely intended for future validation of the salesman ID’s activity (e.g., checking if the record is linked to other data preventing inactivation).
-
Update Database (
winupdSubroutine): -
Processes based on the function key:
- F22 (ReActivate):
- Chains to
bbslsmusingklslsm. - If the record exists (
*in99 = *off) and is inactive (smdel = 'I'), setssmdeltoA(active), updates the record (bbslsmpf), and setsp$flagtoA. - F23 (InActivate):
- Chains to
bbslsmusingklslsm. - If the record exists (
*in99 = *off) and is not already inactive (smdel ≠ 'I'), setssmdeltoI(inactive), updates the record (bbslsmpf), and setsp$flagtoI.
-
Message Handling:
- addmsg: Sends messages to the program message queue using
QMHSNDPM, settingdspmsgto*on. - wrtmsg: Writes the message subfile control (
msgctl) with*in49enabled. -
clrmsg: Clears the message subfile using
QMHRMVPM. Commented-out code for saving/restoringrcdnamandpagrrnsuggests it was planned but not needed for the window format. -
Program Exit:
- Closes all files, sets
*inlrto*on, and returns to the calling program (BB928P).
Business Rules¶
The program enforces the following business rules:
1. Record Status Toggle:
- A salesman ID record can be toggled between active (smdel = 'A') and inactive (smdel = 'I') states.
- Only inactive records can be reactivated (F22), and only non-inactive records can be inactivated (F23).
2. Record Existence:
- The program checks if the salesman ID record exists in bbslsm before allowing status changes.
- If the record does not exist or is in an invalid state (e.g., already inactive for F23), no update occurs.
3. User Interface:
- The window (actwdw) displays a header and function key label based on the record’s current status:
- Inactive records show "Salesman Id Entry ReActivate" with F22 enabled.
- Active records show "Salesman Id Entry InActivate" with F23 enabled.
- F12 allows the user to exit without changes.
4. Database Integrity:
- Uses file overrides to select the correct database file (gbbslsm or zbbslsm) based on p$fgrp.
- Updates only the smdel field in the bbslsm record, preserving other fields.
5. Return Flag:
- Sets p$flag to A for reactivation or I for inactivation to inform the calling program (BB928P) of the outcome.
Database Tables Used¶
The program interacts with the following database file:
1. bbslsm: Primary file for salesman ID records, opened in update/add mode (uf a) with usropn. Used for reading and updating the record status (smdel).
External Programs Called¶
The program calls the following external program:
1. QCMDEXC: Executes the file override command for bbslsm.
2. QMHSNDPM: Sends messages to the program message queue for error or confirmation display.
3. QMHRMVPM: Removes messages from the program message queue.
Additional Notes¶
- Display File:
bb9284dis a workstation file using thePROFOUNDUI(HANDLER)for the user interface, with a single window format (actwdw) for inactivation/reactivation. - Indicators: Uses indicators (19, 21–79, 90–99) for screen control and message handling, consistent with
BB928PandBB928. Notably,*in72and*in73control the display of reactivation/inactivation options. - Field Prefixes: Follows the same naming conventions as
BB928PandBB928(e.g.,f$for display fields,p$for input parameters,o$for output parameters). - Integration with BB928P:
BB9284is called byBB928Pfor option 4 (inactivate/reactivate) to toggle the status of a salesman ID record, returning a flag (p$flag) to indicate the result. - Empty Subroutine: The
chkactsubroutine is empty, suggesting that additional validation (e.g., checking for dependencies like vendor links inBB928P) was planned but not implemented.
This program is a focused module for toggling the active/inactive status of salesman ID records, complementing the broader functionality of BB928P and BB928 by providing a simple, user-driven interface for status changes.