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:
- Initialization (
*inzsrSubroutine): - Receive Parameters: The program accepts several parameters via the
*ENTRYplist: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 fromBB943Pfor 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).
- Set Current Date/Time: Uses the
TIMEoperation to populatet#timeand converts it tot#cymd(CCYYMMDD format) for date validations. - Initialize Fields: Clears work fields (e.g.,
s1sttm,s1entm,s1prce,s1offp), sets defaults (e.g.,fmtagn,delagnto*off), and initializes message handling fields (dspmsg,m@pgmq). - 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. -
Move Parameters: Transfers
p$sqkytof$sq(sequence number) andp$stattos1statfor display. -
Open Database Tables (
opntblSubroutine): - File Overrides: Based on
p$fgrp('G'or'Z'), applies file overrides usingovgorovzarrays (e.g.,ovrdbf file(arcust) tofile(*libl/garcust)for'G'group). Executes overrides usingQCMDEXC. - Open Files: Opens all defined files (
arcust,bicont,gscntr1,gsprod,apvend,gstabl,inloc,shipto,trrtcd,arcupr,bicuag,bicua3,arcomm,bicuagh) withusropnfor controlled access. -
Clear Messages: Calls
clrmsgto clear the message subfile. -
Main Processing (Not Fully Shown Due to Truncation):
- The program likely contains a main loop to display and process the customer sales agreement maintenance screen using the
bb943ddisplay file. The loop handles user input (e.g., function keys like F6 for carrier/billed/all values, Enter for submission) and performs validations. - Display File Interaction: Uses the
bb943ddisplay 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.
- 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). - Field Validation: Validates input fields (e.g., company, customer, product codes) using key lists and chaining to files like
arcust,bicont,gscntr1, andgsprod. -
Record Maintenance:
- Add: In
'MNT'mode, allows creating new records inbicuag(update file withuf a e). - Update: Updates existing records based on
p$sqkyor other keys. - Copy: Copies a record from
p$frsqto 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).
- Add: In
-
Message Handling (
addmsg,wrtmsg,clrmsgSubroutines): - Add Message (
addmsg): Sends messages to the program message queue usingQMHSNDPM, calculating the message length (m@l) and settingdspmsgto*on. - Write Message (
wrtmsg): Writes to the message subfile (msgctl) using*IN49. -
Clear Message (
clrmsg): Clears the message subfile usingQMHRMVPM, saving and restoring the current record format (rcdnam) and page relative record number (pagrrn). -
Program Termination (Not Fully Shown):
- Likely closes all files (
close *all) and sets*inlr = *onto terminate, similar toBB943P.
Business Rules¶
The program enforces several business rules for managing customer sales agreements:
- Mode-Based Access:
- In
'INQ'mode, all fields are protected (*IN70 = *on), allowing only viewing. -
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). -
Validation:
- Company (
bacono): Must exist inbicont(company file). - Customer (
bacust): Must exist inarcust(customer master file). - Ship-to (
baship): Validated againstshiptofile. - Product Codes (
bapr01–bapr10): Validated againstgsprod, with checks for duplicates (svpcarray) and at least one valid product code (errorcom(05)). - Container (
bacntr): Validated againstgscntr1, but can be blank for non-fluid products (perJB04). - Container Type: Removed ability to enter container type (per
jb13, 07/22/2024). - 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 (perjk04). - Min/Max Quantity: Maximum quantity (
s1mxqy) cannot be less than minimum quantity (s1mnqy, errorcom(11)). -
PO/Order Code: Must be
'P'(PO) or'O'(Order, errorcom(12), permg11). -
Duplicate Checks:
- Prevents duplicate product codes (
com(04)), locations (com(07)), ship-to addresses (com(08)), and customer ship-to combinations (com(09)). -
Allows multiple records with the same start date if freight codes differ (per
mg12) or for other conditions (permg12). -
Expiration Handling:
- Expired records are written to the history file (
bicuagh, perjk04). -
Sets ending date of expired record to one minute earlier than the new record’s start time (per
mg12). -
Commission Information:
-
Includes commission data from
arcommwhen applicable (permg09). -
Default Values:
- Sets
p$validpwto'Y'for user'KRAJTEST'. - Sets
s1primto'I'if blank (perjb08). -
Uses
0000as the default start time instead of0001(permg10). -
Price and Off-Price Fields:
-
Expanded
s1prceands1offpto 9.4 packed decimal (perjk05). -
Container Type Lookup:
- Attempts to retrieve
arcuprrecord with container type first, then with blank container type if not found (perjb06).
Tables Used¶
The program uses the following files, as defined in the File Specification (F-spec) section:
- bb943d: Display file (workstation file) for interactive user interface, likely with subfile support.
- arcust: Customer master file, input-only, keyed.
- bicont: Company file, update/input, keyed.
- gscntr1: Container file (replaced
gscntrperjk06), input-only, keyed. - gsprod: Product file, input-only, keyed.
- apvend: Vendor file, input-only, keyed.
- gstabl: Table file (for codes or configurations), input-only, keyed.
- inloc: Location file, input-only, keyed.
- shipto: Ship-to address file, input-only, keyed.
- trrtcd: Transportation rate code file, input-only, keyed.
- arcupr: Customer pricing file, input-only, keyed.
- arcomm: Commission file (added per
jk03), input-only, keyed. - bicua3: Alternate sales agreement file (replaced
bicua2perjk03), input-only, keyed, with renamed record format (bicuagpftobicuaglf). - bicuagh: Sales agreement history file, output-only, keyed.
- 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:
- QCMDEXC:
- Called in
opntblto execute file override commands. -
Parameters:
dbov##(override command),dbol##(length). -
QMHSNDPM:
- Called in
addmsgto send messages to the program message queue. -
Parameters:
m@id,m@msgf,m@data,m@l,m@type,m@pgmq,m@scnt,m@key,m@errc. -
QMHRMVPM:
- Called in
clrmsgto clear messages from the message queue. -
Parameters:
m@pgmq,m@scnt,m@rmvk,m@rmv,m@errc. -
GSDTEDIT (Implied by
pldtedPLIST): - Used for date validation.
-
Parameters:
p#mdy,p#cymd,p#err. -
GSDTCLC1 (Implied by
pldtclc1PLIST): - Used for date addition/subtraction.
- 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 tobicuagh. - 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!