List of Use Cases Implemented in the Call Stack¶
The call stack consists of three RPG programs: BB935P
, BB935
, and BB9354
, which together manage product code cross-reference entries in a billing system. Below are the identified use cases based on the functionality provided by these programs:
- Browse and Filter Product Cross-Reference Entries (BB935P):
- Description: Allows users to view a list of product cross-reference records (
BBPRXY
) in a subfile, with filtering options by company, XRef set, product XRef, product, container, and quantity. Supports toggling between including/excluding deleted records. - Actions: Browse records, reposition based on filters, select records for further actions (create, change, delete, display).
-
Modes: Maintenance (MNT) for selecting actionable options; Inquiry (INQ) for view-only access.
-
Create a New Product Cross-Reference Entry (BB935P → BB935):
- Description: Enables creation of a new product cross-reference record by specifying company, XRef set, and product XRef in the footer (option 1) or selecting option 1 on the subfile, then entering details in a single-record screen.
-
Actions: Validates inputs, ensures record doesn’t exist or isn’t deleted, and writes a new record to
BBPRXY
. -
Change an Existing Product Cross-Reference Entry (BB935P → BB935):
- Description: Allows modification of an existing, non-deleted product cross-reference record by selecting option 2 on the subfile or footer, then editing fields (e.g., product, container, quantity) in a single-record screen.
-
Actions: Validates inputs, updates the record if changed, and confirms the update.
-
Delete a Product Cross-Reference Entry (BB935P → BB9354):
- Description: Marks an active product cross-reference record as deleted (
BXDEL = 'D'
) by selecting option 4 on the subfile or footer, with a confirmation window. -
Actions: Verifies record existence, updates
BXDEL
, and confirms deletion. -
Reactivate a Deleted Product Cross-Reference Entry (BB935P → BB9354):
- Description: Reactivates a deleted product cross-reference record (
BXDEL = 'D'
toBXDEL = 'A'
) by selecting option 4 on a deleted record in the subfile, with a confirmation window. -
Actions: Verifies record is deleted, updates
BXDEL
, and confirms reactivation. -
Display a Product Cross-Reference Entry (BB935P → BB935):
- Description: Views details of a product cross-reference record in a read-only single-record screen by selecting option 5 on the subfile.
-
Actions: Retrieves and displays record details without allowing edits.
-
Prompt for Valid Field Values (BB935P, BB935):
- Description: Provides lookup functionality for fields like XRef set, product, and container to ensure valid entries during browsing or maintenance.
- Actions: Calls external programs (
LGSTABL
,LGSPROD
,LGSCNTR1
) to retrieve valid codes and descriptions.
These use cases cover the core functionality of browsing, managing, and validating product cross-reference entries, with BB935P
handling the list interface, BB935
managing record-level create/change/display, and BB9354
focusing on delete/reactivate operations.
Functional Requirements: Product Cross-Reference Management Function¶
Overview¶
The ProductXRefManagement
function manages product cross-reference records in a billing system, supporting creation, modification, deletion, reactivation, and display of records in the BBPRXY
file, with validation against related master files (BICONT
, GSPROD
, GSCNTR1
, GSTABL
). It processes inputs programmatically, replacing interactive screen logic with a single function call, and operates in Maintenance (MNT) or Inquiry (INQ) mode.
Inputs¶
- Company Code (
P$CO
, numeric): Identifies the company (validated againstBICONT
). - XRef Set (
P$XSET
, 6 chars): Cross-reference set identifier (validated againstGSTABL
for typeBBXSET
). - Product XRef (
P$PXRC
, 20 chars): Product cross-reference identifier. - Product Code (
BXPROD
, variable length): Product identifier (validated againstGSPROD
). - Container Code (
BXCNTR
, variable length): Container identifier (validated againstGSCNTR1
). - Quantity Type (
BXQTTY
, 1 char): Indicates quantity type ('Y' or 'N'; optional, validation commented out in original code). - Operation (
OPERATION
, string): Specifies action (CREATE
,CHANGE
,DELETE
,REACTIVATE
,DISPLAY
). - Mode (
P$MODE
, 3 chars):MNT
for edit operations,INQ
for view-only. - File Group (
P$FGRP
, 1 char):Z
orG
for file library overrides (e.g., test vs. production). - Filter Options (for browse, optional):
- Include Deleted (
INCLUDE_DEL
, boolean): True to include deleted records (BXDEL = 'D'
), false to exclude. - Position Filters (company, XRef set, product XRef, product, container, quantity): For browsing records.
Outputs¶
- Return Flag (
P$FLAG
, 1 char): Indicates result: 1
: Successful create or change.D
: Successful deletion.A
: Successful reactivation.0
: No action or failure.- Error Messages (list of strings): Validation or processing errors.
- Record Data (for
DISPLAY
orBROWSE
, struct): Returns fields (company, XRef set, product XRef, product, container, quantity, descriptions, deletion status) for one or multiple records. - Company Name (
BCNAME
, variable length): Retrieved fromBICONT
. - Product Description (
TPDESC
, variable length): Retrieved fromGSPROD
. - Container Description (
TCDESL
, variable length): Retrieved fromGSCNTR1
.
Process Steps¶
- Apply File Overrides:
-
Use
P$FGRP
(Z
orG
) to override file libraries (BICONT
,BBPRXY
,GSPROD
,GSCNTR1
,GSTABL
) for environment-specific access (e.g.,ZBICONT
vs.GBICONT
). -
Validate Inputs:
- Company: Chain to
BICONT
to verify existence; retrieveBCNAME
. Return errorERR0010
if not found. - XRef Set (for
CREATE
,CHANGE
,BROWSE
): Chain toGSTABL
(typeBBXSET
) to validate; return error if invalid. - Product (if provided): Chain to
GSPROD
to verify existence; retrieveTPDESC
. Return errorERR0010
if not found. - Container (if provided): Chain to
GSCNTR1
to verify existence; retrieveTCDESL
. Return errorERR0010
if not found. - Quantity Type (if provided, commented in original): Must be 'Y' or 'N'; return error "Invalid Response...? or ?" if invalid.
- Record Existence (for
CHANGE
,DELETE
,REACTIVATE
,DISPLAY
): Chain toBBPRXY
with key (P$CO
,P$XSET
,P$PXRC
). Return errorERR0102
if not found. -
Create Checks: For
CREATE
, ensure record doesn’t exist (ERR0101
) or isn’t deleted (ERR0108
). -
Process Operation:
- BROWSE:
- Position to records in
BBPRXY
using filters (company, XRef set, product XRef, product, container, quantity). - Exclude deleted records (
BXDEL = 'D'
) unlessINCLUDE_DEL
is true. - Retrieve up to 28 records (page size); fetch descriptions from
GSPROD
andGSCNTR1
. - Return list of records with fields and descriptions.
- Position to records in
- CREATE (
MNT
mode):- Validate inputs; ensure
P$XSET
andP$PXRC
are provided (ERR0103
if missing). - Write new record to
BBPRXY
withBXDEL = 'A'
,BXCONO = P$CO
,BXXSET = P$XSET
,BXPXRC = P$PXRC
, and other fields. - Set
P$FLAG = '1'
. - Return confirmation message: "Code [XSET]/[PXRC] has been created".
- Validate inputs; ensure
- CHANGE (
MNT
mode):- Validate record is not deleted (
BXDEL ≠ 'D'
; errorERR0108
). - Update
BBPRXY
record with newBXPROD
,BXCNTR
,BXQTTY
if changed. - Set
P$FLAG = '1'
. - Return confirmation message: "Code [XSET]/[PXRC] has been changed".
- Validate record is not deleted (
- DELETE (
MNT
mode):- Validate record is active (
BXDEL ≠ 'D'
). - Update
BBPRXY
settingBXDEL = 'D'
. - Set
P$FLAG = 'D'
. - Return confirmation message: "Code [XSET]/[PXRC] has been deleted".
- Validate record is active (
- REACTIVATE (
MNT
mode):- Validate record is deleted (
BXDEL = 'D'
). - Update
BBPRXY
settingBXDEL = 'A'
. - Set
P$FLAG = 'A'
. - Return confirmation message: "Code [XSET]/[PXRC] has been reactivated".
- Validate record is deleted (
-
DISPLAY (
INQ
mode):- Retrieve record from
BBPRXY
; fetch descriptions fromGSPROD
,GSCNTR1
. - Return record data without updates.
- Retrieve record from
-
Error Handling:
- Return error messages for invalid inputs or failed operations.
-
Clear messages after processing.
-
Return Results:
- Output
P$FLAG
, error messages, and record data (single record forCREATE
,CHANGE
,DELETE
,REACTIVATE
,DISPLAY
; list forBROWSE
).
Business Rules¶
- Modes:
MNT
: AllowsCREATE
,CHANGE
,DELETE
,REACTIVATE
. Validates and updatesBBPRXY
.INQ
: AllowsDISPLAY
,BROWSE
. No updates; read-only.- Record Status:
BXDEL = 'D'
marks a deleted record;BXDEL = 'A'
marks an active record.- Cannot change deleted records (
ERR0108
). - Cannot create if record exists (
ERR0101
) or is deleted (ERR0108
). - Validation:
- Company must exist in
BICONT
(ERR0010
). - XRef set must exist in
GSTABL
(typeBBXSET
). - Product must exist in
GSPROD
(ERR0010
). - Container must exist in
GSCNTR1
(ERR0010
). - Quantity type (if enforced) must be 'Y' or 'N'.
- Browse:
- Filters by company, XRef set, product XRef, product, container, quantity.
- Excludes deleted records unless specified.
- Maximum 28 records per call.
- Messages:
- Confirmations for create, change, delete, reactivate.
- Errors for invalid inputs or operations (e.g.,
ERR0101
,ERR0102
,ERR0103
,ERR0108
,ERR0010
). - File Overrides:
P$FGRP
(Z
orG
) determines library (e.g.,ZBICONT
vs.GBICONT
).
Calculations¶
- Message Length: For error/confirmation messages, calculate length using
%len(%trim(m@data))
forQMHSNDPM
. - Timestamp: Current date/time (
T#CYMD
) retrieved viaTIME
opcode but not used in updates. - Record Comparison: For
CHANGE
, compare saved record (SVDS
) with updated fields (WKDS01
) to detect changes before updating.