BB9295 RPGLE
The BB9295 RPGLE program is part of the Billing and Invoicing system and is designed to generate a printed listing of Customer Service Representative (CSR) IDs from the bbcsr file. It is called by the main program BB929P when the user presses F15 to produce a report. 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 (BB9295)¶
The program is a batch-style printing application that reads all records from the bbcsr file and outputs them to a printer file (qsysprt) in a formatted report. 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 one parameter:
p$fgrp(1 character): File group (ZorG) for database overrides.
- Field Initialization:
- Sets the report header
c$hdr1to "CSR Id Listing By Co#/Cust Service Rep Id" from thehdrarray. - Sets
prtovrto*ONto trigger printing the report header initially. - Calls
opntblto open the database file with the appropriate override.
- Sets the report header
-
Data Structures:
- Initializes time (
t#time,t#hms, etc.) and date (d#cymd,d#mdy, etc.) conversion data structures for formatting the report header. - Uses the program status data structure (
psds##) to retrieve environment details like job name (ps#jobn), user (ps#usr), and current date/time (ps#mdy,ps#hms). - Uses the printer file data structure (
prtf_opn) to access printer file details like file name (prtf_name) and spool file number (prtf_spl#).
- Initializes time (
-
Open Database Tables (
opntblSubroutine): - File Overrides: If
p$fgrpisGorZ, applies database overrides using theQCMDEXCAPI to redirect thebbcsrfile to eithergbbcsrorzbcsr.- Iterates twice to apply overrides from the
ovgorovzarrays (though only one override is needed forbbcsr). - Calls
QCMDEXCwith the override command (dbov##) and length (dbol## = 80).
- Iterates twice to apply overrides from the
-
File Opening: Opens the
bbcsrfile (input-only, keyed access). -
Print Listing (
prtlistSubroutine): - Open Printer File: Calls
openprtfto set up and open the printer file. - Read and Print Loop:
- Reads the
bbcsrfile sequentially until the last record (*INLRis*ON). - For each record:
- Calls
ovrfloto handle page overflow and print headers as needed. - Prints the detail line (
dtl01) containingcrco(company),crcrid(CSR ID),crcrnm(CSR name),cremal(email address), andcrdel(delete flag).
- Reads the
-
Close Printer File: Calls
closprtfto close the printer file and clean up overrides. -
Process Overflow (
ovrfloSubroutine): - Checks if the printer file has reached overflow (
*INOFis*ON).- If true, sets
prtovrto*ONand sets indicators*IN81to*IN85to1.
- If true, sets
-
If
prtovris*ON:- Prints the report header (
hdr01). - Sets
prtovrto*OFF.
- Prints the report header (
-
Open Printer File (
openprtfSubroutine): - Constructs a printer override command by concatenating
ovr(01)andovr(02)(specifying page size, lines per inch, characters per inch, overflow line, output queue, form type, hold, and save options). - Calls
QCMDEXCto execute the override command. -
Opens the
qsysprtprinter file. -
Close Printer File (
closprtfSubroutine): - Closes the
qsysprtprinter file. -
Executes a delete override command (
ovr(03) = DLTOVR FILE(QSYSPRT)) usingQCMDEXCto clean up the printer file override. -
Program Termination:
- The mainline logic does not explicitly close files or set
*INLR, as this is handled in theprtlistandclosprtfsubroutines. The program returns after completing the print job.
Business Rules¶
The BB9295 program enforces the following business rules for generating the CSR ID listing:
- Purpose:
-
Produces a printed report listing all CSR records from the
bbcsrfile, including company number (crco), CSR ID (crcrid), CSR name (crcrnm), email address (cremal), and delete flag (crdel). -
Report Format:
- Header:
- Includes the company name ("American Refining Group"), report title (
c$hdr1), page number, job details (name, program, user), file group (p$fgrp), date (t#mdcy), and time (t#hms). - Prints column headings: "Co", "CSR Id", "CSR Name", "Email Address", and "Del".
- Uses a fixed-width format (164 characters, as specified in the printer file definition).
- Includes the company name ("American Refining Group"), report title (
- Detail Lines:
- Each record is printed with fields aligned at specific positions:
crco(position 2),crcrid(position 8),crcrnm(position 44),cremal(position 95),crdel(position 100).
- Each record is printed with fields aligned at specific positions:
-
Page Layout:
- Page size is 68 lines by 164 characters, with 8 lines per inch (LPI), 15 characters per inch (CPI), and overflow at line 62.
- The report is held (
HOLD(*YES)) and saved (SAVE(*YES)) in the job’s output queue (OUTQ(*JOB)).
-
File Overrides:
- Uses
p$fgrpto redirectbbcsrtogbbcsr(forG) orzbcsr(forZ). -
Applies printer file overrides to configure
qsysprtwith specific formatting and output options. -
Data Inclusion:
-
Reads all records from
bbcsrsequentially, including active, inactive, or deleted records (no filtering based oncrdel). -
Output Handling:
- The report is sent to the system printer file (
qsysprt) and spooled for later retrieval. - Overflow is managed by printing headers when the page limit (line 62) is reached.
Tables (Files) Used¶
The program uses the following files:
1. bbcsr:
- Type: Physical file (input-only, keyed access).
- Usage: Source of CSR records for the report, containing fields crco (company), crcrid (CSR ID), crcrnm (CSR name), cremal (email address), and crdel (delete flag).
- Override: Redirected to gbbcsr or zbcsr based on p$fgrp.
2. qsysprt:
- Type: Printer file (output, 164 characters wide).
- Usage: Outputs the formatted report with headers (hdr01) and detail lines (dtl01).
- Override: Configured with OVRPRTF to set page size (68x164), LPI (8), CPI (15), overflow (line 62), and output queue options (hold and save).
External Programs Called¶
The program calls the following external program (an IBM i API):
1. QCMDEXC:
- Purpose: Executes file override commands for bbcsr (to gbbcsr or zbcsr) and printer file overrides for qsysprt (including OVRPRTF and DLTOVR).
- Parameters:
- dbov## (160 characters for printer overrides, 80 for database overrides, containing the override command).
- dbol## (15.5, command length, set to 160 for printer overrides, 80 for database overrides).
Summary¶
The BB9295 RPGLE program, called by BB929P when F15 is pressed, generates a printed report of all CSR ID records from the bbcsr file. It reads records sequentially, formats them into a 164-character-wide report with headers and detail lines, and outputs to the qsysprt printer file. The report includes company number, CSR ID, name, email, and status, with headers showing job details, date, time, and file group. The program uses file overrides to access the correct bbcsr library (Z or G) and configures the printer file with specific formatting options. It relies on the QCMDEXC API for overrides and manages page overflow to ensure proper pagination. The program interacts with two files: bbcsr (data source) and qsysprt (output).