Skip to content

BB943 RPGLE

The provided document is an RPGLE program named BB943, called from the OCL procedure BB943INQ.ocl36.txt and referenced by the BB943P program in the IBM System/36 (or AS/400 compatibility mode) environment. This program handles "Customer Sales Agreement Maintenance," allowing users to add, update, or inquire about customer sales agreement records. Below, I’ll explain the process steps, business rules, tables used, and external programs called, based on the provided RPGLE source code, the OCL context, and the integration with BB943P.


Process Steps of the RPGLE Program

The BB943 program is an interactive RPGLE program designed for maintaining and inquiring about customer sales agreements. It operates in two modes: inquiry (INQ) and maintenance (MNT), controlled by input parameters. The program uses a display file for user interaction and manages data in the sales agreement file (bicuag) and related files. Here’s a detailed breakdown of the process steps:

  1. Initialization (*inzsr Subroutine):
  2. Receive Parameters: The program accepts several parameters via the *ENTRY plist:
    • p$cono (company number).
    • p$stat (3 characters, status, e.g., 'CF ' for active).
    • p$validpw (1 character, valid password flag, set to 'Y' for user 'KRAJTEST').
    • p$sqky (sequence number key for the agreement).
    • p$frsq (copy-from sequence number for copying records).
    • c1f6flag (1 character, for F6 defaults).
    • c1cust, c1loc, c1cntr, c1prcd, c1prim, c1ship (fields from BB943P for pre-populating data).
    • p$mode (3 characters, 'INQ' or 'MNT').
    • p$fgrp (1 character, file group 'G' or 'Z').
    • p$flag (1 character, return flag).
    • p$dspmsg (1 character, message flag for expiration messages).
  3. Set Current Date/Time: Uses the TIME operation to populate t#time and converts it to t#cymd (CCYYMMDD format) for date validations.
  4. Initialize Fields: Clears work fields (e.g., s1sttm, s1entm, s1prce, s1offp), sets defaults (e.g., fmtagn, delagn to *off), and initializes message handling fields (dspmsg, m@pgmq).
  5. Define Key Lists: Sets up key lists (klcust, klship, klcupr, klcomm, klloc, klvend, klcuag1, klcua3, klcnty, klprod, p$frsqkey, f$sqkey) for file access based on fields like company, customer, location, container, and product codes.
  6. Move Parameters: Transfers p$sqky to f$sq (sequence number) and p$stat to s1stat for display.

  7. Open Database Tables (opntbl Subroutine):

  8. File Overrides: Based on p$fgrp ('G' or 'Z'), applies file overrides using ovg or ovz arrays (e.g., ovrdbf file(arcust) tofile(*libl/garcust) for 'G' group). Executes overrides using QCMDEXC.
  9. Open Files: Opens all defined files (arcust, bicont, gscntr1, gsprod, apvend, gstabl, inloc, shipto, trrtcd, arcupr, bicuag, bicua3, arcomm, bicuagh) with usropn for controlled access.
  10. Clear Messages: Calls clrmsg to clear the message subfile.

  11. Main Processing (Not Fully Shown Due to Truncation):

  12. The program likely contains a main loop to display and process the customer sales agreement maintenance screen using the bb943d display file. The loop handles user input (e.g., function keys like F6 for carrier/billed/all values, Enter for submission) and performs validations.
  13. Display File Interaction: Uses the bb943d display file with formats for maintenance or inquiry, controlled by indicators:
    • *IN70: Protects all fields in 'INQ' mode.
    • *IN71: Protects key fields in update mode ('MNT').
    • *IN72: Protects fields if no password is entered.
  14. Subfile Processing: Likely processes a subfile (though not explicitly shown in the truncated code) for listing agreement details, using indicators *IN40 (subfile clear), *IN41 (subfile display control), *IN42 (subfile display), and *IN43 (subfile end/next change).
  15. Field Validation: Validates input fields (e.g., company, customer, product codes) using key lists and chaining to files like arcust, bicont, gscntr1, and gsprod.
  16. Record Maintenance:

    • Add: In 'MNT' mode, allows creating new records in bicuag (update file with uf a e).
    • Update: Updates existing records based on p$sqky or other keys.
    • Copy: Copies a record from p$frsq to a new sequence number.
    • Expiration: Handles record expiration (per jk04, expires original record if expiration date is greater than the new record’s start date or is zero).
  17. Message Handling (addmsg, wrtmsg, clrmsg Subroutines):

  18. Add Message (addmsg): Sends messages to the program message queue using QMHSNDPM, calculating the message length (m@l) and setting dspmsg to *on.
  19. Write Message (wrtmsg): Writes to the message subfile (msgctl) using *IN49.
  20. Clear Message (clrmsg): Clears the message subfile using QMHRMVPM, saving and restoring the current record format (rcdnam) and page relative record number (pagrrn).

  21. Program Termination (Not Fully Shown):

  22. Likely closes all files (close *all) and sets *inlr = *on to terminate, similar to BB943P.

Business Rules

