Skip to content

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:

  1. Program Initialization (*inzsr Subroutine):
  2. Parameter Reception: The program receives one parameter:
    • p$fgrp (1 character): File group (Z or G) for database overrides.
  3. Field Initialization:
    • Sets the report header c$hdr1 to "CSR Id Listing By Co#/Cust Service Rep Id" from the hdr array.
    • Sets prtovr to *ON to trigger printing the report header initially.
    • Calls opntbl to open the database file with the appropriate override.
  4. 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#).
  5. Open Database Tables (opntbl Subroutine):

  6. File Overrides: If p$fgrp is G or Z, applies database overrides using the QCMDEXC API to redirect the bbcsr file to either gbbcsr or zbcsr.
    • Iterates twice to apply overrides from the ovg or ovz arrays (though only one override is needed for bbcsr).
    • Calls QCMDEXC with the override command (dbov##) and length (dbol## = 80).
  7. File Opening: Opens the bbcsr file (input-only, keyed access).

  8. Print Listing (prtlist Subroutine):

  9. Open Printer File: Calls openprtf to set up and open the printer file.
  10. Read and Print Loop:
    • Reads the bbcsr file sequentially until the last record (*INLR is *ON).
    • For each record:
    • Calls ovrflo to handle page overflow and print headers as needed.
    • Prints the detail line (dtl01) containing crco (company), crcrid (CSR ID), crcrnm (CSR name), cremal (email address), and crdel (delete flag).
  11. Close Printer File: Calls closprtf to close the printer file and clean up overrides.

  12. Process Overflow (ovrflo Subroutine):

  13. Checks if the printer file has reached overflow (*INOF is *ON).
    • If true, sets prtovr to *ON and sets indicators *IN81 to *IN85 to 1.
  14. If prtovr is *ON:

    • Prints the report header (hdr01).
    • Sets prtovr to *OFF.
  15. Open Printer File (openprtf Subroutine):

  16. Constructs a printer override command by concatenating ovr(01) and ovr(02) (specifying page size, lines per inch, characters per inch, overflow line, output queue, form type, hold, and save options).
  17. Calls QCMDEXC to execute the override command.
  18. Opens the qsysprt printer file.

  19. Close Printer File (closprtf Subroutine):

  20. Closes the qsysprt printer file.
  21. Executes a delete override command (ovr(03) = DLTOVR FILE(QSYSPRT)) using QCMDEXC to clean up the printer file override.

  22. Program Termination:

  23. The mainline logic does not explicitly close files or set *INLR, as this is handled in the prtlist and closprtf subroutines. The program returns after completing the print job.

Business Rules

The BB9295 program enforces the following business rules for generating the CSR ID listing:

  1. Purpose:
  2. Produces a printed report listing all CSR records from the bbcsr file, including company number (crco), CSR ID (crcrid), CSR name (crcrnm), email address (cremal), and delete flag (crdel).

  3. Report Format:

  4. 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).
  5. 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).
  6. 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)).
  7. File Overrides:

  8. Uses p$fgrp to redirect bbcsr to gbbcsr (for G) or zbcsr (for Z).
  9. Applies printer file overrides to configure qsysprt with specific formatting and output options.

  10. Data Inclusion:

  11. Reads all records from bbcsr sequentially, including active, inactive, or deleted records (no filtering based on crdel).

  12. Output Handling:

  13. The report is sent to the system printer file (qsysprt) and spooled for later retrieval.
  14. 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).