BB801 RPGLE
The BB801 RPGLE program is a Customer Order Inquiry application within the Customer Orders and Billing system, designed to display detailed information about customer orders, including open and canceled orders. It is called from the main program BB802 and operates interactively, using subfiles to present order details. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.
Process Steps of the BB801 RPG Program¶
The program follows a structured flow to retrieve and display order details based on input parameters, handle user interactions via function keys, and manage subfile displays. The main steps are executed in the srfmt subroutine, with supporting subroutines handling specific tasks. Here’s a breakdown of the key process steps:
- Initialization (
*inzsrSubroutine): - Purpose: Sets up the program environment and initializes variables.
-
Actions:
- Receives input parameters:
p$co(company),p$ord#(order number),p$mode(mode: 'OPN' for open orders, 'CNL' for canceled orders),p$fgrp(file group: 'G' or 'Z'), andp$flag(return flag). - Moves input parameters to format fields (
f$co,f$ord#) and setsw$mode = 'INQ'for inquiry mode. - Initializes subfile control fields (
rrn1,rrn2,rrnsv1,rrnsv2) to zero and sets page sizes (pagsz1 = 12,pagsz2 = 10). - Sets up date fields using the program status data structure (
psds##) to derive current date (ps#dat) in century-year-month-day format. - Configures message handling fields (
dspmsg,m@pgmq,m@key) for error messaging. - Defines key lists (
klist) for database access (e.g.,klordh,klordd,klcust,klcstship). - Sets the header (
c$hdr1) based onp$mode('Customer Order Inquiry' for 'OPN', 'Customer Canceled Order Inquiry' for 'CNL').
- Receives input parameters:
-
Open Database Tables (
opntblSubroutine): - Purpose: Opens required database files with appropriate overrides based on the file group (
p$fgrp) and mode (p$mode). -
Actions:
- Applies file overrides using arrays
ovg,ovz(general files),ovgopn,ovzopn(open orders), orovgcnl,ovzcnl(canceled orders). - Executes
QCMDEXCto apply overrides dynamically (e.g.,arcusttogarcustorzarcust). - Opens files:
arcust,gsctum,gstabl,shipto,inloc,bbordb,bbordd,bbordh,bbordi,bbordm,bbordo,bbords1,bborcl,bbcnb,bbcnd,bbcnh,bbcni,bbcnm,bbcno,bbcnor,bborhs1.
- Applies file overrides using arrays
-
Retrieve Data (
rtvdtaSubroutine): - Purpose: Fetches order header and customer data for the specified order.
-
Actions:
- Chains to
bbordh(open orders) orbbcnh(canceled orders) usingklordh(f$co,f$ord#) to retrieve order header details. - Chains to
arcustusingklcustto retrieve customer details (bocust). - Chains to
bborclusingklorclto retrieve order control data. - Chains to
gstablfor terms (klarterm), salesman (klslsman), order status (klbborst), and cancel reason (klbborcn, for canceled orders). - Calls
rtvshiptoto retrieve ship-to address details. - Calls
clcordtotto calculate order totals (product, miscellaneous, freight). - Sets
w$fmt = 'SFL1'to display the order detail subfile.
- Chains to
-
Process Formats (
srfmtSubroutine): - Purpose: Manages the main loop for displaying and processing panel formats and subfiles.
-
Actions:
- Clears the screen (
clrscr). - Initializes format fields (
f01mov) and setsw$fmt = 'SFL1'for subfile display. - Enters a loop (
fmtagn) to: - Display the message subfile if needed (
wrtmsg). - Select and display the appropriate format based on
w$fmt:FMT01: Main order header format (exfmt fmt01).FMT02: Secondary format (exfmt fmt02).SFL1: Order detail subfile (srsfl1).SFL2: Miscellaneous charges subfile (srsfl2).
- Clears error indicators (
*in50–*in69) and cursor position (row,col). - Clears the message subfile (
clrmsg) if displayed. - Processes user input based on the current format (
f01srforFMT01,f02srforFMT02).
- Clears the screen (
-
Process Format FMT01 (
f01srSubroutine): - Purpose: Handles user input on the main order header format.
-
Actions:
- Processes function keys:
- F03: Exits the program by setting
fmtagn = *off. - F10: Resets cursor position to home (
row,colcleared). - ENTER: Validates input (
f01edt), and if no errors (*in50 = *off), proceeds to the next format (f01nxt). - Calls
f01proto set display attributes (e.g., highlight order process status 'F' in red).
-
Process Format FMT02 (
f02srSubroutine): - Purpose: Handles user input on the secondary format.
-
Actions:
- Processes function keys:
- F03: Exits the program (
fmtagn = *off). - F10: Resets cursor position to home.
- F12: Returns to
SFL2(w$fmt = 'SFL2'). - ENTER: Validates input (
f02edt), and if no errors, proceeds to the next format (f02nxt).
-
Determine Next Format for FMT01 (
f01nxtSubroutine): - Purpose: Sets the next format to display.
-
Actions:
- Sets
w$fmt = 'SFL1'to transition to the order detail subfile.
- Sets
-
Determine Next Format for FMT02 (
f02nxtSubroutine): - Purpose: Handles transition from
FMT02. -
Actions:
- Calls
BB800Efor order access/marks inquiry with parametersa$co,a$ord#,a$ship = '000', andp$fgrp. - Returns to
SFL1(w$fmt = 'SFL1') and reinitializesFMT01fields (f01mov).
- Calls
-
Process Subfile SFL1 (
srsfl1Subroutine): - Purpose: Manages the order detail subfile display and user interactions.
-
Actions:
- Initializes subfile mode to folded (
sfmod1 = '1',*in45 = *on). - Clears and writes the message subfile (
clrmsg,wrtmsg). - Positions the subfile (
sf1rep) and enters a loop (sf1agn): - Handles repositioning if
repsfl = *onby updatingc1seqand callingsf1rep. - Displays the command line (
sflcmd1) and message subfile if needed. - Sets display indicator (
*in41) based on subfile records (rrn1 > 0). - Toggles folded/unfolded mode (
*in45) based onsfmod1. - Displays subfile control (
exfmt sflctl1). - Processes function keys:
- F03: Exits subfile and program (
sf1agn,fmtagn = *off). - F06: Calls
historddInqfor history inquiry if a subfile record is selected. - F12: Returns to
FMT01(w$fmt = 'FMT01'). - F15: Clears subfile and reloads (
sf1clr,sf1lod). - F16: Displays order instructions (
sflcmd2, chains tobbordiorbbcni). - F20: Displays miscellaneous charges subfile (
w$fmt = 'SFL2'). - ENTER: Processes subfile selections (
sf1prc). - PAGEDN: Loads additional subfile records (
sf1lod).
- F03: Exits subfile and program (
- Updates cursor position and subfile record number (
rcdnb1).
- Initializes subfile mode to folded (
-
Process Subfile SFL2 (
srsfl2Subroutine):- Purpose: Manages the miscellaneous charges subfile.
- Actions:
- Similar to
srsfl1, initializes subfile mode, clears/writes message subfile, and positions records (sf2rep). - Processes function keys:
- F03: Exits subfile and program.
- F12: Returns to
SFL1(w$fmt = 'SFL1'). - F15: Clears and reloads subfile.
- ENTER: Processes selections (
sf2prc). - PAGEDN: Loads additional records (
sf2lod).
-
Retrieve Ship-to Address (
rtvshiptoSubroutine):- Purpose: Populates ship-to address fields based on order data.
- Actions:
- If
boship = 0, uses customer master (arcust) address (arname,aradr1, etc.). - If
boshipis 001–899 or 900–998, chains toshiptousingklcstshiporklord999to retrieve address (csname,csadr1, etc.). - Formats zip code (
f$cszp) with hyphen ifarzip9is non-zero. - Calls
movshiptoto move ship-to fields to format fields.
-
Move Ship-to Values (
movshiptoSubroutine):- Purpose: Transfers ship-to data to display fields.
- Actions:
- Moves
csname,csadr1,csadr2,csadr3,csadr4,csctst,csstat,cscszp,csctyto correspondingf$fields.
-
Calculate Order Totals (
clcordtotSubroutine):- Purpose: Computes product, miscellaneous, and freight totals for the order.
- Actions:
- Clears totals (
f$ptot,f$mtot,f$ftot). - For order details (
bborddorbbcndbased onp$mode):- Reads records using
klordh. - Converts container quantity (
bdqty) to actual quantity usinggsctum(cuoper,cucvfa). - Calculates product total (
f$ptot) asw$qty * bdprce. - Adds freight (
bdofrrorbdfrrt * w$qty) tof$ftot.
- Reads records using
- For miscellaneous charges (
bbordmorbbcnm):- Reads records and adds
bmamttof$mtot(non-freight) orf$ftot(freight,bmmsty = 'F').
- Reads records and adds
- Skips deleted records (
bddel,bmdel <> 'D').
-
History Inquiry (
historddInqSubroutine):- Purpose: Calls the order history inquiry program for a selected subfile record.
- Actions:
- Sets
o$file = 'BBORDH',o$fgrp,f$co,bocust,f$ord#,o$seq. - Calls
GB730Pwithx$ordrhistdata structure.
-
Message Handling (
addmsg,wrtmsg,clrmsgSubroutines):- addmsg: Sends error messages to the program message queue using
QMHSNDPM. - wrtmsg: Displays the message subfile (
msgctl). - clrmsg: Clears the message subfile using
QMHRMVPM.
- addmsg: Sends error messages to the program message queue using
-
Program Termination:
- Closes all open files (
close *all). - Sets
*inlr = *onand returns.
- Closes all open files (
Business Rules¶
- Order Mode Handling:
- Supports two modes: 'OPN' (open orders) and 'CNL' (canceled orders), determined by
p$mode. - Different files are accessed based on mode (
bbord*for open,bbcn*for canceled). -
The header (
c$hdr1) reflects the mode ('Customer Order Inquiry' or 'Customer Canceled Order Inquiry'). -
File Overrides:
- Files are overridden based on
p$fgrp('G' or 'Z') to access different libraries (e.g.,garcustvs.zarcust). -
Additional overrides for open (
ovgopn,ovzopn) or canceled orders (ovgcnl,ovzcnl) ensure correct file access. -
Ship-to Address Logic:
- If
boship = 0, uses customer master address. - For
boship001–899 or 900–998, retrieves fromshiptomaster; for 900+, uses one-time ship-to address. -
Skips deleted ship-to records (
csdel <> 'D'). -
Order Totals Calculation:
- Product total (
f$ptot): Sum ofbdqty * bdprceafter converting container quantity. - Freight total (
f$ftot): Sum ofbdofrrorbdfrrt * qtyfrom order details, plus freight-type miscellaneous charges (bmmsty = 'F'). - Miscellaneous total (
f$mtot): Sum of non-freight miscellaneous charges (bmamt). -
Excludes deleted records and handles special case for sequence 950 (automatic fuel surcharge, per jb01).
-
Display and Navigation:
- Highlights orders with process status 'F' in red (
*in76). - Supports folded/unfolded subfile views (
*in45). - Allows navigation between formats (
FMT01,FMT02,SFL1,SFL2) and inquiries (e.g., order access/marks viaBB800E). -
Ensures proper subfile pagination and cursor positioning.
-
Error Handling:
- Validates input in
f01edtandf02edt(though currently empty, likely to be implemented). - Displays error messages for invalid inputs or credit hold status (
comarray). -
Clears errors after processing to maintain a clean user interface.
-
Credit Hold Check:
-
Displays a message if the order is on credit hold (
com(01)). -
Revision-Specific Rules:
- jb01: Includes sequence 950 records (automatic fuel surcharge) in totals.
- jk02: Adds order process status to
FMT01display. - jk03: Adds F06 for history inquiry via
GB730P. - jk04: Expands screen to 132 columns and adds
inlocfile support. - jk05: Ensures
bborhs1andbbords1are opened for canceled orders to avoid I/O errors.
Tables Used¶
The program accesses the following database files, all defined with usropn for manual opening and overrides:
- arcust: Customer master file (customer details).
- gsctum: Container unit of measure file (quantity conversions).
- gstabl: General table file (terms, salesman, order status, cancel reason).
- shipto: Ship-to master file (ship-to addresses).
- inloc: Location master file (added by jk04).
- bbordb: Order billing file (open orders).
- bbordd: Order detail file (open orders).
- bbordh: Order header file (open orders).
- bbordi: Order instructions file (open orders).
- bbordm: Order miscellaneous charges file (open orders).
- bbordo: Order file (open orders).
- bbords1: Order detail file (open orders, additional).
- bborcl: Order control file (open orders).
- bbcnb: Canceled order billing file.
- bbcnd: Canceled order detail file.
- bbcnh: Canceled order header file.
- bbcni: Canceled order instructions file.
- bbcnm: Canceled order miscellaneous charges file.
- bbcno: Canceled order file.
- bbcnor: Canceled order reason file.
- bborhs1: Order history file (open/canceled orders, added by jk04).
External Programs Called¶
The program interacts with the following external programs:
- BB800E: Order access/marks inquiry program, called from
f02nxt. - Parameters:
a$co,a$ord#,a$ship,o$frgp. - GB730P: Order history inquiry program, called via F06 from
historddInq. - Parameters:
x$ordrhist(data structure witho$file,o$fgrp,f$co,bocust,f$ord#,o$seq). - QMHSNDPM: Sends error 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: Removes messages from the program message queue.
- Parameters:
m@pgmq,m@scnt,m@rmvk,m@rmv,m@errc. - QCMDEXC: Executes override commands for file access.
- Parameters: (implied, not explicitly defined in code snippet).
Additional Notes¶
- Indicator Usage: Uses indicators (19, 21–39, 40–43, 49, 50–69, 70–79, 80, 88, 90–99) for screen control, subfile operations, and error handling.
- Field Prefixes: Organizes fields with prefixes (e.g.,
f$for display,c$for subfile control,s1/s2for subfile fields). - Revisions: Includes updates for fuel surcharge (jb01), process status display (jk02), history inquiry (jk03), screen expansion (jk04), and file I/O fix (jk05).
- Subfile Management: Supports two subfiles (
SFL1for order details,SFL2for miscellaneous charges) with pagination and folded/unfolded views. - Error Messaging: Uses
comarray for messages like credit hold and handles message subfile display/clearing.
This program provides a comprehensive interface for querying customer order details, with robust navigation, data retrieval, and validation features, integrated with the broader system via calls from BB802.