The program enforces several business rules for managing customer sales agreements:

  1. Mode-Based Access:
  2. In 'INQ' mode, all fields are protected (*IN70 = *on), allowing only viewing.
  3. In 'MNT' mode, fields are editable, but key fields may be protected (*IN71 = *on) during updates, and fields are protected if no valid password is provided (*IN72 = *on).

  4. Validation:

  5. Company (bacono): Must exist in bicont (company file).
  6. Customer (bacust): Must exist in arcust (customer master file).
  7. Ship-to (baship): Validated against shipto file.
  8. Product Codes (bapr01bapr10): Validated against gsprod, with checks for duplicates (svpc array) and at least one valid product code (error com(05)).
  9. Container (bacntr): Validated against gscntr1, but can be blank for non-fluid products (per JB04).
  10. Container Type: Removed ability to enter container type (per jb13, 07/22/2024).
  11. Expiration Date: Cannot be before the start date (error com(06)). Original record expires only if its expiration date is greater than the new record’s start date or is zero (per jk04).
  12. Min/Max Quantity: Maximum quantity (s1mxqy) cannot be less than minimum quantity (s1mnqy, error com(11)).
  13. PO/Order Code: Must be 'P' (PO) or 'O' (Order, error com(12), per mg11).

  14. Duplicate Checks:

  15. Prevents duplicate product codes (com(04)), locations (com(07)), ship-to addresses (com(08)), and customer ship-to combinations (com(09)).
  16. Allows multiple records with the same start date if freight codes differ (per mg12) or for other conditions (per mg12).

  17. Expiration Handling:

  18. Expired records are written to the history file (bicuagh, per jk04).
  19. Sets ending date of expired record to one minute earlier than the new record’s start time (per mg12).

  20. Commission Information:

  21. Includes commission data from arcomm when applicable (per mg09).

  22. Default Values:

  23. Sets p$validpw to 'Y' for user 'KRAJTEST'.
  24. Sets s1prim to 'I' if blank (per jb08).
  25. Uses 0000 as the default start time instead of 0001 (per mg10).

  26. Price and Off-Price Fields:

  27. Expanded s1prce and s1offp to 9.4 packed decimal (per jk05).

  28. Container Type Lookup:

  29. Attempts to retrieve arcupr record with container type first, then with blank container type if not found (per jb06).

Tables Used

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

  1. bb943d: Display file (workstation file) for interactive user interface, likely with subfile support.
  2. arcust: Customer master file, input-only, keyed.
  3. bicont: Company file, update/input, keyed.
  4. gscntr1: Container file (replaced gscntr per jk06), input-only, keyed.
  5. gsprod: Product file, input-only, keyed.
  6. apvend: Vendor file, input-only, keyed.
  7. gstabl: Table file (for codes or configurations), input-only, keyed.
  8. inloc: Location file, input-only, keyed.
  9. shipto: Ship-to address file, input-only, keyed.
  10. trrtcd: Transportation rate code file, input-only, keyed.
  11. arcupr: Customer pricing file, input-only, keyed.
  12. arcomm: Commission file (added per jk03), input-only, keyed.
  13. bicua3: Alternate sales agreement file (replaced bicua2 per jk03), input-only, keyed, with renamed record format (bicuagpf to bicuaglf).
  14. bicuagh: Sales agreement history file, output-only, keyed.
  15. bicuag: Primary sales agreement file, update/add/input, keyed.

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


External Programs Called

The program calls the following external programs:

  1. QCMDEXC:
  2. Called in opntbl to execute file override commands.
  3. Parameters: dbov## (override command), dbol## (length).

  4. QMHSNDPM:

  5. Called in addmsg to send messages to the program message queue.
  6. Parameters: m@id, m@msgf, m@data, m@l, m@type, m@pgmq, m@scnt, m@key, m@errc.

  7. QMHRMVPM:

  8. Called in clrmsg to clear messages from the message queue.
  9. Parameters: m@pgmq, m@scnt, m@rmvk, m@rmv, m@errc.

  10. GSDTEDIT (Implied by pldted PLIST):

  11. Used for date validation.
  12. Parameters: p#mdy, p#cymd, p#err.

  13. GSDTCLC1 (Implied by pldtclc1 PLIST):

  14. Used for date addition/subtraction.
  15. Parameters: p#dat1, p#dat2, p#fmt, p#diff, p#err.

Note: The program likely calls additional programs (e.g., for validation or prompting, such as BB9643V referenced in the p$vlist data structure), but the truncated code does not explicitly show these calls.


Summary

  • Process Steps:
  • Initialize parameters, work fields, key lists, and date/time.
  • Apply file overrides and open database files.
  • Process the display file (bb943d) for maintenance or inquiry, handling user input and validations.
  • Manage add, update, or copy operations on bicuag, with history logging to bicuagh.
  • Handle messages (addmsg, wrtmsg, clrmsg).
  • Terminate by closing files (not fully shown).

  • Business Rules:

  • Supports 'INQ' (read-only) and 'MNT' (editable) modes with field protection.
  • Validates company, customer, ship-to, product codes, and container (optional for non-fluid products).
  • Prevents duplicate product codes, locations, ship-to, and customer ship-to entries.
  • Ensures expiration date is not before start date and handles expiration logic.
  • Enforces min/max quantity rules and PO/order code validation.
  • Supports multiple records with the same start date if freight codes differ.
  • Writes expired records to history and adjusts ending times.
  • Includes commission data and expanded price fields.

  • Tables Used:

  • bb943d, arcust, bicont, gscntr1, gsprod, apvend, gstabl, inloc, shipto, trrtcd, arcupr, arcomm, bicua3, bicuagh, bicuag.

  • External Programs Called:

  • QCMDEXC, QMHSNDPM, QMHRMVPM, GSDTEDIT, GSDTCLC1 (implied).

Due to the truncation of the source code (110,200 characters), some details about the main loop, subfile processing, and additional subroutines (e.g., validation, add/update logic) are not fully visible. If you can provide the complete BB943.rpgle code or specific sections (e.g., main loop, validation subroutines), I can refine the process steps and business rules further. Additionally, if you have the display file (bb943d) or source for called programs like BB9643V, I can provide more context. Let me know how you’d like to proceed!