Skip to content

BB9294 RPGLE

The BB9294 RPGLE program is part of the Billing and Invoicing system and is designed to handle the Inactivation and Reactivation of Customer Service Representative (CSR) IDs. It is called by the main program BB929P to toggle the status of a CSR record between active (A) and inactive (I). 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 (BB9294)

The program is an interactive workstation-based application that uses a display file (bb9294d) to present a window format (actwdw) for confirming the inactivation or reactivation of a CSR record. It updates the crdel field in the bbcsr file to reflect the status change. 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 four parameters:
    • p$co: Company number (input).
    • p$crid: CSR ID (input).
    • p$fgrp (1 character): File group (Z or G) for database overrides.
    • p$flag (1 character): Return flag (output, set to A for reactivation or I for inactivation).
  3. Field Initialization:
    • Moves input parameters p$co and p$crid to display file fields f$co and f$crid.
    • Defines key list klcsr for accessing the bbcsr file using f$co and f$crid.
    • Sets winagn to *ON to control the window processing loop.
    • Initializes message handling fields (dspmsg to blank, m@pgmq to *, m@key to blanks).
    • Defines a parameter list (pld010) for date validation (not used in the provided code).
  4. Commented Test Code: Includes commented-out code for testing with hardcoded values (e.g., p$co = '10', p$crid = 'JGK').

  5. Open Database Tables (opntbl Subroutine):

  6. File Overrides: Based on p$fgrp (Z or G), applies a database override using the QCMDEXC API to redirect access to the bbcsr file to either gbbcsr or zbcsr.
  7. File Opening: Opens the bbcsr file (update/add, keyed access).

  8. Retrieve Data (rtvdta Subroutine):

  9. Chains to bbcsr using klcsr (f$co, f$crid) to retrieve the CSR record.
  10. If the record exists (*IN99 is *OFF):

    • If crdel is I (inactive):
    • Sets the header f$hdr to "CSR Id Entry ReActivate" (hdr(01)).
    • Sets the function key label f$fkyd to "F22=ReActivate" (fky(01)).
    • Sets *IN72 to *ON (likely for display formatting, e.g., color).
    • If crdel is not I (active or other status):
    • Sets f$hdr to "CSR Id Entry InActivate" (hdr(02)).
    • Sets f$fkyd to "F23=InActivate" (fky(02)).
    • Sets *IN73 to *ON.
  11. Process Window (prcwdw Subroutine):

  12. Main Loop (winagn):

    • Display Messages: If dspmsg is *ON, calls wrtmsg to display the message subfile; otherwise, writes msgclr to clear messages.
    • Display Window: Executes exfmt actwdw to display the window format and accept user input.
    • Clear Messages: If dspmsg is *ON, calls clrmsg to clear the message subfile.
    • Clear Error Indicators: Resets indicators *IN50 to *IN69 to zero.
    • Cursor Positioning: Contains commented-out code for calculating cursor position (row, col) using csrloc.
    • Process User Input:
    • F12 (Exit): Sets winagn to *OFF to exit the loop.
    • F22 or F23 (ReActivate/InActivate):
      • Calls winedt to validate input (which calls chkact).
      • If no errors (*IN50 is *OFF), calls winupd to update the database and sets winagn to *OFF to exit.
    • Other (e.g., Enter): Calls winedt to validate input (no further action unless F22/F23 is pressed).
    • The loop continues until winagn is *OFF.
  13. Edit Window Input (winedt Subroutine):

  14. Calls chkact to check activity prior to status change (no logic implemented in chkact).

  15. Check Activity (chkact Subroutine):

  16. Currently empty, likely intended as a placeholder for checking if the CSR ID is used in other tables (e.g., vendor table, as indicated by the E flag in BB929P).

  17. Update Database (winupd Subroutine):

  18. ReActivate (F22):
    • Chains to bbcsr using klcsr.
    • If the record exists (*IN99 is *OFF) and crdel is I (inactive):
    • Sets crdel to A (active).
    • Updates the bbcsrpf record.
    • Sets p$flag to A to indicate successful reactivation.
  19. InActivate (F23):

    • Chains to bbcsr using klcsr.
    • If the record exists (*IN99 is *OFF) and crdel is not I (e.g., active):
    • Sets crdel to I (inactive).
    • Updates the bbcsrpf record.
    • Sets p$flag to I to indicate successful inactivation.
  20. Message Handling (addmsg, wrtmsg, clrmsg Subroutines):

  21. Add Message (addmsg):
    • Sets dspmsg to *ON.
    • Calculates the length of m@data and sends a message to the program message queue using QMHSNDPM.
    • Clears message data fields.
  22. Write Message Subfile (wrtmsg):
    • Sets *IN49 to *ON and writes the msgctl format to display messages.
  23. Clear Message Subfile (clrmsg):

    • Sets dspmsg to *OFF.
    • Calls QMHRMVPM to clear messages (note: saving/restoring rcdnam and pagrrn is commented out, suggesting a simplified message clearing process).
  24. Program Termination:

  25. Closes all files.
  26. Sets *INLR to *ON and returns.

