BB929P RPGLE
The provided document is an RPGLE program named BB929P, part of a Billing and Invoicing system, designed to manage Customer Service Representative (CSR) IDs. Below, I will explain the process steps of the program, list the external programs called, and identify the tables (files) used.
Process Steps of the RPGLE Program (BB929P)¶
The program is a workstation-based interactive application that uses a subfile (SFL) to display and manage CSR IDs. It operates in either maintenance (MNT) or inquiry (INQ) mode, with functionality to create, change, inactivate/reactivate, and display CSR records. 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 two input parameters:
p$mode(3 characters): Specifies the run mode (MNTfor maintenance orINQfor inquiry).p$fgrp(1 character): Specifies the file group (ZorG) for database overrides.
- Genie Check: The program checks if it is being called from the Genie environment by calling
GSGENIE2C. Ifgenievaris notYES, the program closes all files and terminates. - Field Initialization: Initializes various fields, including:
- Subfile control fields (e.g.,
rrn1,rrnsv1,pagsz1set to 14 for page size). - Message handling fields (e.g.,
dspmsg,m@pgmq). - Current date and time (
t#time,t#cymd). - Key lists (
klsfl1,kls1s1) for file access.
- Subfile control fields (e.g.,
-
Header Setup: Sets the display header (
c$hdr1) from thehdrarray. -
Open Database Tables (
opntblSubroutine): - File Overrides: Based on the
p$fgrpparameter (ZorG), applies database overrides using theQCMDEXCAPI to redirect file access to the appropriate library (gbbcsr,zbcsr,gbicont,zbicont). -
File Opening: Opens three files:
bbcsr(CSR master file, input-only).bbcsrrd(CSR master file with renamed record format, input-only).bicont(control file, input-only).
-
Process Subfile (
srsfl1Subroutine): - Clear Message Subfile: Calls
clrmsgto clear any existing messages andwrtmsgto display the message subfile. - Subfile Mode Initialization:
- Sets
sfmod1to'1'and#foldto'0'to control folded/unfolded display mode. - Initializes subfile control fields (
c1co,c1crid) to zeros or blanks. - Sets
w$inactto*ON(display all records, including inactive ones, per revisionjb01).
- Sets
- Global Protection: Sets indicator
*IN70based onp$mode:*OFFfor maintenance mode (MNT).*ONfor inquiry mode (INQ), protecting input fields.
- Subfile Repositioning: Calls
sf1repto position the file and load the subfile initially. -
Main Loop (
sf1agn):- Reposition Subfile: If
repsflis*ON, updates control fields (c1co,c1crid) and callssf1repto reposition the subfile. - Display Command Line: Writes the
sflcmd1format (command line). - Display Message Subfile: If
dspmsgis*ON, callswrtmsg; otherwise, writesmsgclrto clear messages. - Subfile Display Check: Sets
*IN41(SFLDSP) based on whetherrrn1(relative record number) is greater than zero. - Folded/Unfolded Mode: Sets
*IN45based onsfmod1and#foldto control subfile display mode. - Display Subfile Control: Sets
*IN40(SFLDSPCTL) to*ONand executesexfmt sflctl1to display the subfile control format and accept user input. - Clear Messages: If
dspmsgis*ON, callsclrmsgto clear the message subfile. - Clear Indicators: Resets screen error indicators (
*IN21to*IN39,*IN50to*IN69) to zero. - Cursor Positioning: Calculates row (
row1) and column (col1) for the cursor usingcsrloc. - Set Record Number: Sets
rcdnb1topagrrnto ensure the correct subfile page is displayed. - Process User Input (Before Subfile Read):
- F03 (Exit): Sets
sf1agnto*OFFto exit the loop. - F04 (Field Prompting): Calls
promptto handle field prompting and iterates. - F05 (Refresh): Clears
r$co, setsrepsflto*ON, and iterates to refresh the subfile. - F08 (Toggle Inactive Filter): Toggles
w$inactbetween*ONand*OFFto include/exclude inactive records, setsrepsflto*ON, and iterates. (Note: F8 functionality is commented out for Profound UI, defaulting to include all records.) - F15 (Print Listing): Calls
BB9295with parameters to print a CSR ID listing, sends a confirmation message, and iterates. - Direct Access: If
d1opt,d1co, ord1cridis non-blank/zero, callssf1dirto process direct access options. - Page Down: If the
PAGEDNkey is pressed, callssf1lodto load the next page of subfile records. - Process Subfile on Enter: If the
ENTERkey is pressed, callssf1prcto process subfile changes. - Process User Input (After Subfile Read):
- Position Request: If
c1coorc1cridis non-blank/zero, callssf1repto reposition the subfile. - F10 (Position Cursor): Clears
row1andcol1to reposition the cursor to the control record. - The loop continues until
sf1agnis*OFF.
- Reposition Subfile: If
-
Process Subfile on Enter (
sf1prcSubroutine): - Reads changed subfile records using
readc sfl1(indicator*IN81). -
For each changed record, calls
sf1chgto process the selected option. -
Process Subfile Record Change (
sf1chgSubroutine): - Retains selected values (
s1co,s1crid) ins$coands$crid. - Processes based on the subfile option (
s1opt):- Option 2 (Change): If in
MNTmode and the record is not deleted (s1delis notDorI), callssf1s02. - Option 4 (Inactivate/Reactivate): If in
MNTmode, callssf1s04. - Option 5 (Display): Calls
sf1s05.
- Option 2 (Change): If in
-
Updates the subfile record by chaining to
bbcsrandsfl1, clearings1opt, formatting the record (sf1fmt), applying color coding (sf1col), and updating the subfile. -
Reposition Subfile (
sf1repSubroutine): - Clears the subfile (
sf1clr) and resetsrrn1. - Edits subfile control input (
sf1cte). - If no errors (
*IN50is*OFF), positions the file usingsetllonbbcsrrdand loads the subfile (sf1lod). -
Retains control fields (
c1co,c1crid) inr$coandr$cridfor repositioning. -
Edit Subfile Control Input (
sf1cteSubroutine): -
Currently empty, likely intended for input validation (not implemented in the provided code).
-
Load Subfile Records (
sf1lodSubroutine): - Sets
rrn1to the last saved relative record number (rrnsv1). - Sets
rcdnb1torrn1 + 1to ensure the new page is displayed. - Loads up to
pagsz1(14) records:- Reads the next record from
bbcsrrd(indicator*IN43for end-of-file). - Skips deleted or inactive records (
crdel=DorI) ifw$inactis*OFF. - Formats the subfile line (
sf1fmt), applies color coding (sf1col), and writes the record tosfl1. - Increments
rrn1.
- Reads the next record from
-
Saves the last
rrn1inrrnsv1. -
Format Subfile Detail Line (
sf1fmtSubroutine): - Clears the subfile record (
sfl1). -
Moves fields from the file record (
crco,crcrid,crcrnm,cremal,crdel) to subfile fields (s1co,s1crid,s1crnm,s1emal,s1del). -
Subfile Color Coding (
sf1colSubroutine):- Sets
*IN72to*ON(blue color) if the record is deleted or inactive (s1del=DorI).
- Sets
-
Direct Access Processing (
sf1dirSubroutine):- Retains direct input values (
d1co,d1crid) ins$coands$crid. - Validates input:
- For option 1 (Create), ensures
d1coandd1cridare not blank/zero; otherwise, sets errorERR0103. - For option 1, checks if
d1coexists inbicont; if not, sets errorERR0021. - Checks if the record exists in
bbcsrusingsetll:- For non-create options, if the record exists, proceeds; otherwise, sets error
ERR0102. - For create, if the record exists, sets error
ERR0101(cannot create duplicate).
- For non-create options, if the record exists, proceeds; otherwise, sets error
- If no errors (
*IN50is*OFF), processes the option: - Option 1 (Create): Calls
sf1s01. - Option 2 (Change): Calls
sf1s02. - Option 4 (Inactivate/Reactivate): Calls
sf1s04. - Option 5 (Display): Calls
sf1s05. - Clears input fields and cursor position if no errors.
- Retains direct input values (
-
Subfile Option 01 - Create (
sf1s01Subroutine):- Calls
BB929with parameters: s$co,s$crid(key fields).o$modeset toMNT.p$fgrp(file group).o$flag(return flag).- If
o$flagis1, sends a confirmation message (Code <crid> has been created), setsc1coandc1crid, and setsrepsflto*ONto reposition the subfile.
- Calls
-
Subfile Option 02 - Change (
sf1s02Subroutine):- Chains to
bbcsrto check if the record is deleted or inactive (crdel=DorI). If so, sends error messageCannot Modify An Inactive Record. - If valid, calls
BB929with parameters similar tosf1s01. - If
o$flagis1, sends a confirmation message (Code <crid> has been changed).
- Chains to
-
Subfile Option 04 - Inactivate/Reactivate (
sf1s04Subroutine):- Calls
BB9294with parameters: s$co,s$crid(key fields).p$fgrp(file group).o$flag(return flag).- Processes the return flag:
I: Sends messageCode <crid> has been InActivated.A: Sends messageCode <crid> has been ReActivated.E: Sends messageCode <crid> <vendor table error>.- Stores
o$coina$co.
- Calls
-
Subfile Option 05 - Display Customer Order (
sf1s05Subroutine):- Calls
BB929with parameters, settingo$modetoINQfor inquiry mode.
- Calls
-
Field Prompting (
promptSubroutine):- Sets
*IN19to*ONto indicate panel format input change. - (Note: Cursor positioning code is commented out.)
- Sets
-
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.
- Write Message Subfile (
wrtmsg): - Sets
*IN49to*ONand writes themsgctlformat to display messages. - Clear Message Subfile (
clrmsg): - Sets
dspmsgto*OFF. - Saves and restores the current record format (
rcdnam) andpagrrn. - Clears messages using
QMHRMVPM.
- Add Message (
-
Program Termination:
- Closes all files.
- Sets
*INLRto*ONand returns.
External Programs Called¶
The program calls the following external programs:
1. GSGENIE2C:
- Called during initialization to check if the program is running in the Genie environment.
- Parameter: genievar (3 characters, returns YES if in Genie).
2. BB929:
- Called for options 1 (Create), 2 (Change), and 5 (Display).
- Parameters:
- o$co (company number, output).
- o$crid (CSR ID, output).
- o$mode (MNT or INQ, output).
- o$fgrp (file group Z or G, output).
- o$flag (return flag, output).
3. BB9294:
- Called for option 4 (Inactivate/Reactivate).
- Parameters:
- o$co (company number, output).
- o$crid (CSR ID, output).
- o$fgrp (file group Z or G, output).
- o$flag (return flag: I, A, or E, output).
4. BB9295:
- Called for F15 (Print Listing).
- Parameter: o$fgrp (file group Z or G, output).
5. QCMDEXC:
- IBM i API called to execute file override commands.
- Parameters:
- dbov## (80 characters, override command).
- dbol## (15.5, command length).
6. QMHSNDPM:
- IBM i API called to send messages to the program message queue.
- Parameters: Message ID, message file, message data, data length, message type, program queue, stack counter, message key, error code.
7. QMHRMVPM:
- IBM i API called to clear messages from the program message queue.
- Parameters: Program queue, stack counter, message key, remove option, error code.
Tables (Files) Used¶
The program uses the following files:
1. bb929pd:
- Type: Workstation file (display file).
- Usage: Contains the subfile sfl1 and control format sflctl1 for the user interface.
- Handler: PROFOUNDUI(HANDLER) for Profound UI integration.
2. bbcsr:
- Type: Physical file (input-only).
- Usage: Master file for CSR records, accessed using key list klsfl1.
- Override: Redirected to gbbcsr or zbcsr based on p$fgrp.
3. bbcsrrd:
- Type: Physical file (input-only) with renamed record format (bbcsrpf to bbcsrpr).
- Usage: Used for sequential reading and positioning, accessed using key list kls1s1.
- Override: Redirected to gbbcsr or zbcsr based on p$fgrp.
4. bicont:
- Type: Physical file (input-only).
- Usage: Control file to validate company numbers (d1co).
- Override: Redirected to gbicont or zbicont based on p$fgrp.
Summary¶
The BB929P program is an interactive RPGLE application that manages CSR IDs using a subfile-based interface. It supports creating, changing, inactivating/reactivating, and displaying records, with options to filter inactive records (though modified to always include them per jb01). The program uses database overrides to access files in different libraries (Z or G), integrates with Profound UI, and provides message handling for user feedback. It calls external programs (BB929, BB9294, BB9295, GSGENIE2C) and IBM i APIs (QCMDEXC, QMHSNDPM, QMHRMVPM) to perform its functions, and interacts with three database files (bbcsr, bbcsrrd, bicont) and one display file (bb929pd).