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 (
*inzsr
Subroutine): - Parameter Reception: The program receives two input parameters:
p$mode
(3 characters): Specifies the run mode (MNT
for maintenance orINQ
for inquiry).p$fgrp
(1 character): Specifies the file group (Z
orG
) for database overrides.
- Genie Check: The program checks if it is being called from the Genie environment by calling
GSGENIE2C
. Ifgenievar
is notYES
, the program closes all files and terminates. - Field Initialization: Initializes various fields, including:
- Subfile control fields (e.g.,
rrn1
,rrnsv1
,pagsz1
set 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 thehdr
array. -
Open Database Tables (
opntbl
Subroutine): - File Overrides: Based on the
p$fgrp
parameter (Z
orG
), applies database overrides using theQCMDEXC
API 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 (
srsfl1
Subroutine): - Clear Message Subfile: Calls
clrmsg
to clear any existing messages andwrtmsg
to display the message subfile. - Subfile Mode Initialization:
- Sets
sfmod1
to'1'
and#fold
to'0'
to control folded/unfolded display mode. - Initializes subfile control fields (
c1co
,c1crid
) to zeros or blanks. - Sets
w$inact
to*ON
(display all records, including inactive ones, per revisionjb01
).
- Sets
- Global Protection: Sets indicator
*IN70
based onp$mode
:*OFF
for maintenance mode (MNT
).*ON
for inquiry mode (INQ
), protecting input fields.
- Subfile Repositioning: Calls
sf1rep
to position the file and load the subfile initially. -
Main Loop (
sf1agn
):- Reposition Subfile: If
repsfl
is*ON
, updates control fields (c1co
,c1crid
) and callssf1rep
to reposition the subfile. - Display Command Line: Writes the
sflcmd1
format (command line). - Display Message Subfile: If
dspmsg
is*ON
, callswrtmsg
; otherwise, writesmsgclr
to clear messages. - Subfile Display Check: Sets
*IN41
(SFLDSP) based on whetherrrn1
(relative record number) is greater than zero. - Folded/Unfolded Mode: Sets
*IN45
based onsfmod1
and#fold
to control subfile display mode. - Display Subfile Control: Sets
*IN40
(SFLDSPCTL) to*ON
and executesexfmt sflctl1
to display the subfile control format and accept user input. - Clear Messages: If
dspmsg
is*ON
, callsclrmsg
to clear the message subfile. - Clear Indicators: Resets screen error indicators (
*IN21
to*IN39
,*IN50
to*IN69
) to zero. - Cursor Positioning: Calculates row (
row1
) and column (col1
) for the cursor usingcsrloc
. - Set Record Number: Sets
rcdnb1
topagrrn
to ensure the correct subfile page is displayed. - Process User Input (Before Subfile Read):
- F03 (Exit): Sets
sf1agn
to*OFF
to exit the loop. - F04 (Field Prompting): Calls
prompt
to handle field prompting and iterates. - F05 (Refresh): Clears
r$co
, setsrepsfl
to*ON
, and iterates to refresh the subfile. - F08 (Toggle Inactive Filter): Toggles
w$inact
between*ON
and*OFF
to include/exclude inactive records, setsrepsfl
to*ON
, and iterates. (Note: F8 functionality is commented out for Profound UI, defaulting to include all records.) - F15 (Print Listing): Calls
BB9295
with parameters to print a CSR ID listing, sends a confirmation message, and iterates. - Direct Access: If
d1opt
,d1co
, ord1crid
is non-blank/zero, callssf1dir
to process direct access options. - Page Down: If the
PAGEDN
key is pressed, callssf1lod
to load the next page of subfile records. - Process Subfile on Enter: If the
ENTER
key is pressed, callssf1prc
to process subfile changes. - Process User Input (After Subfile Read):
- Position Request: If
c1co
orc1crid
is non-blank/zero, callssf1rep
to reposition the subfile. - F10 (Position Cursor): Clears
row1
andcol1
to reposition the cursor to the control record. - The loop continues until
sf1agn
is*OFF
.
- Reposition Subfile: If
-
Process Subfile on Enter (
sf1prc
Subroutine): - Reads changed subfile records using
readc sfl1
(indicator*IN81
). -
For each changed record, calls
sf1chg
to process the selected option. -
Process Subfile Record Change (
sf1chg
Subroutine): - Retains selected values (
s1co
,s1crid
) ins$co
ands$crid
. - Processes based on the subfile option (
s1opt
):- Option 2 (Change): If in
MNT
mode and the record is not deleted (s1del
is notD
orI
), callssf1s02
. - Option 4 (Inactivate/Reactivate): If in
MNT
mode, callssf1s04
. - Option 5 (Display): Calls
sf1s05
.
- Option 2 (Change): If in
-
Updates the subfile record by chaining to
bbcsr
andsfl1
, clearings1opt
, formatting the record (sf1fmt
), applying color coding (sf1col
), and updating the subfile. -
Reposition Subfile (
sf1rep
Subroutine): - Clears the subfile (
sf1clr
) and resetsrrn1
. - Edits subfile control input (
sf1cte
). - If no errors (
*IN50
is*OFF
), positions the file usingsetll
onbbcsrrd
and loads the subfile (sf1lod
). -
Retains control fields (
c1co
,c1crid
) inr$co
andr$crid
for repositioning. -
Edit Subfile Control Input (
sf1cte
Subroutine): -
Currently empty, likely intended for input validation (not implemented in the provided code).
-
Load Subfile Records (
sf1lod
Subroutine): - Sets
rrn1
to the last saved relative record number (rrnsv1
). - Sets
rcdnb1
torrn1 + 1
to ensure the new page is displayed. - Loads up to
pagsz1
(14) records:- Reads the next record from
bbcsrrd
(indicator*IN43
for end-of-file). - Skips deleted or inactive records (
crdel
=D
orI
) ifw$inact
is*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
rrn1
inrrnsv1
. -
Format Subfile Detail Line (
sf1fmt
Subroutine): - 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 (
sf1col
Subroutine):- Sets
*IN72
to*ON
(blue color) if the record is deleted or inactive (s1del
=D
orI
).
- Sets
-
Direct Access Processing (
sf1dir
Subroutine):- Retains direct input values (
d1co
,d1crid
) ins$co
ands$crid
. - Validates input:
- For option 1 (Create), ensures
d1co
andd1crid
are not blank/zero; otherwise, sets errorERR0103
. - For option 1, checks if
d1co
exists inbicont
; if not, sets errorERR0021
. - Checks if the record exists in
bbcsr
usingsetll
:- 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 (
*IN50
is*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 (
sf1s01
Subroutine):- Calls
BB929
with parameters: s$co
,s$crid
(key fields).o$mode
set toMNT
.p$fgrp
(file group).o$flag
(return flag).- If
o$flag
is1
, sends a confirmation message (Code <crid> has been created
), setsc1co
andc1crid
, and setsrepsfl
to*ON
to reposition the subfile.
- Calls
-
Subfile Option 02 - Change (
sf1s02
Subroutine):- Chains to
bbcsr
to check if the record is deleted or inactive (crdel
=D
orI
). If so, sends error messageCannot Modify An Inactive Record
. - If valid, calls
BB929
with parameters similar tosf1s01
. - If
o$flag
is1
, sends a confirmation message (Code <crid> has been changed
).
- Chains to
-
Subfile Option 04 - Inactivate/Reactivate (
sf1s04
Subroutine):- Calls
BB9294
with 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$co
ina$co
.
- Calls
-
Subfile Option 05 - Display Customer Order (
sf1s05
Subroutine):- Calls
BB929
with parameters, settingo$mode
toINQ
for inquiry mode.
- Calls
-
Field Prompting (
prompt
Subroutine):- Sets
*IN19
to*ON
to indicate panel format input change. - (Note: Cursor positioning code is commented out.)
- Sets
-
Message Handling (
addmsg
,wrtmsg
,clrmsg
Subroutines):- Add Message (
addmsg
): - Sets
dspmsg
to*ON
. - Calculates the length of
m@data
and sends a message to the program message queue usingQMHSNDPM
. - Clears message data fields.
- Write Message Subfile (
wrtmsg
): - Sets
*IN49
to*ON
and writes themsgctl
format to display messages. - Clear Message Subfile (
clrmsg
): - Sets
dspmsg
to*OFF
. - Saves and restores the current record format (
rcdnam
) andpagrrn
. - Clears messages using
QMHRMVPM
.
- Add Message (
-
Program Termination:
- Closes all files.
- Sets
*INLR
to*ON
and 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
).