Skip to content

BB935

Process Steps

This RPG program (BB935) is designed for maintaining or inquiring about product code references in a billing system. It operates in two modes: Maintenance (MNT) for adding/updating records, or Inquiry (INQ) for viewing only. The program receives parameters (company code, cross-reference set, product cross-reference, mode, file group, and a return flag) and interacts with a display screen (FMT01 format) to allow user input/validation. It uses a workstation display file (bb935d) for user interaction.

Here's a step-by-step breakdown of the program's execution:

  1. Initialization (*INZSR subroutine):
  2. Receives entry parameters: Company (p$co), XRef Set (p$xset), Prod XRef (p$pxrc), Mode (p$mode: 'MNT' or 'INQ'), File Group (p$fgrp: 'G' or 'Z'), and Return Flag (p$flag).
  3. Moves parameters to screen fields (f$co, f$xset, f$pxrc).
  4. Sets up various work fields, message handling, and key lists for file access.
  5. Defines constants for function keys (e.g., F03=Exit, F04=Prompt, F12=Return).

  6. Open Database Tables (OPNTBL subroutine):

  7. Applies file overrides based on the file group parameter (p$fgrp):
    • If 'G', overrides to G-prefixed libraries (e.g., gbicont, gbbprxy).
    • If 'Z', overrides to Z-prefixed libraries (e.g., zbicont, zbbprxy).
  8. Executes overrides using QCMDEXC API.
  9. Opens files: bicont, bbprxy, gsprod, gscntr1.

  10. Retrieve Data for Passed Parameters (RTVDTA subroutine):

  11. Chains (reads) to bbprxy using keys (company, XRef set, Prod XRef). If no record found, clears the record format.
  12. Chains to bicont using company code to fetch company name (bcname). If not found, clears the name.
  13. Sets screen header based on mode: "Product Code Reference Maintenance/Inquiry" for MNT, or "Product Code Reference Inquiry" for INQ.
  14. In INQ mode, protects input fields (IN70 = ON).

  15. Process Panel Formats (SRFMT subroutine):

  16. Clears the screen and initializes FMT01 fields.
  17. Enters a loop to display and process the panel (FMT01) until exit.
  18. Handles message subfile if errors exist (writes to MSGCTL).
  19. Displays FMT01 and processes user input based on function keys or ENTER.
  20. Resets error indicators (IN50-IN69) and clears messages after processing.

  21. Process Format Input (F01SR subroutine):

  22. Handles function keys:
    • F04: Prompts for field lookups (calls external programs LGSPROD or LGSCNTR1 based on cursor position).
    • F10: Positions cursor to home.
    • F12: Exits the loop and program.
  23. For ENTER key (or INQ mode navigation):

    • Edits input fields (F01EDT subroutine).
    • If no errors and in MNT mode, updates/adds to database (UPDDBF subroutine).
    • Determines next action (F01NXT): If no input changes, exits the loop (sets fmtagn = *OFF). (Note: FMT02 is commented out, so it always stays on FMT01.)
  24. Edit Format Input (F01EDT subroutine):

  25. Validates Product Code (bxprod): Chains to gsprod; if invalid, adds error message 'ERR0010' and sets IN50/IN51.
  26. Validates Container Code (bxcntr): Chains to gscntr1; if invalid, adds error message 'ERR0010' and sets IN50/IN52.
  27. (Quantity Type validation is commented out.)
  28. In INQ mode, clears errors and messages (no validation needed).

  29. Update Database (UPDDBF subroutine):

  30. Saves current record values.
  31. Chains to bbprxy: If record exists and changed, updates it; if unchanged, does nothing.
  32. If no record exists, writes a new record with screen values.
  33. Sets return flag (p$flag = '1') if a record was added/updated.
  34. Sets w$exists if a record now exists.

  35. Initialize Format Fields (F01MOV subroutine):

  36. Calls F01EDT to populate descriptions.
  37. Clears errors if any.

  38. Format Protection (F01PRO subroutine):

  39. Sets field protection indicators (IN70-IN74): In INQ mode, protects key fields (IN70-IN73 = *ON).

  40. Prompt Processing (PROMPT subroutine):

    • Determines cursor position.
    • Calls external lookup programs based on field (e.g., LGSPROD for product, LGSCNTR1 for container).
    • Sets *IN19 to indicate format change.
  41. Message Handling:

    • ADDMSG: Sends messages to program message queue using QMHSNDPM API.
    • WRTMSG: Writes to message subfile.
    • CLRMSG: Removes messages using QMHRMVPM API.
  42. Program End:

    • Closes all files.
    • Sets INLR = ON and returns.

The program loops on FMT01 until F12 or no changes in INQ mode. It ensures data integrity through validations and handles user prompts for lookups.

Business Rules

  • Modes:
  • MNT: Allows input, validation, add/update to bbprxy. Fields are editable.
  • INQ: Read-only; fields protected (IN70 = ON). No updates; clears errors automatically.

  • Validation Rules:

  • Product Code (bxprod) must exist in gsprod (fetches description tpdesc).
  • Container Code (bxcntr) must exist in gscntr1 (fetches description tcdesl).
  • Error 'ERR0010' for invalid codes (likely "Record not found").
  • (Commented: Quantity Type must be 'Y' or 'N'; invalid triggers 'ERR0000' with message "Invalid Response...? or ?".)

  • Database Operations:

  • Reads from bicont for company name.
  • Add/Update only in MNT mode; uses chain to check existence.
  • New records populated with screen fields (company, XRef set, Prod XRef).
  • Return flag (p$flag) set to '1' on successful add/update.

  • File Groups:

  • 'G' or 'Z' determines library overrides (e.g., production vs. test data sets).

  • User Interaction:

  • F04 prompts lookups.
  • F12 exits without saving (in INQ) or after saving (in MNT).
  • Errors displayed in message subfile; must be cleared before proceeding.
  • No deletion functionality (only add/update/inquiry).

  • Assumptions:

  • Called from a main OCL (Operating Control Language) procedure.
  • Handles U.S. Dollars as a constant (c#US$), but not used in logic.
  • Date/Time conversions defined but not actively used in visible logic.

Tables Used

The program uses the following AS/400 files (tables). All are user-opened (USROPN) except the display file. Overrides apply based on file group.

  • bb935d: Workstation display file (CF E) for screen interaction (formats: FMT01, MSGCTL, CLRSCR).
  • bicont: Input-only file (IF E K) for company details (key: company code; fetches bcname).
  • gscntr1: Input-only file (IF E K) for container code validation (key: container code; fetches tcdesl).
  • gsprod: Input-only file (IF E K) for product code validation (key: company + product code; fetches tpdesc). Renamed field: tpfil5 to x@fil5.
  • bbprxy: Update/Add file (UF A E K) for product cross-references (key: company + XRef set + Prod XRef; record format bbprxrpf). Fields include bxcono, bxxset, bxpxrc, bxprod, bxcntr, etc.

External Programs Called

  • LGSPROD: Called for product code lookup (F04 on BXPROD field). Parameters: Company (out), Product Code (in/out), File Group (out).
  • LGSCNTR1: Called for container code lookup (F04 on BXCNTR field). Parameters: Container Code (in/out), File Group (out).
  • QMHSNDPM: System API to send program messages (for error/display messages).
  • QMHRMVPM: System API to remove program messages.
  • QCMDEXC: System API to execute commands (for file overrides).
  • (Commented/Unused: DTP010R for date validation, not called in this code.)