BB928 RPGLE
The RPGLE program BB928 is a component of a billing and invoicing system designed to handle the maintenance and inquiry of salesman ID entries. It is called by the main program BB928P (as referenced in the previous document) to perform specific operations such as creating, updating, or displaying salesman ID records. 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 BB928 Program¶
The program is structured to interact with a display file (bb928d) and manage salesman ID records through a single panel format (fmt01). It operates in either maintenance (MNT) or inquiry (INQ) mode, based on input parameters. Here’s a detailed breakdown of the process steps:
- Initialization (
*inzsrSubroutine): - Parameters: Receives input parameters:
p$co: Company number.p$smid: Salesman ID.p$mode: Run mode (MNTfor maintenance,INQfor inquiry).p$fgrp: File group (ZorG).p$flag: Return flag to indicate success or failure.
- Field Setup: Moves input parameters
p$coandp$smidto display file fields (f$co,f$smid). Initializes output parameters (o$co,o$smid,o$mode,o$fgrp,o$flag) and miscellaneous fields (fmtagn,delagn,dspmsg,m@pgmq,m@key). -
Keylist: Defines
klslsmkeylist usingf$coandf$smidfor database access. -
Open Database Tables (
opntblSubroutine): - File Overrides: Based on
p$fgrp(GorZ), applies database overrides fromovgorovzarrays to point to the correct files (gbbslsmorzbbslsm,gbicontorzbicont) using theQCMDEXCprogram. -
File Open: Opens
bbslsm(update/add mode) andbicont(input mode) withusropn. Chains tobicontusingf$coto validate the company number. -
Retrieve Data (
rtvdtaSubroutine): - Record Retrieval: Chains to
bbslsmusingklslsm(company and salesman ID) to check if the record exists.- If the record is not found (
*in99 = *on), clears the record buffer (bbslsmpf) and setsw$existsto*off. - If found, sets
w$existsto*on.
- If the record is not found (
-
Header and Protection: Sets the display header (
c$hdr1) to "Salesman Id Entry Maintenance" or "Salesman Id Inquiry" based onp$mode. Sets*in70to*onfor inquiry mode (protecting input fields) or*offfor maintenance mode. -
Process Panel Formats (
srfmtSubroutine): - Clear Screen: Writes the
clrscrformat to clear the display. - Initial Setup: Calls
f01movto initialize format fields and setsw$fmttoFMT01. -
Main Loop:
- Displays the message subfile if
dspmsgis*on(viawrtmsg) or clears the screen. - Sets
*in19to*offto indicate no format change. - Displays
fmt01usingexfmt(other formats likefmt02are commented out, indicating onlyfmt01is currently used). - Clears error indicators (
*in50–*in69) and cursor position (row,col). - Clears the message subfile if
dspmsgis*on(viaclrmsg). - Processes the current format (
fmt01) by callingf01sr.
- Displays the message subfile if
-
Process Format (
f01srSubroutine): -
Handles user input for
fmt01:- F4 (Field Prompting): Calls
promptto set*in19for cursor positioning. - F10 (Position Cursor Home): Clears cursor position (
row,col). - F12 (Exit): Sets
fmtagnto*offto exit the loop. - Inquiry Mode: If
p$mode = 'INQ', callsf01nxtto determine the next format (though it currently exits the loop). - Enter Key:
- Validates input fields via
f01edt. - If no errors (
*in50 = *off) and in maintenance mode (p$mode = 'MNT'), updates the database viaupddbf. - Calls
f01nxtto determine the next format or exit.
- F4 (Field Prompting): Calls
-
Determine Next Format (
f01nxtSubroutine): -
If
*in19is*off, setsfmtagnto*offto exit the main loop (no additional formats likefmt02are used). -
Edit Format Input (
f01edtSubroutine): - Validates input fields in
fmt01:- Checks if
smsmnm(salesman name) is blank, settingm@idtoERR0012,*in50, and*in51if true. - Checks if
smemal(email address) is blank, settingm@idtoERR0012,*in50, and*in52if true.
- Checks if
-
In inquiry mode (
p$mode = 'INQ'), clears error indicators and messages to prevent validation errors. -
Initialize Format Fields (
f01movSubroutine): -
Calls
f01edtto validate fields and clears error indicators and messages if validation fails. -
Format Protection Schemes (
f01proSubroutine): -
Sets protection indicators:
- Clears
*in70–*in74by default. - In inquiry mode (
p$mode ≠ 'MNT'), sets*in70–*in73to*onto protect input fields. - In maintenance mode, if the record exists (
w$exists = *on), sets*in71to protect key fields (f$co,f$smid).
- Clears
-
Update Database (
upddbfSubroutine):- Saves current field values to
svds. - Chains to
bbslsmusingklslsm: - If the record exists (
*in80 = *off):- If fields have changed (
svds ≠ wkds01), restoressvdstowkds01and updates the record (bbslsmpf). - Sets
p$flagto1to indicate success. - If no changes, forces end-of-data (
feod) to reset the file pointer.
- If fields have changed (
- If the record does not exist:
- Clears the record buffer, sets
smco(company),smsmid(salesman ID), andsmdeltoA(active), and writes a new record tobbslsmpf. - Sets
p$flagto1.
- Clears the record buffer, sets
- Saves current field values to
-
Field Prompting (
promptSubroutine):- Determines cursor location (
row,col) fromcsrlocand sets*in19to indicate a format change.
- Determines cursor location (
-
Message Handling:
- addmsg: Sends error 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, preserving the current record format andpagrrn.
- addmsg: Sends error messages to the program message queue using
-
Program Exit:
- Closes all files, sets
*inlrto*on, and returns to the calling program (BB928P).
- Closes all files, sets
Business Rules¶
The program enforces the following business rules:
1. Input Validation:
- Salesman name (smsmnm) and email address (smemal) are mandatory fields. If either is blank, an ERR0012 message is displayed, and error indicators (*in50, *in51, *in52) are set.
- In inquiry mode, validation errors are cleared to allow read-only access.
2. Mode-Based Access:
- Maintenance Mode (MNT):
- Allows creation or update of salesman ID records.
- Protects key fields (f$co, f$smid) if the record exists (w$exists = *on) to prevent changes to the company or salesman ID.
- Updates or creates records in bbslsm and sets p$flag to 1 on success.
- Inquiry Mode (INQ):
- Protects all input fields (*in70–*in73) to prevent modifications.
- Displays existing records without allowing changes.
3. Record Existence:
- Checks if the salesman ID record exists in bbslsm before displaying or updating.
- Creates a new record with smdel = 'A' (active) if it does not exist.
4. Company Validation:
- Validates the company number (f$co) against bicont during file open.
5. Message Handling:
- Displays error messages for invalid input and clears them after display or in inquiry mode.
6. Database Integrity:
- Uses file overrides to select the correct database files based on p$fgrp (G or Z).
- Ensures only changed records are updated, and new records are written with appropriate default values.
Database Tables Used¶
The program interacts with the following database files:
1. bbslsm: Primary file for salesman ID records, opened in update/add mode (uf a) with usropn. Used for reading, updating, and creating records.
2. bicont: Input file for company records, opened with usropn. Used to validate the company number (f$co).
External Programs Called¶
The program calls the following external programs:
1. QCMDEXC: Executes file override commands for bbslsm and bicont.
2. QMHSNDPM: Sends messages to the program message queue for error display.
3. QMHRMVPM: Removes messages from the program message queue.
Additional Notes¶
- Display File:
bb928dis a workstation file using thePROFOUNDUI(HANDLER)for the user interface, with a single active format (fmt01). References tofmt02are commented out, suggesting it was planned but not implemented. - Indicators: Uses indicators (19, 21–79, 90–99) for screen control, error handling, and field protection, consistent with
BB928P. - Field Prefixes: Follows the same naming conventions as
BB928P(e.g.,f$for display fields,p$for input parameters,o$for output parameters). - Integration with BB928P:
BB928is called byBB928Pfor options 1 (create), 2 (change), and 5 (display) to handle individual record operations, returning a flag (p$flag) to indicate success.
This program is a focused module for maintaining or viewing salesman ID records, complementing the subfile-based interface of BB928P by providing detailed record manipulation functionality.