BB800E RPGLE
The BB800E.rpgle.txt is an RPGLE (RPG IV) program named BB800E, designed for the Customer Order Entry system on an IBM AS/400 (iSeries) platform. It serves as a "Customer Order Instructions Inquiry" program, providing an interactive interface to query accessorial and marks instructions for customer orders or ship-to master records, using a subfile (SFL) to display data. Below, I will explain the process steps, business rules, tables used, and external programs called, based on the provided RPGLE source code.
Process Steps¶
The program follows a structured flow to manage the inquiry process for customer order instructions, organized into subroutines executed in a specific sequence:
- Initialization (
*inzsrSubroutine): - Parameters: Receives four input parameters:
p$co(2 characters): Company number.p$csor(6 characters): Customer or order number.p$ship(3 characters): Ship-to number (zero for order mode, non-zero for ship-to mode).p$fgrp(1 character): File group identifier ('G' or 'Z') for file overrides.
- Field Setup: Initializes subfile control fields (
rrn1,rrnsv1,pagsz1set to 32), output parameters (o$mode = 'INQ',o$flag = '0'), and message handling fields (dspmsg,m@pgmq,m@key). - Key Lists: Defines key lists (
klc1s1,klc1s2,klc1r1,klc1r2,klordh,klcus1,klcus2,klship) for file access. -
File Overrides: Prepares for file overrides based on
p$fgrp('G' or 'Z'). -
Error Handling (
*pssrSubroutine): -
Checks for parameter errors using the program status data structure (
psds##). Ifps#err = 221(invalid number of parameters), setsreturn = '*detc'and exits. -
Process Parameters (
@parmsSubroutine): - Assigns input parameters to control fields:
- If at least 1 parameter, sets
c$co = p$co. - If at least 2 parameters, sets
c$csor = p$csor. - If at least 3 parameters, sets
c$ship = p$ship.
- If at least 1 parameter, sets
-
Includes commented-out test values for
c$co,c$csor, andc$shipfor order and ship-to modes. -
Open Database Tables (
opntblSubroutine): - Applies file overrides for
arcust,bbora1,bbordh,bbshsa1, andshiptobased onp$fgrp('G' forg*files, 'Z' forz*files) using theQCMDEXCAPI. -
Opens the files with
usropnfor input-only access. -
Retrieve Data (
rtvdtaSubroutine): - Clears display fields (
c$csnm,c$shnm). - Order Mode (
c$ship = 0):- Sets header
c$hdr1to "Open Order Accessorials/Marks Inquiry" (hd1(01)). - Chains to
bbordhusingklordhto validate the order. - Chains to
arcustusingklcus1to retrieve customer name (arname) intoc$csnm.
- Sets header
-
Ship-to Mode (
c$ship ≠ 0):- Sets header
c$hdr1to "ShipTo Master Accessorials/Marks Inq." (hd1(02)). - Sets
*in79to indicate ship-to mode. - Chains to
arcustusingklcus2to retrieve customer name (arname) intoc$csnm. - Chains to
shiptousingklshipto retrieve ship-to name (csname) intoc$shnm.
- Sets header
-
Process Subfile (
srsfl1Subroutine): - Subfile Setup: Initializes subfile mode (
sfmod1 = '1', folded,*in45 = *on), clears message subfile (clrmsg), and writes it (wrtmsg). - Repositioning: Calls
sf1repto position the file and load initial records. - Overlay: Writes an assume-overlay record (
wdwovr). - Main Loop (
sf1agn):- Repositions the subfile if
repsflis on, usingr$rcid(sf1rep). - Displays the message subfile if errors exist (
wrtmsg). - Sets
*in41(SFLDSP) based on whether subfile records exist (rrn1 > 0). - Sets folded/unfolded mode (
*in45) based onsfmod1. - Writes the command line (
sflcmd1), sets*in40(SFLDSPCTL), and displays the subfile control format (sflctl1) usingexfmt. - Clears message subfile (
clrmsg,msgclr) if errors exist. - Clears format indicators (
*in50-69,*in21-39). - Sets the subfile record number (
rcdnb1) topagrrnfor proper page redisplay.
- Repositions the subfile if
-
User Input Handling:
- F03 (Exit): Exits the loop (
sf1agn = *off). - F12 (Return): Exits the loop (
sf1agn = *off). - Enter Key: Processes subfile selections (
sf1prc). - User Positioning: If
c$rcid ≠ 0, repositions the subfile (sf1rep). - F10: Clears cursor position (
row1,col1) and sets*in69. - Page Down: Commented out, but would load additional records (
sf1lod).
- F03 (Exit): Exits the loop (
-
Subfile Processing (
sf1prcSubroutine): -
If
rrn1 > 0, reads subfile records (readc sfl1) and processes changes (sf1chg) for each record (*in81 = *off). -
Subfile Record Change (
sf1chgSubroutine): -
Currently empty, with commented-out logic for processing option 5 (
s1sel = 5) viasf1s05, suggesting limited or disabled selection functionality. -
Subfile Repositioning (
sf1repSubroutine): - Clears the subfile (
sf1clr) and validates control fields (sf1cte). -
If no errors (
*in50 = *off):- In order mode (
c$ship = 0), positionsbbora1usingklc1s1. - In ship-to mode, positions
bbshsa1usingklc1s2. - Retains
c$rcidinr$rcidand clearsc$rcid. - Loads subfile records (
sf1lod).
- In order mode (
-
Control Field Validation (
sf1cteSubroutine):- Empty, with commented-out validation for a model field (
c$modl) againstinmodl, suggesting potential for future validation (e.g., error 'ERR0900').
- Empty, with commented-out validation for a model field (
-
Subfile Loading (
sf1lodSubroutine):- Sets
rrn1to the last saved record number (rrnsv1) andrcdnb1torrn1 + 1. - Loads up to
pagsz1(32) records: - In order mode, reads
bbora1usingklc1r1. - In ship-to mode, reads
bbshsa1usingklc1r2. - If end of file (
*in43 = *on), adjustsrcdnb1and exits the loop. - Formats each record (
sf1fmt) and writes to the subfile. - Saves the last record number (
rrnsv1) and clears cursor position (row1,col1).
- Sets
-
Subfile Formatting (
sf1fmtSubroutine):- Clears the subfile record and populates fields from
bbora1orbbshsa1: s1rcid: Record ID (barcid).s1qty: Quantity (baqty).s1desc: Description (badesc).s1tcst: Total cost (batcst).s1rccd: Reason code (barccd).s1pick: Pick flag (bapick = 'Y').s1dsph: Dispatch flag (badsph = 'Y').s1bol: Bill of lading flag (babol = 'Y').s1inv: Invoice flag (bainv = 'Y').s1cost: Cost indicator (batcst ≠ 0, sets*in71).
- Clears the subfile record and populates fields from
-
Subfile Protection (
sf1proSubroutine):- Empty, indicating no specific protection logic (though
*in70is defined for global protect in inquiry mode).
- Empty, indicating no specific protection logic (though
-
Message Handling:
- Add Message (
addmsg): Sends error messages to the program message queue usingQMHSNDPM. - Write Message (
wrtmsg): Displays the message subfile (msgctl). - Clear Message (
clrmsg): Clears the message subfile usingQMHRMVPM, preservingrcdnamandpagrrn.
- Add Message (
-
Program Termination:
- Closes all files (
close *all). - Sets
*inlr = *onand returns.
- Closes all files (
Business Rules¶
- Operation Modes:
- Order Mode (
p$ship = 0): Queries accessorial/marks instructions for a customer order usingbbora1. Displays header "Open Order Accessorials/Marks Inquiry." -
Ship-to Mode (
p$ship ≠ 0): Queries instructions for a customer ship-to usingbbshsa1. Displays header "ShipTo Master Accessorials/Marks Inq." and sets*in79. -
Data Validation:
- Validates customer (
bocustorc$csor) againstarcustto retrievearname. - In order mode, validates order (
c$csor) againstbbordh. - In ship-to mode, validates ship-to (
c$ship) againstshiptoto retrievecsname. -
Commented-out validation for
c$modlsuggests potential for model-specific checks. -
Subfile Management:
- Displays up to 32 records per page (
pagsz1). - Supports folded/unfolded display modes (
*in45). -
No "No Results" message logic, unlike
BI890P. -
Navigation and Input:
- F03: Exits the program.
- F12: Returns, exiting the loop.
- F10: Positions cursor to the control record and sets
*in69. - Enter: Processes subfile selections (though
sf1chgis currently empty). - Positioning: Repositions the subfile if
c$rcid ≠ 0. -
Page Down: Commented out, but would load additional records.
-
Inquiry-Only:
- Operates in inquiry mode (
o$mode = 'INQ'), with*in70defined for global field protection. -
No update or create functionality (no options like 1, 2, or 3 as in
BI890P). -
Error Handling:
- Displays errors in a message subfile (
msgctl) usingQMHSNDPM. - Clears messages after each display cycle (
clrmsg). - Parameter errors (
ps#err = 221) trigger program exit.
Tables (Files) Used¶
The program uses the following database files (tables) with input-only access (if and usropn):
1. arcust: Customer master file (contains customer data, e.g., arname).
2. bbora1: Order accessorial/marks file (contains order instructions, e.g., barcid, baqty, badesc, batcst, barccd, bapick, badsph, babol, bainv).
3. bbordh: Order header file (contains order data, e.g., bocust).
4. bbshsa1: Ship-to accessorial/marks file (contains ship-to instructions, similar fields to bbora1).
5. shipto: Ship-to master file (contains ship-to data, e.g., csname).
6. bb800ed: Display file (workstation file with subfile sfl1 and formats sflctl1, sflcmd1, msgctl, msgclr, wdwovr).
External Programs Called¶
The program calls the following external programs (all system APIs):
1. QCMDEXC: Executes file override commands (ovrdbf) for arcust, bbora1, bbordh, bbshsa1, and shipto.
2. QMHSNDPM: Sends error messages to the program message queue.
3. QMHRMVPM: Clears messages from the program message queue.
Summary¶
The BB800E program is an inquiry-only tool for displaying accessorial and marks instructions for customer orders (bbora1) or ship-to master records (bbshsa1). It:
- Operates in order or ship-to mode based on p$ship.
- Uses a subfile to display up to 32 records, with navigation via function keys (F03, F10, F12).
- Validates customer and order/ship-to data, retrieving names for display.
- Applies file overrides based on p$fgrp ('G' or 'Z').
- Includes minimal error handling and no update functionality.
The program integrates with arcust, bbora1, bbordh, bbshsa1, and shipto files, using system APIs for file and message handling. The commented-out logic suggests potential for additional features (e.g., search, selection options) that are currently disabled.
If you need further analysis or have additional context (e.g., related programs like BI9002), please let me know!