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:
- Initialization (*INZSR subroutine):
- 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).
- Moves parameters to screen fields (f$co, f$xset, f$pxrc).
- Sets up various work fields, message handling, and key lists for file access.
-
Defines constants for function keys (e.g., F03=Exit, F04=Prompt, F12=Return).
-
Open Database Tables (OPNTBL subroutine):
- 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).
- Executes overrides using QCMDEXC API.
-
Opens files: bicont, bbprxy, gsprod, gscntr1.
-
Retrieve Data for Passed Parameters (RTVDTA subroutine):
- Chains (reads) to bbprxy using keys (company, XRef set, Prod XRef). If no record found, clears the record format.
- Chains to bicont using company code to fetch company name (bcname). If not found, clears the name.
- Sets screen header based on mode: "Product Code Reference Maintenance/Inquiry" for MNT, or "Product Code Reference Inquiry" for INQ.
-
In INQ mode, protects input fields (IN70 = ON).
-
Process Panel Formats (SRFMT subroutine):
- Clears the screen and initializes FMT01 fields.
- Enters a loop to display and process the panel (FMT01) until exit.
- Handles message subfile if errors exist (writes to MSGCTL).
- Displays FMT01 and processes user input based on function keys or ENTER.
-
Resets error indicators (IN50-IN69) and clears messages after processing.
-
Process Format Input (F01SR subroutine):
- 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.
-
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.)
-
Edit Format Input (F01EDT subroutine):
- Validates Product Code (bxprod): Chains to gsprod; if invalid, adds error message 'ERR0010' and sets IN50/IN51.
- Validates Container Code (bxcntr): Chains to gscntr1; if invalid, adds error message 'ERR0010' and sets IN50/IN52.
- (Quantity Type validation is commented out.)
-
In INQ mode, clears errors and messages (no validation needed).
-
Update Database (UPDDBF subroutine):
- Saves current record values.
- Chains to bbprxy: If record exists and changed, updates it; if unchanged, does nothing.
- If no record exists, writes a new record with screen values.
- Sets return flag (p$flag = '1') if a record was added/updated.
-
Sets w$exists if a record now exists.
-
Initialize Format Fields (F01MOV subroutine):
- Calls F01EDT to populate descriptions.
-
Clears errors if any.
-
Format Protection (F01PRO subroutine):
-
Sets field protection indicators (IN70-IN74): In INQ mode, protects key fields (IN70-IN73 = *ON).
-
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.
-
Message Handling:
- ADDMSG: Sends messages to program message queue using QMHSNDPM API.
- WRTMSG: Writes to message subfile.
- CLRMSG: Removes messages using QMHRMVPM API.
-
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.)