BB905P RPGLE
The provided document is an RPGLE program named BB905P
, designed to manage billing carrier codes within a billing and invoicing system. Below, I’ll explain the process steps of the program, list the external programs called, and identify the database tables used.
Process Steps of the RPGLE Program (BB905P
)¶
The program is structured to handle a subfile (SFL) interface for displaying and managing carrier ID entries. It supports operations such as creating, changing, inactivating/reactivating, and displaying carrier records, with functionality for both maintenance (MNT
) and inquiry (INQ
) modes. Here’s a step-by-step breakdown of the program’s logic:
- Program Initialization (
*inzsr
Subroutine): - Receives Input Parameters: The program accepts two parameters:
p$mode
(run mode:MNT
for maintenance orINQ
for inquiry) andp$fgrp
(file group:Z
orG
for database file overrides). - Sets Up Work Fields: Initializes subfile control fields (e.g.,
rrn1
for relative record number,pagsz1
for page size set to 14), message handling fields, and key lists (klsfl1
,kls1s1
) for database access. - Sets Current Date/Time: Uses the
TIME
operation to capture the current timestamp and formats it into a data structure (t#time
) for date and time manipulation. -
Initializes Headers and Flags: Sets the display header (
c$hdr1
) and initializes flags likesf1agn
(to control subfile processing) anddspmsg
(for message subfile handling). -
Open Database Tables (
opntbl
Subroutine): - Applies File Overrides: Based on the
p$fgrp
parameter (Z
orG
), executesOVRDBF
commands to override the database files (bbcaid
,bbcaidrd
,bicont
) to the appropriate library (e.g.,gbbcaid
orzbbcaid
). -
Opens Files: Opens the database files
bbcaid
,bbcaidrd
, andbicont
for processing. -
Main Subfile Processing (
srsfl1
Subroutine): - Clears Message Subfile: Calls
clrmsg
to clear any existing messages in the message subfile andwrtmsg
to display it. - Initializes Subfile: Sets the subfile mode to folded (
sfmod1 = '1'
,*in45 = *on
) and clears subfile control fields (c1co
,c1caid
). - Sets Protection Mode: If
p$mode = 'MNT'
, input fields are unprotected (*in70 = *off
); otherwise, in inquiry mode, fields are protected (*in70 = *on
). - Positions File: Calls
sf1rep
to position the file pointer for reading records. -
Main Loop:
- Handles Repositioning: If
repsfl = *on
, repositions the subfile based on user input (c1co
,c1caid
) by callingsf1rep
. - Displays Command Line and Messages: Writes the command line (
sflcmd1
) and message subfile ifdspmsg = *on
. - Controls Subfile Display: Sets
*in41
(subfile display) based on whether records exist (rrn1 > 0
) and manages folded/unfolded mode with*in45
. - Displays Subfile Control: Writes and formats the subfile control record (
sflctl1
) usingEXFMT
. - Clears Messages and Indicators: Clears message subfile if needed and resets error indicators (
*in50
to*in69
,*in21
to*in39
). - Handles Cursor Location: Calculates row and column (
row1
,col1
) fromcsrloc
for the next display. - Sets Subfile Record Number: Uses
pagrrn
to setrcdnb1
for proper page redisplay. - Processes User Input (Before Subfile Read):
- F03 (Exit): Sets
sf1agn = *off
to exit the loop. - F04 (Field Prompting): Calls
prompt
to handle field prompting and iterates. - F05 (Refresh): Clears positioning fields (
r$co
) and setsrepsfl = *on
to reload the subfile. - F08 (Toggle Inactive Filter): Toggles
w$inact
to include/exclude inactive records, updates the function key label (s1f08d
), and setsrepsfl = *on
. - F15 (Print Listing): Calls
BB9055
to print a carrier ID listing, sends a confirmation message, and iterates. - Direct Access: If
d1opt
,d1co
, ord1caid
is non-blank/zero, callssf1dir
for direct access processing. - Page Down: Calls
sf1lod
to load more subfile records. - Processes Subfile on Enter: If the
ENTER
key is pressed, callssf1prc
to process subfile records. - Processes User Input (After Subfile Read):
- User Positioning: If
c1co
orc1caid
is non-blank/zero, callssf1rep
to reposition the subfile. - F10 (Position to Control): Clears cursor coordinates (
row1
,col1
).
- Handles Repositioning: If
-
Process Subfile on Enter (
sf1prc
Subroutine): -
Reads changed subfile records (
readc sfl1
) and processes each record by callingsf1chg
. -
Process Subfile Record Change (
sf1chg
Subroutine): - Stores Selected Values: Saves subfile fields (
s1co
,s1caid
) to work fields (s$co
,s$caid
). - Handles Options:
- Option 2 (Change): If
p$mode = 'MNT'
and the record is not deleted/inactive (s1del ≠ 'D' or 'I'
), callssf1s02
. - Option 4 (Inactivate/Reactivate): If
p$mode = 'MNT'
, callssf1s04
. - Option 5 (Display): Calls
sf1s05
.
- Option 2 (Change): If
-
Updates Subfile: Chains to the database file (
bbcaid
) using key listklsfl1
, updates the subfile record withsf1fmt
andsf1col
, and writes it back. -
Reposition Subfile (
sf1rep
Subroutine): - Clears the subfile (
sf1clr
), validates control input (sf1cte
), positions the file usingsetll
onbbcaidrd
, and loads the subfile (sf1lod
). -
Retains control fields (
c1co
,c1caid
) in reposition fields (r$co
,r$caid
). -
Edit Subfile Control Input (
sf1cte
Subroutine): -
Placeholder for input validation (currently empty).
-
Load Subfile Records (
sf1lod
Subroutine): - Sets the relative record number (
rrn1
) to the last saved value (rrnsv1
). - Loads up to
pagsz1
(14) records into the subfile:- Reads the next record from
bbcaidrd
. - Skips deleted/inactive records if
w$inact = *off
. - Formats the subfile line (
sf1fmt
) and applies color coding (sf1col
). - Writes the record to the subfile and increments
rrn1
.
- Reads the next record from
-
Updates
rcdnb1
to ensure the correct page is displayed. -
Format Subfile Line (
sf1fmt
Subroutine): -
Clears the subfile record and populates fields (
s1co
,s1ffid
,s1ein
,s1caid
,s1canm
,s1del
) from the database record. -
Subfile Color Coding (
sf1col
Subroutine):- Sets
*in72
to*on
(blue color) for deleted or inactive records (s1del = 'D' or 'I'
).
- Sets
-
Direct Access Processing (
sf1dir
Subroutine):- Validates direct input (
d1opt
,d1co
,d1caid
): - For option 1 (create), ensures
d1co
andd1caid
are non-blank/zero and checks ifd1co
exists inbicont
. - Checks if the record exists in
bbcaid
usingklsfl1
. - Displays errors for invalid company numbers, non-existent records (for non-create options), or existing records (for create).
- Processes valid options (1, 2, 4, 5) by calling
sf1s01
,sf1s02
,sf1s04
, orsf1s05
ifp$mode = 'MNT'
(except for option 5). - Clears input fields on success.
- Validates direct input (
-
Subfile Option 01 - Create (
sf1s01
Subroutine):- Calls
BB905
with parameters for creating a new carrier ID, passings$co
,s$caid
,MNT
,p$fgrp
, and a return flag. - If successful (
o$flag = '1'
), sends a confirmation message, updates control fields, and setsrepsfl = *on
to reload the subfile.
- Calls
-
Subfile Option 02 - Change (
sf1s02
Subroutine):- Validates that the record is not deleted/inactive.
- Calls
BB905
with parameters for changing the carrier ID. - Sends a confirmation message if successful (
o$flag = '1'
).
-
Subfile Option 04 - Inactivate/Reactivate (
sf1s04
Subroutine):- Calls
BB9054
to inactivate or reactivate the carrier ID. - Sends appropriate confirmation messages based on the return flag (
I
for inactivated,A
for reactivated,E
for vendor-linked error).
- Calls
-
Subfile Option 05 - Display (
sf1s05
Subroutine):- Calls
BB905
in inquiry mode (INQ
) to display the carrier ID details.
- Calls
-
Field Prompting (
prompt
Subroutine):- Sets
*in19
to indicate input change and prepares for cursor repositioning.
- Sets
-
Message Handling:
- Add Message (
addmsg
): Sends messages to the program message queue usingQMHSNDPM
, settingdspmsg = *on
. - Write Message Subfile (
wrtmsg
): Displays the message subfile (msgctl
) with*in49
. - Clear Message Subfile (
clrmsg
): Clears messages usingQMHRMVPM
, preserving the current record format and page number.
- Add Message (
-
Program Termination:
- Closes all files and sets
*inlr = *on
to end the program.
- Closes all files and sets
External Programs Called¶
The program calls the following external programs:
1. BB905:
- Used for creating (option 1), changing (option 2), and displaying (option 5) carrier ID records.
- Parameters: o$co
(company), o$caid
(carrier ID), o$mode
(MNT
or INQ
), o$fgrp
(file group), o$flag
(return flag).
2. BB9054:
- Used for inactivating or reactivating carrier IDs (option 4).
- Parameters: o$co
, o$caid
, o$fgrp
, o$flag
.
3. BB9055:
- Used for printing a carrier ID listing (F15).
- Parameters: o$fgrp
(file group).
4. QCMDEXC:
- Used to execute file override commands (OVRDBF
) in the opntbl
subroutine.
- Parameters: dbov##
(override command string), dbol##
(length of command).
5. QMHSNDPM:
- Used to send messages to the program message queue in the addmsg
subroutine.
- Parameters: m@id
, m@msgf
, m@data
, m@l
, m@type
, m@pgmq
, m@scnt
, m@key
, m@errc
.
6. QMHRMVPM:
- Used to clear messages from the message subfile in the clrmsg
subroutine.
- Parameters: m@pgmq
, m@scnt
, m@rmvk
, m@rmv
, m@errc
.
Database Tables Used¶
The program interacts with the following database files:
1. bbcaid:
- Input-only file, used for chaining and reading carrier ID records.
- Key fields: Likely cico
(company) and cicaid
(carrier ID), based on klsfl1
.
2. bbcaidrd:
- Input-only file with a renamed record format (bbcaidpf
to bbcaidpr
), used for positioning and reading records.
- Key fields: c1co
(company) and c1caid
(carrier ID), based on kls1s1
.
3. bicont:
- Input-only file, used to validate company numbers (d1co
) during direct access processing.
- Key field: Likely cico
(company).
Additional Notes¶
- File Overrides: The program supports two file groups (
Z
andG
), which determine the library for the database files (gbbcaid
,zbbcaid
, etc.). - Subfile Options:
- 1: Create a new carrier ID.
- 2: Change an existing carrier ID.
- 4: Inactivate or reactivate a carrier ID.
- 5: Display carrier ID details.
- Function Keys:
- F03: Exit.
- F04: Field prompting.
- F05: Refresh subfile.
- F08: Toggle include/exclude inactive records.
- F10: Position cursor to control record.
- F15: Print carrier ID listing.
- Indicators: Used extensively to control subfile display, errors, and input protection (e.g.,
*in70
for global protection in inquiry mode). - Error Handling: Displays messages for invalid inputs, non-existent records, or attempts to create duplicate records.
This program is a typical IBM i RPGLE application for managing a subfile-based user interface, with robust error handling and database interaction. Let me know if you need further clarification or specific details!