Business Rules

The BB9294 program enforces the following business rules for inactivating or reactivating CSR IDs:

  1. Purpose:
  2. The program toggles the status of a CSR record in the bbcsr file by updating the crdel field between A (active) and I (inactive).

  3. Input Parameters:

  4. Requires p$co (company number) and p$crid (CSR ID) to identify the record.
  5. Uses p$fgrp to determine the file library (Z or G).
  6. Returns p$flag as A (reactivated), I (inactivated), or unchanged if no action is taken.

  7. Status Toggle:

  8. ReActivate (F22): Only allowed if the record exists and crdel is I. Sets crdel to A and updates the record.
  9. InActivate (F23): Only allowed if the record exists and crdel is not I. Sets crdel to I and updates the record.
  10. If the record does not exist (*IN99 is *ON), no update is performed, and p$flag remains unchanged.

  11. Activity Check:

  12. The chkact subroutine is a placeholder, suggesting a business rule to check for dependencies (e.g., CSR ID used in a vendor table, as indicated by the E flag in BB929P). However, no logic is implemented, so no validation occurs.

  13. User Interface:

  14. Displays a window (actwdw) with a header and function key label that reflect the current record status:
    • If inactive (crdel = 'I'), shows "CSR Id Entry ReActivate" and "F22=ReActivate".
    • If active, shows "CSR Id Entry InActivate" and "F23=InActivate".
  15. Supports function keys:
    • F12: Exits the program without changes.
    • F22: Triggers reactivation.
    • F23: Triggers inactivation.
  16. Provides message feedback using the GSMSGF message file (though no specific error messages are used in the provided code).

  17. File Overrides:

  18. Uses p$fgrp to apply overrides, redirecting bbcsr to gbbcsr or zbcsr based on the file group.

  19. Message Handling:

  20. Displays messages in a message subfile (msgctl) and clears them as needed. The com array includes a placeholder error message, but it is not used in the code.

Tables (Files) Used

The program uses the following files: 1. bb9294d: - Type: Workstation file (display file). - Usage: Contains the actwdw format for the inactivation/reactivation window, along with a message subfile (msgctl) and clear message format (msgclr). - Handler: PROFOUNDUI(HANDLER) for Profound UI integration. 2. bbcsr: - Type: Physical file (update/add, keyed access). - Usage: Stores CSR records, used to retrieve and update the crdel field for status changes. Accessed using the key list klcsr (f$co, f$crid). - Override: Redirected to gbbcsr or zbcsr based on p$fgrp.


External Programs Called

The program calls the following external program (an IBM i API): 1. QCMDEXC: - Purpose: Executes the file override command to redirect bbcsr to the appropriate library. - Parameters: - dbov## (80 characters, override command). - dbol## (15.5, command length). 2. QMHSNDPM: - Purpose: Sends messages to the program message queue for display in the message subfile. - Parameters: Message ID, message file, message data, data length, message type, program queue, stack counter, message key, error code. 3. QMHRMVPM: - Purpose: Clears messages from the program message queue. - Parameters: Program queue, stack counter, message key, remove option, error code.


Summary

The BB9294 RPGLE program, called by BB929P, is responsible for toggling the status of CSR ID records between active (A) and inactive (I) in the bbcsr file. It presents a confirmation window (actwdw) with dynamic headers and function key labels based on the current record status, allowing users to reactivate (F22) or inactivate (F23) a record. The program enforces rules to ensure status changes are only applied to existing records with the appropriate current status, and it uses file overrides to access the correct library (Z or G). It interacts with two files: bb9294d (display) and bbcsr (CSR data), and relies on IBM i APIs (QCMDEXC, QMHSNDPM, QMHRMVPM) for file overrides and message handling. The chkact subroutine suggests a potential business rule for dependency checking, but it is not implemented in the provided code.