Skip to content

BB944 RPGLE

The provided document is an RPGLE program named BB944, called from the OCL procedure BB943INQ.ocl36.txt in the IBM System/36 (or AS/400 compatibility mode) environment. This program, titled "Customer Sales Agreement Delete Program," is designed to delete or reactivate customer sales agreement records in the bicuag file, with history logging to the bicuagh file. It interacts with users via a display file (bb944d) and supports operations like marking records for deletion or reactivating previously deleted records. Below, I’ll explain the process steps, business rules, tables used, and external programs called, based on the provided RPGLE source code and its context within the customer sales agreement maintenance system, integrating with BB943, BB943V, BB9433, and GSDTCLC1.


Process Steps of the RPGLE Program

The BB944 program is an interactive module that allows users to delete or reactivate customer sales agreement records based on a provided company number (p$cono) and sequence number (p$seqn). It uses a display file (bb944d) for user interaction and updates the bicuag file, logging changes to bicuagh. Due to the truncation of the source code (9,696 characters), some logic (e.g., the srfmt and rtvdta subroutines) is incomplete, but I’ll reconstruct the process steps based on the available code and context.

  1. Initialization (*inzsr Subroutine):
  2. Receive Parameters: The program accepts four parameters via the *ENTRY plist:
    • p$cono (company number, defined like bacono).
    • p$seqn (sequence number, defined like baseqn).
    • p$fgrp (1 character, file group: 'G' or 'Z' for file overrides).
    • p$flag (1 character, return flag: e.g., '1' for success, '0' for failure).
  3. Set System Information: Uses the psds## program status data structure to retrieve:
    • ps#pgm (program name).
    • ps#usr (user ID, 10 characters).
    • ps#usr8 (user ID, 8 characters, per jk01).
    • ps#mdy (job date, MMDDYY).
    • ps#hms (job time, HHMMSS).
  4. Set Current Date/Time: Uses the TIME operation to populate t#time (14-digit timestamp) and converts it to t#cymd (8-digit CCYYMMDD) for history record timestamps.
  5. Initialize Fields:
    • Output parameters: Clears o$fgrp, o$mode, and o$flag.
    • Work fields: Sets l$cncd (container code, 2.0) to zeros, w$cnty (container type, 1 character) to blanks.
    • Control flags: Sets fmtagn and delagn to *off for controlling format and deletion window processing.
    • Message fields: Initializes dspmsg to blank, m@pgmq to '*', and m@key to blanks.
  6. Define Key Lists:
    • klship: For accessing shipto with bacono, bacust, and baship.
    • klcuag: For accessing bicuag with p$cono and p$seqn.
    • klcnty: For accessing gstabl with k$cntrty (set to 'CNTRTY') and k$cnty (container type).
  7. Open Database Tables: Calls opntbl to apply file overrides and open files.
  8. Note: Test parameters (commented out, e.g., p$cprf = 'E0910114', p$mode = 'MNT') are for debugging and not used in production.

  9. Open Database Tables (opntbl Subroutine):

  10. File Overrides: Based on p$fgrp ('G' or 'Z'), applies file overrides using ovg or ovz arrays (e.g., ovrdbf file(bicuag) tofile(*libl/gbicuag) for 'G'). Executes overrides with QCMDEXC for five files.
  11. Open Files: Opens the following files with usropn:
    • gscntr1 (container file, input-only, keyed, replaced gscntr per jk02).
    • gstabl (table file for codes, input-only, keyed).
    • shipto (ship-to address file, input-only, keyed).
    • bicuag (sales agreement file, update/input, keyed).
    • bicuagh (sales agreement history file, output-only, keyed, added per jk01).
  12. Purpose: Ensures access to the correct file library (G or Z) for data operations.

  13. Retrieve Data (rtvdta Subroutine, Truncated):

  14. Chain to bicuag: Likely uses klcuag (p$cono, p$seqn) to retrieve the sales agreement record.
  15. Check Record Status:
    • If the record’s end date (baend8) is non-zero, sets *IN71 to *ON (record has expired).
    • If the record’s deletion flag (badel) is 'Y', sets *IN72 to *ON (record is marked deleted, action is reactivate); otherwise, *IN72 = *OFF (record is active, action is delete).
  16. Populate Display Fields: Moves bicuag fields (e.g., bacono, bacust, baloc, bacntr, baship, bapr01bapr10, bapord, bastd8, baend8, baprce, baoffp) to display file fields (f$, s1, or s2 prefixes) for user confirmation.
  17. Validate Related Data: Likely chains to gscntr1 (container), gstabl (unit of measure, container type), and shipto (ship-to address) to display descriptions.

  18. Process Panel Formats (srfmt Subroutine, Partially Truncated):

  19. Initialize Window: Sets winagn = *ON to indicate the main window is active.
  20. Main Window Loop:
    • Displays the bb944d display file, likely with a subfile (sfl1 or sfl2) for agreement details, controlled by indicators:
    • *IN40: Subfile clear.
    • *IN41: Subfile display control.
    • *IN42: Subfile display.
    • *IN43: Subfile end/next change.
    • *IN71: Record has expired.
    • *IN72: Action is reactivate (*ON) or delete (*OFF).
    • Processes user input (function keys: F23 for delete, F22 for reactivate, F12 for cancel, ENTER for confirmation, PAGEDN for scrolling).
  21. Handle Function Keys:
    • F23 (Delete): Marks the record for deletion by setting badel = 'Y' in bicuag and writes to bicuagh.
    • F22 (Reactivate): Clears badel = ' ' to reactivate the record.
    • F12 (Cancel): Exits without changes, setting p$flag = '0'.
    • ENTER: Confirms the delete/reactivate action, updating bicuag and logging to bicuagh.
  22. Subfile Processing: Uses *IN88 for READC (read changed subfile) and *IN49 for message subfile display/control.

  23. Clear Message Subfile (clrmsg Subroutine):

  24. Clear Messages: Calls QMHRMVPM to remove messages from the program message queue.
  25. Save/Restore Context: Saves and restores the current record format (rcdnam to rcdsav) and subfile page relative record number (pagrrn to pagsav).
  26. Parameters: Passes m@pgmq, m@scnt, m@rmvk, m@rmv, and m@errc to QMHRMVPM.
  27. Set Flag: Sets dspmsg = *OFF to indicate no messages are displayed.

  28. Write to History File (Implied, Not Shown):

  29. When deleting a record, likely writes a copy to bicuagh with audit fields:
    • hhchd8 (change date, set to t#cymd).
    • hhchtm (change time, set to t#hms).
    • hhuser (user ID, set to ps#usr8, per jk01).
  30. Uses wkdshist (external data structure for bicuagh) to populate fields.

  31. Program Termination:

  32. Closes all files (close *all).
  33. Sets *inlr = *on to terminate.
  34. Returns p$flag to indicate success ('1') or failure/cancellation ('0').

Business Rules

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

  1. Delete vs. Reactivate:
  2. If the record’s deletion flag (badel) is 'Y', the action is to reactivate (*IN72 = *ON, F22=ReActivate).
  3. If badel is blank, the action is to delete (*IN72 = *OFF, F23=Delete).
  4. Expired records (baend8 ≠ 0) are marked with *IN71 = *ON for display purposes.

  5. Record Retrieval:

  6. Retrieves the agreement from bicuag using p$cono and p$seqn (klcuag).
  7. Validates related data (container in gscntr1, unit of measure/container type in gstabl, ship-to in shipto).

  8. History Logging (per jk01):

  9. When a record is deleted, a copy is written to bicuagh with audit fields (hhchd8, hhchtm, hhuser).
  10. The deletion flag (badel) is copied to hhdel in the history record.

  11. User Interaction:

  12. Displays the agreement details for confirmation using bb944d.
  13. Supports function keys:
    • F23: Marks badel = 'Y' and logs to bicuagh.
    • F22: Clears badel = ' ' to reactivate.
    • F12: Cancels the operation.
    • ENTER: Confirms the delete/reactivate action.
    • PAGEDN: Scrolls the subfile.
  14. Protects input fields in certain modes (*IN70–*IN79).

  15. Validation:

  16. Ensures the agreement exists in bicuag before processing.
  17. Validates container codes (gscntr1, replaced gscntr per jk02) and other fields (via gstabl, shipto).

  18. Error Handling:

  19. Displays errors using the message subfile (*IN49) with messages stored in m@80 array and GSMSGF message file.
  20. Positions the cursor (csrloc) on error fields (*IN50–*IN69, *IN21–*IN39).

Tables Used

The program uses the following files, as defined in the File Specification (F-spec) section:

  1. bb944d: Display file (workstation file) for user interaction, likely with subfile support (sfl1 or sfl2).
  2. gscntr1: Container file (replaced gscntr per jk02), input-only, keyed.
  3. gstabl: Table file (for codes like unit of measure, container type), input-only, keyed.
  4. shipto: Ship-to address file, input-only, keyed.
  5. bicuag: Sales agreement file, update/input, keyed.
  6. bicuagh: Sales agreement history file (added per jk01), output-only, keyed.

File Overrides: - The ovg and ovz arrays specify overrides for file groups 'G' and 'Z', mapping files to libraries (e.g., ggscntr1, zbicuagh).


External Programs Called

The program explicitly calls one external program:

  1. QCMDEXC:
  2. Called in the opntbl subroutine to execute file override commands.
  3. Parameters: dbov## (override command string, 80 bytes), dbol## (length, 15.5).

  4. QMHRMVPM:

  5. Called in the clrmsg subroutine to clear messages from the message subfile.
  6. Parameters: m@pgmq, m@scnt, m@rmvk, m@rmv, m@errc.

No other external programs are explicitly called, though GSDTCLC1 (from the previous context) may be used for date calculations in the truncated rtvdta or srfmt subroutines.


Summary

  • Process Steps:
  • Initialize by receiving p$cono, p$seqn, p$fgrp, and p$flag, setting date/time, and defining key lists.
  • Apply file overrides and open files (opntbl).
  • Retrieve agreement data from bicuag and related files (rtvdta, truncated).
  • Process user interaction via bb944d, handling delete (F23), reactivate (F22), or cancel (F12) actions (srfmt, partially truncated).
  • Clear message subfile (clrmsg).
  • Update bicuag (set badel) and log to bicuagh for deletions.
  • Terminate, closing files and returning p$flag.

  • Business Rules:

  • Deletes records by setting badel = 'Y' (F23) or reactivates by clearing badel (F22), based on *IN72.
  • Logs deleted records to bicuagh with audit fields (jk01).
  • Validates agreement existence and related data (container, ship-to).
  • Displays expired records with *IN71.
  • Handles user input with function keys and subfile navigation.
  • Uses G or Z file groups for overrides.

  • Tables Used:

  • bb944d, gscntr1, gstabl, shipto, bicuag, bicuagh.

  • External Programs Called:

  • QCMDEXC (for file overrides).
  • QMHRMVPM (for message clearing).

Due to the truncation of the source code, details of the srfmt and rtvdta subroutines are incomplete, limiting visibility into the full display logic and record processing. If you can provide the complete BB944.rpgle code or specific sections (e.g., srfmt, rtvdta), I can refine the process steps and business rules further. Additionally, if you have the display file (bb944d) or related programs, I can provide more context. Let me know how you’d like to proceed!