Skip to content

BB944 RPGLE

The RPG program BB944.rpgle is an IBM i (AS/400) program designed for deleting or reactivating customer sales agreement records in the bicuag file. It is called from BB943P as part of the Customer Sales Agreement Maintenance process, specifically for handling the delete (option 4) operation. The program presents a confirmation window to the user to either delete an active record or reactivate a deleted record and updates the history file (bicuagh) accordingly. Below, I will explain the process steps, business rules, tables used, and external programs called based on the provided RPG source code.


Process Steps of the RPG Program

The BB944 program follows a structured flow to manage the deletion or reactivation of customer sales agreement records using a display file (bb944d) with a confirmation window. The key process steps are:

  1. Initialization (*inzsr Subroutine):
  2. Parameters: Receives four input parameters:
    • p$cono: Company number.
    • p$seqn: Sequence number of the sales agreement record.
    • p$fgrp: File group ('G' or 'Z') to determine database file overrides.
    • p$flag: Return flag to indicate the action taken ('D' for delete, 'A' for reactivate).
  3. Field Setup: Initializes work fields (l$cncd, w$cnty), message handling fields (dspmsg, m@pgmq, m@key), and current date/time (t#time, t#cymd) for validation and history logging.
  4. Output Parameters: Initializes o$fgrp, o$mode, and o$flag as blank.
  5. Data Structures: Defines wkds01 (external data structure for bicuag) and wkdshist (external data structure for bicuagh) to hold record formats.

  6. Open Database Tables (opntbl Subroutine):

  7. Applies file overrides (ovg or ovz) based on p$fgrp using the QCMDEXC API, mapping files to appropriate libraries (e.g., ggscntr1 or zgscntr1).
  8. Opens input files (gscntr1, gstabl, shipto) and update/output files (bicuag, bicuagh) with USROPN for data access.

  9. Retrieve Data (rtvdta Subroutine):

  10. Chains to bicuag using the klcuag keylist (p$cono, p$seqn) to retrieve the sales agreement record.
  11. If the record is found (*in99 = *off):
    • Populates display fields (f$*) with record data (e.g., f$cono, f$cust, f$loc, f$cntr, f$ship, f$pord, f$prce, f$offp).
    • Converts start/end dates (bastd8, baend8) to MMDDYY format (f$smdy, f$emdy) for display.
    • Checks if the record is expired (baend8 < t#cymd) and sets *in71 = *on to highlight in red.
    • Checks the deletion status (badel):
    • If badel = 'D', sets *in72 = *on (indicating reactivation mode, F22=ReActivate).
    • If badel ≠ 'D', sets *in72 = *off (indicating deletion mode, F23=Delete).
  12. Chains to shipto using klship to retrieve the ship-to name (f$shnm) if baship ≠ 0.

  13. Process Panel Formats (srfmt Subroutine):

  14. Main Window Loop: Enters a loop (winagn = *on) to display the confirmation window (delwdw) and process user input.
  15. Message Handling:
    • Displays the message subfile (wrtmsg) if dspmsg = *on.
    • Clears the message subfile (clrmsg) after input processing.
  16. Display Window: Writes the overlay record (wdwovr) and formats (delwdw) using EXFMT to show the confirmation window with record details.
  17. Process Input:

    • F12 (Cancel): Exits the loop (winagn = *off), returning without action.
    • F23 (Delete): If *in72 = *off (active record), chains to bicuag, sets badel = 'D', writes to history (writehist), updates bicuag, sets p$flag = 'D', and exits.
    • F22 (Reactivate): If *in72 = *on (deleted record), chains to bicuag, sets badel = 'A', writes to history (writehist), updates bicuag, sets p$flag = 'A', and exits.
    • Other Input: Validates the password (c1agpw) against w$agpw (populated by rtvdta) and redisplays the window if invalid.
  18. Write History (writehist Subroutine):

  19. Copies the current bicuag record to the wkdshist data structure.
  20. Sets history fields:
    • hhdel = badel (deletion status, per jk01).
    • hhuser = ps#usr8 (user ID, 8 characters).
    • hhmdy = ps#mdy (current date, MMDDYY).
    • hhhmst = ps#hms (current time, HHMMSS).
  21. Writes the record to bicuagh.

  22. Message Handling:

  23. Add Message (addmsg): Sends messages to the program message queue using QMHSNDPM.
  24. Write Message (wrtmsg): Writes messages to the message subfile (msgctl).
  25. Clear Message (clrmsg): Clears the message subfile using QMHRMVPM, preserving the current record format and subfile page.

  26. Program Termination:

  27. Closes all files (close *all).
  28. Sets *inlr = *on and returns, passing back p$flag ('D' or 'A') to indicate the action taken.

Business Rules

The program enforces the following business rules for deleting or reactivating customer sales agreement records:

  1. Record Status:
  2. Records with badel = 'D' (deleted) can be reactivated (badel = 'A') using F22 (*in72 = *on).
  3. Records with badel ≠ 'D' (active) can be deleted (badel = 'D') using F23 (*in72 = *off).
  4. Expired records (baend8 < current date) are highlighted in red (*in71 = *on).

  5. Password Validation:

  6. A valid agreement password (c1agpw) must match the stored password (w$agpw) from rtvdta for delete or reactivate actions.
  7. Invalid passwords cause the window to redisplay for re-entry.

  8. History Logging:

  9. Every delete or reactivation action writes a record to bicuagh with the user ID, date, time, and deletion status (hhdel = 'D' or 'A', per jk01).

  10. Record Existence:

  11. The program chains to bicuag using p$cono and p$seqn to ensure the record exists before processing (*in99 = *off).
  12. If the record is not found or already in the desired state (e.g., attempting to delete a deleted record), no update occurs.

  13. Ship-To Name:

  14. If a ship-to code (baship) is non-zero, the program retrieves the ship-to name (f$shnm) from shipto for display.

  15. File Group Overrides:

  16. Uses p$fgrp ('G' or 'Z') to apply appropriate file overrides, ensuring access to the correct dataset (e.g., gbicuag or zbicuag).

Tables Used

The program uses the following database files, with overrides applied based on p$fgrp ('G' or 'Z'):

  1. gscntr1: Container file (input, validates container codes, alpha key, replaced gscntr per jk02).
  2. gstabl: Table file (input, likely for container types or other reference data).
  3. shipto: Ship-to file (input, retrieves ship-to name for display).
  4. bicuag: Sales agreement file (update, primary file for deleting/reactivating records).
  5. bicuagh: Sales agreement history file (output, logs delete/reactivate actions, added per jk01).

Overrides map these files to specific libraries (e.g., ggscntr1 or zgscntr1).


External Programs Called

The program calls the following external programs:

  1. QCMDEXC: System API to execute file override commands for the specified file group ('G' or 'Z').
  2. QMHSNDPM: System API to send messages to the program message queue.
  3. QMHRMVPM: System API to clear messages from the message subfile.

No other user-defined programs are called in the provided source code.


Summary

  • Process Steps: Initializes parameters, applies file overrides, opens database files, retrieves the sales agreement record, displays a confirmation window, processes user input (F12 to cancel, F23 to delete, F22 to reactivate), validates passwords, updates bicuag, logs to bicuagh, and handles messages.
  • Business Rules: Allows deletion (badel = 'D') or reactivation (badel = 'A') of records, requires valid passwords, logs actions to history, highlights expired records, and validates record existence and ship-to names.
  • Tables Used: gscntr1, gstabl, shipto, bicuag, bicuagh.
  • External Programs Called: QCMDEXC, QMHSNDPM, QMHRMVPM.

If you need further analysis of specific subroutines, file structures, or integration with BB943P or BB943, please provide additional details or source code. Alternatively, I can perform a DeepSearch for related information if enabled. Let me know how to proceed!