BB929 RPGLE
The BB929 RPGLE program is part of the Billing and Invoicing system and is designed for CSR (Customer Service Representative) ID Entry Maintenance and Inquiry. It is called by the main program BB929P to handle the creation, modification, or inquiry of individual CSR records. 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 (BB929)¶
The program is an interactive workstation-based application that uses a display file (bb929d) to present a single record format (FMT01) for maintaining or inquiring CSR ID records. It operates in either maintenance (MNT) or inquiry (INQ) mode, allowing users to create or update CSR records or view them without modification. 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 five parameters:
p$co: Company number (input).p$crid: CSR ID (input).p$mode(3 characters): Run mode (MNTfor maintenance,INQfor inquiry).p$fgrp(1 character): File group (ZorG) for database overrides.p$flag(1 character): Return flag (output, set to1on successful update/create).
- Field Initialization:
- Moves input parameters
p$coandp$cridto display file fieldsf$coandf$crid. - Initializes output parameters (
o$co,o$crid,o$mode,o$fgrp,o$flag) to blanks or zeros. - Sets up message handling fields (
dspmsg,m@pgmq,m@key). - Defines key list
klcsrfor accessing thebbcsrfile usingf$coandf$crid. - Initializes flags (
fmtagn,delagn,winagn) to*OFF.
- Moves input parameters
-
Commented Test Code: Includes commented-out code for testing with hardcoded values (e.g.,
p$mode = 'MNT'). -
Open Database Tables (
opntblSubroutine): - File Overrides: Based on
p$fgrp(ZorG), applies database overrides using theQCMDEXCAPI to redirect file access to the appropriate library (gbbcsrorzbcsrforbbcsr,gbicontorzbicontforbicont). - File Opening: Opens two files:
bbcsr(update/add, keyed access).bicont(input-only, keyed access).
-
Company Validation: Chains to
bicontusingf$coto validate the company number (no specific error handling is implemented here). -
Retrieve Data (
rtvdtaSubroutine): - Record Retrieval: Chains to
bbcsrusing the key listklcsr(f$co,f$crid) to check if the record exists.- If
*IN99is*ON(record not found), clears thebbcsrpfrecord format and setsw$existsto*OFF. - If
*IN99is*OFF(record found), setsw$existsto*ON.
- If
-
Header and Protection Setup:
- If
p$modeisMNT, sets*IN70to*OFF(no global protection) and sets the headerc$hdr1to "CSR Id Entry Maintenance". - If
p$modeisINQ, sets*IN70to*ON(global protection) and setsc$hdr1to "CSR Id Inquiry".
- If
-
Process Panel Formats (
srfmtSubroutine): - Clear Screen: Writes the
clrscrformat to clear the display. - Initialize Format: Calls
f01movto initialize fields for theFMT01format and setsw$fmttoFMT01. -
Main Loop (
fmtagn):- Display Messages: If
dspmsgis*ON, callswrtmsgto display the message subfile; otherwise, writesclrscr. - Clear Format Change Indicator: Sets
*IN19to*OFF. - Display Format:
- If
w$fmtisFMT01, callsf01proto set protection indicators and executesexfmt fmt01to display the format and accept user input. - If
w$fmtis notFMT01, defaults to processingFMT01(note:FMT02is commented out, indicating it may not be used). - Clear Error Indicators: Resets indicators
*IN50to*IN69to zero. - Clear Cursor Position: Clears
rowandcol. - Clear Messages: If
dspmsgis*ON, callsclrmsgto clear the message subfile. - Process Format Input: If the current format is
FMT01, callsf01srto process user input. - The loop continues until
fmtagnis*OFF.
- Display Messages: If
-
Process Format (
f01srSubroutine): -
Handle User Input:
- F04 (Field Prompting): Calls
promptto handle field prompting. - F10 (Position Cursor Home): Clears
rowandcolto reposition the cursor. - F12 (Exit): Sets
fmtagnto*OFFto exit the loop. - Inquiry Mode: If
p$modeisINQ, callsf01nxtto determine the next format (which terminates the loop since*IN19is*OFF). - Enter Key:
- Calls
f01edtto validate input fields. - If no errors (
*IN50is*OFF) and inMNTmode, callsupddbfto update the database. - Calls
f01nxtto determine the next format (terminates the loop if*IN19is*OFF).
- F04 (Field Prompting): Calls
-
Determine Next Format (
f01nxtSubroutine): - If
*IN19is*OFF, setsfmtagnto*OFFto exit the main loop. -
(Note: Code for
FMT02is commented out, suggesting onlyFMT01is used.) -
Edit Format Input (
f01edtSubroutine): - Validate CSR Name: If
crcrnm(CSR name) is blank, sets errorERR0012, sets*IN50and*IN51to*ON, and callsaddmsg. - Validate Email Address: If
cremal(email address) is blank, sets errorERR0012, sets*IN50and*IN52to*ON, and callsaddmsg. -
Inquiry Mode: If
p$modeisINQ, clears error indicators (*IN50to*IN69) and clears messages usingclrmsg. -
Initialize Format Field Values (
f01movSubroutine): - Calls
f01edtto validate fields. -
If errors exist (
*IN50is*ON), clears error indicators and messages. -
Format Protection Schemes (
f01proSubroutine): - Clears protection indicators
*IN70to*IN74to0. - If
p$modeis notMNT(i.e.,INQ), sets*IN70to*IN73to1for global input protection. -
If in
MNTmode and the record exists (w$existsis*ON), sets*IN71to*ONto protect key fields (f$co,f$crid). -
Update Database (
upddbfSubroutine):- Saves the current
wkds01(external data structure forbbcsr) tosvds. - Chains to
bbcsrusingklcsr: - If the record exists (
*IN80is*OFF):- If
svdsdiffers fromwkds01(indicating changes), restoressvdstowkds01, updates thebbcsrpfrecord, and setsp$flagto1. - If no changes, forces end-of-data (
feod) onbbcsr.
- If
- If the record does not exist (
*IN80is*ON):- Clears
bbcsrpf, restoressvdstowkds01, setscrco(company),crcrid(CSR ID), andcrdeltoA(active), writes the new record, and setsp$flagto1.
- Clears
- Saves the current
-
Field Prompting (
promptSubroutine):- Calculates cursor position (
row,col) usingcsrloc. - Checks the current format (
rcdnam=FMT01) but has no specific logic implemented (likely a placeholder for field-specific prompting). - Sets
*IN19to*ONto indicate a panel format change.
- Calculates cursor position (
-
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
rcdnamandpagrrn. - Clears messages using
QMHRMVPM.
- Add Message (
-
Program Termination:
- Closes all files.
- Sets
*INLRto*ONand returns.
Business Rules¶
The BB929 program enforces the following business rules for managing CSR ID records:
- Operational Modes:
- Maintenance Mode (
MNT): Allows creation and updating of CSR records. Key fields (f$co,f$crid) are protected if the record already exists (w$existsis*ON). Input validation is performed, and the database is updated if no errors occur. -
Inquiry Mode (
INQ): Displays CSR records in read-only mode, with all input fields protected (*IN70to*IN73set to1). No database updates are performed. -
Input Validation:
- CSR Name (
crcrnm): Must not be blank; otherwise, errorERR0012is displayed, and*IN51is set. - Email Address (
cremal): Must not be blank; otherwise, errorERR0012is displayed, and*IN52is set. -
In inquiry mode, validation errors are cleared, and no updates are attempted.
-
Database Operations:
- Create Record: If the record does not exist (
*IN80is*ON), a new record is written tobbcsrwithcrdelset toA(active). - Update Record: If the record exists and changes are detected (
svdsdiffers fromwkds01), the record is updated. - No Changes: If no changes are detected, the file is set to end-of-data (
feod). -
Success Flag: Sets
p$flagto1on successful create or update. -
Field Protection:
- In maintenance mode, key fields (
f$co,f$crid) are protected for existing records to prevent modification. -
In inquiry mode, all input fields are protected to prevent any changes.
-
File Overrides:
-
The program uses the
p$fgrpparameter to determine the file library (ZorG) and applies overrides to accessgbbcsrorzbcsrforbbcsr, andgbicontorzbicontforbicont. -
User Interface:
- Displays a single format (
FMT01) for entering or viewing CSR data. - Supports function keys:
- F04: Initiates field prompting (logic not fully implemented).
- F10: Repositions the cursor to the home position.
- F12: Exits the program.
-
Provides message feedback for validation errors and successful operations.
-
Message Handling:
- Uses the
GSMSGFmessage file in*LIBLfor error messages (e.g.,ERR0012for blank fields). - Displays messages in a message subfile (
msgctl) and clears them as needed.
Tables (Files) Used¶
The program uses the following files:
1. bb929d:
- Type: Workstation file (display file).
- Usage: Contains the FMT01 format (and possibly FMT02, commented out) for user interaction, along with a message subfile (msgctl) and clear screen format (clrscr).
- Handler: PROFOUNDUI(HANDLER) for Profound UI integration.
2. bbcsr:
- Type: Physical file (update/add, keyed access).
- Usage: Stores CSR records, used for creating, updating, and retrieving records. Accessed using the key list klcsr (f$co, f$crid).
- Override: Redirected to gbbcsr or zbcsr based on p$fgrp.
3. bicont:
- Type: Physical file (input-only, keyed access).
- Usage: Used to validate the company number (f$co).
- Override: Redirected to gbicont or zbicont based on p$fgrp.
External Programs Called¶
The program calls the following external programs (all IBM i APIs):
1. QCMDEXC:
- Purpose: Executes file override commands to redirect bbcsr and bicont to the appropriate library.
- Parameters:
- dbov## (80 characters, override command).
- dbol## (15.5, command length).
2. QMHSNDPM:
- Purpose: Sends messages (e.g., error ERR0012) 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 BB929 RPGLE program, called by BB929P, is responsible for the maintenance and inquiry of individual CSR ID records in the Billing and Invoicing system. It operates in MNT or INQ mode, allowing users to create or update CSR records (with validation for non-blank name and email fields) or view them in read-only mode. The program uses a single display format (FMT01) with Profound UI integration, enforces field protection based on mode and record existence, and updates the bbcsr file accordingly. It validates the company number against bicont and uses file overrides to access the correct library (Z or G). The program relies on IBM i APIs (QCMDEXC, QMHSNDPM, QMHRMVPM) for file overrides and message handling, and interacts with three files: bb929d (display), bbcsr (CSR data), and bicont (company validation).