BB110 RPG36
Process Steps of the RPG Program BB110¶
This RPG III program (indicated by the .rpg36 extension and syntax) is a core printing utility for generating picking tickets, order confirmations, or proforma invoices on an IBM midrange system (e.g., AS/400 or iSeries). It is called from the OCL program BB114O and handles the formatting and output of detailed order documents, including specialized versions for customer-owned products (e.g., Viscosity EDI856), packaging plants, and order confirmations. The program processes input files, applies complex logic for sorting, grouping, and calculations, and outputs to multiple printer files (LIST, LIST2, LIST3, LIST4). The provided code is truncated, but includes sufficient detail to outline the process, especially for proforma invoices (aligned with BB114O context). Below is a step-by-step breakdown based on the visible code and revisions:
- Initialization and File Setup:
- Defines numerous input files (e.g., BBORTR, BBORTU, BBORTO, BBORCL, ARCUST, etc.) for order data, customer info, products, and related details.
- Defines printer files: LIST (picking tickets), LIST2 (packaging pick sheet, added JK02), LIST3 (order confirmations, added MG41), LIST4 (proforma invoices, added MG41).
- Initializes variables, indicators (e.g., U5 for picks, U6 for confirmations), and data structures for totals, freight, and addresses.
-
Sets up key lists (KLISTs) for chaining to files (e.g., ARCUST, GSPROD, GSTABL).
-
Header Processing:
- Reads header records from BBORTR (sorted input from BB114O) and BBORHS1 (order headers).
- Chains to related files (e.g., ARCUST for customer name, SHIPTO for ship-to address, BBCAID for carrier) to fetch descriptions and addresses.
- Applies logic for special cases:
- Checks order delete code (BODEL); skips printing if 'E' (error, JB22).
- Evaluates order process status (BOORPR): Treats 'R' (revised/complete) same as 'C' (complete, JB39); marks 'H' as on-hold (MG46).
-
Outputs header data to printer file (e.g., LIST4 for proforma) with fields like order#, customer, ship-to, incoterms (JB38), and route code (JB33).
-
Detail Processing:
- Reads detail records from BBORTR (sorted by BB1143), skipping deleted lines (JB17).
- Chains to GSPROD for product descriptions, GSCNTR1 for container types (JK03), GSMLCD for loading location (JB37), and ARCUPR for pricing with container type (JB45).
- Calculates quantities, weights, and prices:
- Computes net/gross weights (L2NWT, L2GWT; product weight added JB47, gross weight from BB101 JB43).
- Calculates extended price (EXTPRCJB) and totals (TOTPRCJB, PROTOTJB).
- Handles unit conversions via GSUMCV (relaxed for 'KG', 'LI', 'ML', 'OZ' in JB40, JB42).
- For packaging plant (PP/PKGP) or Viscosity EDI856 (JB15, JB18, JB19):
- Outputs customized fields (SIZE, PPBRND, PPDSC1-3, PPCD12) to LIST2 (JK02, JB51).
- Right-justifies brand, removes part# heading (JB20).
-
Outputs detail lines to appropriate printer file (e.g., LIST4 for proforma) with fields like quantity (BDQTY, BDQTS), gross weight (BDGWT), unit measure (PPUMBP), and price (NEWPRCJ).
-
Freight and Miscellaneous Processing:
- Fetches freight details from BBFRPR, BBCAID, or BBOTHS (DC01).
- Determines freight bill address:
- Internal processor: Uses customer address (JB27).
- External processor: Uses freight processor address (JB27, JB28).
- Calls MSHPADR for compressed ship-to address, passing country (JB26, DC02).
- Outputs freight description (FRCDDS), amount (L2FRT, suppressed JB37), and bill-to address (@FBNML, @FBA1L-@FBA3L, @FBCSZ).
-
Prints multiple freight tables for traffic via Spoolflex (MG29).
-
Total and Summary Output:
- Accumulates totals (L2CQT for net quantity, L2TOT for misc charges, TOTPRCJB for price total, PROTOTJB for proforma total).
- Outputs summary lines (PRL4TT format for LIST4):
- Gross/net weight (L2GWT, L2NWT in LBS, JB34), total misc (L2TOT), freight (L2FRT), price total (TOTPRCJB).
- Order status description (P$SDSC, JK01) and 'ON HOLD - DO NOT SHIP' for BOORPR = 'H' (MG46).
-
Prints notes (NTE section) with ARG’s terms, safety instructions, freight estimates, and export compliance.
-
Output Formatting:
- Uses solid lines for headings, dotted lines between groups (JB16).
- Adjusts column positions to avoid off-page printing (JB16, JB18, MG32).
- Prints dispatch marks if enabled (JB17), incoterms (JB38), and expanded product codes/descriptions (MG50).
-
Writes to LIST2 for packaging plant pick sheet instead of LIST for specific cases (JB51).
-
Cleanup and Termination:
- Releases SHPADR record to prevent locking (JB25).
- Outputs to spool files (LIST, LIST2, LIST3, LIST4) for further processing (e.g., SFASPLIT, FFAEDOC in BB114O).
- Sets *INLR to end program, returning to caller.
Business Rules¶
- Document Type Selection: Supports picking tickets (LIST, U5), order confirmations (LIST3, U6, MG41), and proforma invoices (LIST4, MG41) based on input data and caller context (BB114O focuses on proforma).
- Order Validation: Skips orders with delete code 'E' (error, JB22). Marks BOORPR = 'H' as on-hold (MG46).
- Sorting and Grouping: Uses BB1143’s sort fields (GROUP, SORT1-SORT3) for Viscosity (JB15, JB18) or packaging plant (JB19, JB20), e.g., by product, size, or container.
- Freight Handling:
- Internal vs. external processor determines freight bill address (JB27, JB28).
- Suppresses freight total printing (JB37); includes multiple freight tables (MG29).
- Weight and Quantity:
- Gross weight from BB101 (JB43); net weight includes product weight (JB47).
- Relaxed GSUMCV lookups for certain units (JB40, JB42).
- Descriptions and Formatting:
- Uses GSCNTR1 for container codes (JK03), GSMLCD for loading location (JB37).
- Customized descriptions for packaging plant (JB19, JB51) and greases (MG48).
- Expanded product codes/descriptions (MG50).
- EDI and Export:
- Supports Viscosity EDI856 format (JB15, JB18).
- Includes export compliance notes (e.g., U.S. regulations, MSDS availability).
- Printing Rules:
- Adjusts layouts to avoid off-page issues (JB16, MG32).
- Right-justifies brand, adjusts headings (JB20, JB21).
- Prints incoterms (JB38), route code (JB33), and order status (JK01).
- Locking: Releases SHPADR to prevent job conflicts (JB25).
Tables/Files Used¶
Input Files (all shared, prefixed with ?9? from BB114O): - BBORTR (sorted input from BB1143S). - BBORTU, BBORTO, BBORTR3 (BBPROR; unsorted order data). - BBORCL (order control). - ARCUST (customers). - ARCUPR (customer pricing; container type in key, JB45). - SHIPTO, SHPADR (ship-to addresses). - GSCONT (contacts?). - GSTABL (general tables; e.g., CNTRCD, CNTRPF). - GSUMCV (unit conversions). - GSCTWT (carton weights). - GSCTUM (carton UOM). - BICONT (bill-to contacts?). - GSHAZM (hazmat). - BBFRPR (freight pricing). - BBSRNH (serial numbers?). - CUADR (customer addresses). - EDICUS (EDI customers?). - BBASND (ASN data?). - BBSHPH (ship headers?). - BBSHPD (ship details?). - BBOTHS1, BBORH1 (BBORHS1; order headers). - BBOTDS1, BBORD1 (BBORDS1; order details). - BBOTA1, BBORA1 (BBORA; order attachments?). - BBFPORH, BBFPORH1 (proforma headers). - BBFPORD (proforma details). - BBFPORA (proforma attachments). - BBORDRB (BBORDB; order rebates?). - BBORF, BBFPORF (order/proforma footers). - ARCUFMX (customer formats?). - GSCNTR, GSCNTR1 (countries; GSCNTR1 for alpha key, JK03). - GSPROD (products). - GSPRCT (product categories?). - GSMLCD (multi-codes; loading location, JB37). - BBCAID (carrier IDs).
Printer Files: - LIST (picking tickets). - LIST2 (packaging pick sheet, JK02). - LIST3 (order confirmations, MG41). - LIST4 (proforma invoices, MG41).
External Programs Called¶
- MSHPADR: Called for compressed ship-to address, passing country (DC02, JB26).
- MINLBGL1: Called for weight calculations (replaces MINLBGL, JB31).
- No explicit calls in truncated code, but implied integration with Spoolflex tools (MG29, via BB114O’s SFASPLIT, FFAEDOC).