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 (
*inzsrSubroutine): - Receives Input Parameters: The program accepts two parameters:
p$mode(run mode:MNTfor maintenance orINQfor inquiry) andp$fgrp(file group:ZorGfor database file overrides). - Sets Up Work Fields: Initializes subfile control fields (e.g.,
rrn1for relative record number,pagsz1for page size set to 14), message handling fields, and key lists (klsfl1,kls1s1) for database access. - Sets Current Date/Time: Uses the
TIMEoperation 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 (
opntblSubroutine): - Applies File Overrides: Based on the
p$fgrpparameter (ZorG), executesOVRDBFcommands to override the database files (bbcaid,bbcaidrd,bicont) to the appropriate library (e.g.,gbbcaidorzbbcaid). -
Opens Files: Opens the database files
bbcaid,bbcaidrd, andbicontfor processing. -
Main Subfile Processing (
srsfl1Subroutine): - Clears Message Subfile: Calls
clrmsgto clear any existing messages in the message subfile andwrtmsgto 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
sf1repto 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 (
*in50to*in69,*in21to*in39). - Handles Cursor Location: Calculates row and column (
row1,col1) fromcsrlocfor the next display. - Sets Subfile Record Number: Uses
pagrrnto setrcdnb1for proper page redisplay. - Processes User Input (Before Subfile Read):
- F03 (Exit): Sets
sf1agn = *offto exit the loop. - F04 (Field Prompting): Calls
promptto handle field prompting and iterates. - F05 (Refresh): Clears positioning fields (
r$co) and setsrepsfl = *onto reload the subfile. - F08 (Toggle Inactive Filter): Toggles
w$inactto include/exclude inactive records, updates the function key label (s1f08d), and setsrepsfl = *on. - F15 (Print Listing): Calls
BB9055to print a carrier ID listing, sends a confirmation message, and iterates. - Direct Access: If
d1opt,d1co, ord1caidis non-blank/zero, callssf1dirfor direct access processing. - Page Down: Calls
sf1lodto load more subfile records. - Processes Subfile on Enter: If the
ENTERkey is pressed, callssf1prcto process subfile records. - Processes User Input (After Subfile Read):
- User Positioning: If
c1coorc1caidis non-blank/zero, callssf1repto reposition the subfile. - F10 (Position to Control): Clears cursor coordinates (
row1,col1).
- Handles Repositioning: If
-
Process Subfile on Enter (
sf1prcSubroutine): -
Reads changed subfile records (
readc sfl1) and processes each record by callingsf1chg. -
Process Subfile Record Change (
sf1chgSubroutine): - 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 withsf1fmtandsf1col, and writes it back. -
Reposition Subfile (
sf1repSubroutine): - Clears the subfile (
sf1clr), validates control input (sf1cte), positions the file usingsetllonbbcaidrd, and loads the subfile (sf1lod). -
Retains control fields (
c1co,c1caid) in reposition fields (r$co,r$caid). -
Edit Subfile Control Input (
sf1cteSubroutine): -
Placeholder for input validation (currently empty).
-
Load Subfile Records (
sf1lodSubroutine): - 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
rcdnb1to ensure the correct page is displayed. -
Format Subfile Line (
sf1fmtSubroutine): -
Clears the subfile record and populates fields (
s1co,s1ffid,s1ein,s1caid,s1canm,s1del) from the database record. -
Subfile Color Coding (
sf1colSubroutine):- Sets
*in72to*on(blue color) for deleted or inactive records (s1del = 'D' or 'I').
- Sets
-
Direct Access Processing (
sf1dirSubroutine):- Validates direct input (
d1opt,d1co,d1caid): - For option 1 (create), ensures
d1coandd1caidare non-blank/zero and checks ifd1coexists inbicont. - Checks if the record exists in
bbcaidusingklsfl1. - 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, orsf1s05ifp$mode = 'MNT'(except for option 5). - Clears input fields on success.
- Validates direct input (
-
Subfile Option 01 - Create (
sf1s01Subroutine):- Calls
BB905with 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 = *onto reload the subfile.
- Calls
-
Subfile Option 02 - Change (
sf1s02Subroutine):- Validates that the record is not deleted/inactive.
- Calls
BB905with parameters for changing the carrier ID. - Sends a confirmation message if successful (
o$flag = '1').
-
Subfile Option 04 - Inactivate/Reactivate (
sf1s04Subroutine):- Calls
BB9054to inactivate or reactivate the carrier ID. - Sends appropriate confirmation messages based on the return flag (
Ifor inactivated,Afor reactivated,Efor vendor-linked error).
- Calls
-
Subfile Option 05 - Display (
sf1s05Subroutine):- Calls
BB905in inquiry mode (INQ) to display the carrier ID details.
- Calls
-
Field Prompting (
promptSubroutine):- Sets
*in19to 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 = *onto 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 (
ZandG), 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.,
*in70for 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!