Skip to content

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:

  1. Program Initialization (*inzsr Subroutine):
  2. Receives Input Parameters: The program accepts two parameters: p$mode (run mode: MNT for maintenance or INQ for inquiry) and p$fgrp (file group: Z or G for database file overrides).
  3. 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.
  4. 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.
  5. Initializes Headers and Flags: Sets the display header (c$hdr1) and initializes flags like sf1agn (to control subfile processing) and dspmsg (for message subfile handling).

  6. Open Database Tables (opntbl Subroutine):

  7. Applies File Overrides: Based on the p$fgrp parameter (Z or G), executes OVRDBF commands to override the database files (bbcaid, bbcaidrd, bicont) to the appropriate library (e.g., gbbcaid or zbbcaid).
  8. Opens Files: Opens the database files bbcaid, bbcaidrd, and bicont for processing.

  9. Main Subfile Processing (srsfl1 Subroutine):

  10. Clears Message Subfile: Calls clrmsg to clear any existing messages in the message subfile and wrtmsg to display it.
  11. Initializes Subfile: Sets the subfile mode to folded (sfmod1 = '1', *in45 = *on) and clears subfile control fields (c1co, c1caid).
  12. Sets Protection Mode: If p$mode = 'MNT', input fields are unprotected (*in70 = *off); otherwise, in inquiry mode, fields are protected (*in70 = *on).
  13. Positions File: Calls sf1rep to position the file pointer for reading records.
  14. Main Loop:

    • Handles Repositioning: If repsfl = *on, repositions the subfile based on user input (c1co, c1caid) by calling sf1rep.
    • Displays Command Line and Messages: Writes the command line (sflcmd1) and message subfile if dspmsg = *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) using EXFMT.
    • 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) from csrloc for the next display.
    • Sets Subfile Record Number: Uses pagrrn to set rcdnb1 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 sets repsfl = *on to reload the subfile.
    • F08 (Toggle Inactive Filter): Toggles w$inact to include/exclude inactive records, updates the function key label (s1f08d), and sets repsfl = *on.
    • F15 (Print Listing): Calls BB9055 to print a carrier ID listing, sends a confirmation message, and iterates.
    • Direct Access: If d1opt, d1co, or d1caid is non-blank/zero, calls sf1dir for direct access processing.
    • Page Down: Calls sf1lod to load more subfile records.
    • Processes Subfile on Enter: If the ENTER key is pressed, calls sf1prc to process subfile records.
    • Processes User Input (After Subfile Read):
    • User Positioning: If c1co or c1caid is non-blank/zero, calls sf1rep to reposition the subfile.
    • F10 (Position to Control): Clears cursor coordinates (row1, col1).
  15. Process Subfile on Enter (sf1prc Subroutine):

  16. Reads changed subfile records (readc sfl1) and processes each record by calling sf1chg.

  17. Process Subfile Record Change (sf1chg Subroutine):

  18. Stores Selected Values: Saves subfile fields (s1co, s1caid) to work fields (s$co, s$caid).
  19. Handles Options:
    • Option 2 (Change): If p$mode = 'MNT' and the record is not deleted/inactive (s1del ≠ 'D' or 'I'), calls sf1s02.
    • Option 4 (Inactivate/Reactivate): If p$mode = 'MNT', calls sf1s04.
    • Option 5 (Display): Calls sf1s05.
  20. Updates Subfile: Chains to the database file (bbcaid) using key list klsfl1, updates the subfile record with sf1fmt and sf1col, and writes it back.

  21. Reposition Subfile (sf1rep Subroutine):

  22. Clears the subfile (sf1clr), validates control input (sf1cte), positions the file using setll on bbcaidrd, and loads the subfile (sf1lod).
  23. Retains control fields (c1co, c1caid) in reposition fields (r$co, r$caid).

  24. Edit Subfile Control Input (sf1cte Subroutine):

  25. Placeholder for input validation (currently empty).

  26. Load Subfile Records (sf1lod Subroutine):

  27. Sets the relative record number (rrn1) to the last saved value (rrnsv1).
  28. 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.
  29. Updates rcdnb1 to ensure the correct page is displayed.

  30. Format Subfile Line (sf1fmt Subroutine):

  31. Clears the subfile record and populates fields (s1co, s1ffid, s1ein, s1caid, s1canm, s1del) from the database record.

  32. Subfile Color Coding (sf1col Subroutine):

    • Sets *in72 to *on (blue color) for deleted or inactive records (s1del = 'D' or 'I').
  33. Direct Access Processing (sf1dir Subroutine):

    • Validates direct input (d1opt, d1co, d1caid):
    • For option 1 (create), ensures d1co and d1caid are non-blank/zero and checks if d1co exists in bicont.
    • Checks if the record exists in bbcaid using klsfl1.
    • 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, or sf1s05 if p$mode = 'MNT' (except for option 5).
    • Clears input fields on success.
  34. Subfile Option 01 - Create (sf1s01 Subroutine):

    • Calls BB905 with parameters for creating a new carrier ID, passing s$co, s$caid, MNT, p$fgrp, and a return flag.
    • If successful (o$flag = '1'), sends a confirmation message, updates control fields, and sets repsfl = *on to reload the subfile.
  35. 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').
  36. 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).
  37. Subfile Option 05 - Display (sf1s05 Subroutine):

    • Calls BB905 in inquiry mode (INQ) to display the carrier ID details.
  38. Field Prompting (prompt Subroutine):

    • Sets *in19 to indicate input change and prepares for cursor repositioning.
  39. Message Handling:

    • Add Message (addmsg): Sends messages to the program message queue using QMHSNDPM, setting dspmsg = *on.
    • Write Message Subfile (wrtmsg): Displays the message subfile (msgctl) with *in49.
    • Clear Message Subfile (clrmsg): Clears messages using QMHRMVPM, preserving the current record format and page number.
  40. Program Termination:

    • Closes all files and sets *inlr = *on to end the program.

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 and G), 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!