BB928P RPGLE
The provided RPGLE program, BB928P, is designed to manage salesman IDs within a billing and invoicing system. It uses a display file with a subfile to interact with users, allowing them to view, create, update, inactivate, reactivate, or print salesman ID records. Below, I’ll explain the process steps, list the external programs called, and identify the database tables used.
Process Steps of the BB928P Program¶
The program follows a structured flow, primarily driven by user interaction with a subfile (SFL1) displayed on a workstation. Here’s a breakdown of the key process steps based on the program’s logic:
- Initialization (
*inzsrSubroutine): - Parameters: Receives input parameters
p$mode(run mode: 'MNT' for maintenance or 'INQ' for inquiry) andp$fgrp(file group: 'Z' or 'G'). - Genie Check: Calls
GSGENIE2Cto verify if the program is running in a Genie environment. Ifgenievaris not 'YES', the program closes all files and exits. - Field Setup: Initializes subfile control fields, message handling fields, and key lists (
klsfl1,kls1s1) for database access. Sets up date/time fields using the system timestamp. -
Headers: Sets the display header (
c$hdr1) from thehdrarray. -
Open Database Tables (
opntblSubroutine): - File Overrides: Based on
p$fgrp('G' or 'Z'), applies database overrides usingovgorovzarrays to point to the correct files (gbbslsm,zbbslsm,gbicont,zbicont). -
File Open: Opens the database files
bbslsm,bbslsmrd(renamed record format), andbicontfor input. -
Subfile Processing (
srsfl1Subroutine): - Clear Message Subfile: Calls
clrmsgto clear any existing messages in the message subfile andwrtmsgto write the message subfile control. - Subfile Initialization: Sets the subfile mode (
sfmod1) to folded (#fold = '0',*in45 = *on) and initializes control fields (c1co,c1smid) to zeros or blanks. - Inactive Records Filter: Sets
w$inactto*on(include inactive records) due to thejb01revision, which removed the F8 toggle functionality. - Protection Mode: Sets
*in70based onp$mode(*offfor 'MNT',*onfor 'INQ' to protect input fields in inquiry mode). - Initial Positioning: Calls
sf1repto position the file and load the subfile initially. -
Main Loop:
- Display: Writes the command line (
sflcmd1) and message subfile if needed, checks if subfile records exist to set*in41(SFLDSP), and determines folded/unfolded mode (*in45). - User Input: Displays the subfile control (
sflctl1) usingexfmtand processes user input based on function keys and direct input: - F3 (Exit): Sets
sf1agnto*offto exit the loop. - F4 (Field Prompting): Calls
promptto set*in19for cursor positioning. - F5 (Refresh): Clears positioning fields (
r$co,r$smid) and setsrepsflto reposition the subfile. - F8 (Toggle Inactive): Previously toggled
w$inactto include/exclude inactive records, butjb01revision defaults to include all records. - F15 (Print Listing): Calls
BB9285to print a salesman ID listing, passingp$fgrpas a parameter, and displays a confirmation message. - Direct Access: If
d1opt,d1co, ord1smidare non-zero, callssf1dirfor direct processing (create, change, inactivate, or display). - Page Down: Calls
sf1lodto load more subfile records. - Enter Key: Calls
sf1prcto process subfile changes. - Repositioning: If
c1coorc1smidare non-zero, callssf1repto reposition the subfile. F10 clears cursor positioning (row1,col1). - Cursor and Record Number: Updates cursor location (
row1,col1) and sets the subfile record number (rcdnb1) based onpagrrn.
- Display: Writes the command line (
-
Subfile Record Processing (
sf1prcSubroutine): - Reads subfile records (
sfl1) usingreadcuntil no more changed records (*in81). -
For each changed record, calls
sf1chgto process user-selected options. -
Process Subfile Record Change (
sf1chgSubroutine): - Stores selected values (
s1co,s1smid) ins$co,s$smid. - Processes options based on
s1opt:- Option 2 (Change): If in maintenance mode (
p$mode = 'MNT') and the record is not deleted/inactive, callssf1s02. - Option 4 (Inactivate/Reactivate): If in maintenance mode, calls
sf1s04. - Option 5 (Display): Calls
sf1s05.
- Option 2 (Change): If in maintenance mode (
-
Updates the subfile record after processing by chaining to
bbslsm, clearings1opt, formatting (sf1fmt), applying color coding (sf1col), and updatingsfl1. -
Reposition Subfile (
sf1repSubroutine): - Clears the subfile (
sf1clr) and resetsrrn1. - Validates control input (
sf1cte). - Positions the file using
kls1s1(based onc1co,c1smid) and loads the subfile (sf1lod). -
Retains control fields (
r$co,r$smid) for future repositioning. -
Edit Subfile Control Input (
sf1cteSubroutine): -
Currently empty, likely intended for future input validation.
-
Load Subfile Records (
sf1lodSubroutine): - Sets
rrn1to the last saved record number (rrnsv1) andrcdnb1to the next record number for display. - Loads up to
pagsz1(14) records:- Reads the next record from
bbslsmrd. - Skips deleted/inactive records if
w$inact = *off. - Formats the subfile line (
sf1fmt), applies color coding (sf1col), and writes tosfl1.
- Reads the next record from
-
Updates
rrnsv1with the lastrrn1. -
Format Subfile Line (
sf1fmtSubroutine): -
Clears the subfile record and populates fields (
s1co,s1smid,s1smnm,s1emal,s1del) from the database record. -
Subfile Color Coding (
sf1colSubroutine):- Sets
*in72(blue color) for deleted (s1del = 'D') or inactive (s1del = 'I') records.
- Sets
-
Direct Access Processing (
sf1dirSubroutine):- Validates direct input (
d1opt,d1co,d1smid): - For option 1 (create), ensures
d1coandd1smidare non-zero and checks if the company number exists inbicont. - Checks if the record exists in
bbslsmto prevent duplicate creation or invalid updates. - Processes valid options (1, 2, 4, 5) by calling
sf1s01,sf1s02,sf1s04, orsf1s05. - Clears input fields upon successful processing.
- Validates direct input (
-
Subfile Options:
- sf1s01 (Create): Calls
BB928in maintenance mode, passings$co,s$smid,p$fgrp, and mode 'MNT'. Displays a confirmation message if successful (o$flag = '1'). - sf1s02 (Change): Checks if the record is not deleted/inactive, calls
BB928in maintenance mode, and displays a confirmation message if successful. - sf1s04 (Inactivate/Reactivate): Calls
BB9284, processes the return flag ('I' for inactivated, 'A' for reactivated, 'E' for vendor-linked error), and displays a message. - sf1s05 (Display): Calls
BB928in inquiry mode to display the record.
- sf1s01 (Create): Calls
-
Field Prompting (
promptSubroutine):- Sets
*in19to indicate a panel format change for cursor positioning.
- Sets
-
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, preserving the current record format andpagrrn.
- addmsg: Sends messages to the program message queue using
-
Program Exit:
- Closes all files, sets
*inlr = *on, and returns.
- Closes all files, sets
External Programs Called¶
The program calls the following external programs:
1. GSGENIE2C: Checks if the program is running in a Genie environment, returning genievar ('YES' or not).
2. QCMDEXC: Executes file override commands for bbslsm, bbslsmrd, and bicont.
3. QMHSNDPM: Sends messages to the program message queue.
4. QMHRMVPM: Removes messages from the program message queue.
5. BB928: Handles create, change, and display operations for salesman ID records, called with parameters for company, salesman ID, mode, file group, and return flag.
6. BB9284: Manages inactivate/reactivate operations for salesman ID records.
7. BB9285: Prints a salesman ID listing, called with the file group parameter.
Database Tables Used¶
The program interacts with the following database files:
1. bbslsm: Primary input file for salesman ID records, opened with usropn.
2. bbslsmrd: Input file with a renamed record format (bbslsmpr) for salesman ID records, opened with usropn.
3. bicont: Input file for company records, used for validation, opened with usropn.
Additional Notes¶
- Display File:
bb928pdis a workstation file with a subfile (sfl1) and uses thePROFOUNDUI(HANDLER)for the user interface. - Indicators: The program uses indicators (19, 21–79, 90–99) to control display behavior, error handling, and subfile operations.
- Field Prefixes: Uses prefixes like
f$,c1,s1,p$, etc., to organize fields for display, control, and parameters. - Revisions: The
jb01revision (10/10/2023) modified the program to default to displaying all records (active and inactive) due to issues with Profound UI’s F8 functionality.
This program is a typical IBM i RPG application for interactive data management, leveraging subfiles for user interaction and database operations for data retrieval and manipulation.