Skip to content

BB201 RPG36

Process Steps of the RPG Program (BB201)

This RPG program (likely RPG III or RPG/400 for IBM iSeries/AS/400) is responsible for updating open orders based on transaction data from an order entry batch. It processes header, detail, miscellaneous (misc), and marks/remarks records, performing additions, updates, and deletions on various order-related files. The program acts as the core "posting" logic in the order entry system, handling business data like quantities, prices, taxes, freight, and statuses. It includes extensive modifications over time (e.g., JB05 for new fields, JB21 for freight-related deletions) to accommodate evolving business needs, such as customer-owned products, incoterms, rush orders, and history tracking.

The program reads sequentially from the primary input file BBORTR (transaction file) and uses level indicators (L1-L3) and matching records (M1-M3) for processing hierarchies (header → details/misc/marks). It uses indicators (e.g., 01 for header, 02 for detail) to control flow. Key steps are conditional on whether records are new (add), existing (update), or marked for deletion (delete code 'D').

  1. Initialization and Setup:
  2. Define files, fields, and arrays (e.g., BTA and BFA arrays for tax amounts).
  3. Read the first record from BBORTR.
  4. Clear accumulators and work fields (e.g., totals for products, misc, freight, order via CLRHDS subroutine).
  5. Prepare keys for chaining (lookup) to existing order files.

  6. Header Record Processing (Indicator 01):

  7. Identify header records (positions 10-12 = '000').
  8. Chain to BBORDRH (open order header) using company/order#/seq#.
  9. If not found (new order): Add a record to BBORDRH with status 'A' and order flag 'Y'. Copy all header fields (e.g., customer, ship-to, dates, terms, freight code).
  10. If found (existing order): Update specific fields (e.g., customer, ship-to, dates, terms, salesman, carrier, incoterms, totals).
  11. Handle supplemental header (BBORHS1): Add or update fields like totals (product, misc, freight, order), freight details.
  12. If calculate freight (BOCAFR) = 'N': Delete misc records with seq# 943 (CYY service charge) and 950 (separate surcharge) from BBORDRM to handle freight term changes.
  13. Delete from BBOTHS1 (transaction supplemental) if applicable.
  14. Write history to BBORHHS with timestamp, user ID, and workstation ID.

  15. Detail Line Processing (Indicator 02):

  16. Identify detail records (position 10 not '9').
  17. Chain to BBORDRD (open order detail) using company/order#/seq#.
  18. If not found: Add record with status 'A' and order flag 'Y'. Copy fields like item, quantity, price, UOM, description, taxes, freight.
  19. If found: Update fields (e.g., item, quantity, price, UOM, taxes, freight rate, overrides).
  20. Update fluid code (BDFLCD) and IMS UOM (BDIUM) from product master (GSPROD).
  21. Handle supplemental detail (BBORDS1): Add or update fields like container size, weight, hazmat desc, extended taxes (up to 10 codes), qty in UOM.
  22. Delete from BBOTDS1 if applicable.
  23. If delete code = 'D': Call external program to remove from order history (BBOH).
  24. Accumulate totals (e.g., gross/net gallons, weights).
  25. Write history to BBORDHS.

  26. Miscellaneous Line Processing (Indicator 03, implied via seq#):

  27. Process misc items (e.g., seq# 900+ for charges like freight).
  28. Chain to BBORDRM.
  29. Add or update records with qty, desc, amount, G/L, taxes (up to 10 codes), overrides.
  30. Handle customer-owned product flag (BMCOON).
  31. Delete from BBOTA1 or BBORA1 if needed.
  32. Write history to BBORMHS.

  33. Marks/Remarks Processing (Indicators 04-06):

  34. Identify marks by type:
    • 04: Order entry remarks (BBORDRO) – e.g., 4 lines of remarks.
    • 05: Invoice entry remarks/dispatch info (BBORDRI) – e.g., remarks and dispatch lines.
    • 06: Bill of lading remarks (BBORDRB) – e.g., remarks and freight details.
  35. Chain to respective files.
  36. Add or update with customer/ship-to and remark lines.
  37. No deletes shown in provided code.

  38. Tax Override Processing (Indicator 07, implied):

  39. Add or update BBORTX with extended taxes (BTOTE1-0 for order taxes, BTOFE1-0 for freight taxes) and amounts (BTA/BFA arrays, up to 10).

  40. Customer Order Status Update:

  41. Update CUSORD: Add ('A'), update, or delete ('D') status with company, customer, order#, status code, century, date.

  42. Closeout and Cleanup:

  43. Update BBORCL (order closeout?) with delete code, zeros, totals.
  44. No printing (disabled per JB10; previously printed order update register).
  45. End program, committing changes.

The program is cycle-based (implicit LR for last record), with subroutines like CLRHDS (clear header supp), CLRDHS (clear detail supp).

Business Rules

  • Order Types: Handles ' ' (standard), 'R' (return?), 'M' (product move, reused from cash return per JB20), 'C' (removed, was cash sale). Validates and passes to header.
  • Deletions: Only process if delete code = 'D'. For details, call history delete only on 'D' (JB12). Headers/details/marks set status to 'D' or delete records.
  • Freight Handling (JB21): If BOCAFR = 'N' (no calc freight), delete misc seq# 943/950 to avoid residual charges from prior freight terms.
  • Taxes: Supports up to 10 tax codes per line (extended in LT13). Overrides (BDOTX/BMOTX = 'Y') allow manual tax amounts. Separate for product and freight.
  • Quantities and Units: Updates gross/net gallons, temp, gravity, gallon code (MG22). Converts qty to UOM (BDQTUM). Handles container qty, ship qty, backorders.
  • Customer-Owned Product (JB06): Flags (BOCOON/BDCOON/BMCOON) passed; affects shipment logic.
  • Overrides: Prices (BDOPRC), freight rates (BDOFRR), taxes – copied if present.
  • History Tracking (MG19): Writes full record snapshots to history files on changes, including timestamp, user, workstation.
  • Product Validation: Uses GSPROD (replaced GSTABL per JK01) for type, fluid code, IMS UOM.
  • Incoterms and Rush (JB07/DC01): Pass incoterms (BOINCT), rush (BORUSH), process code (BOORPR).
  • Percentages (LT15/JB09): Calculate % of total (BDPCTT) and freight total (BDPCFT).
  • No Charge/Overrides: Flags like BDNOCH ('Y' for no charge), BDQTTY (qty type).
  • Error/Validation: Implicit via chains; assumes pre-validated transactions. Locks records during update.
  • Performance/Nulls: Fields zero/blank-filled (LT13/MG16) to avoid null issues.

Tables (Files) Used

The program uses fixed-format file specifications (F specs) for disk files. All are shared access unless noted. Inputs are mostly update-capable (U), with some input-only (I) or output-only (O). Keys are based on company/order#/seq#.

  • Primary Input: BBORTR (transaction input, IP - primary, sequential read).
  • Update Files (UF/UC - update, chained):
  • BBOTHS1 (header supplemental transaction).
  • BBOTDS1 (detail supplemental transaction).
  • BBOTA1 (accessorial/marks transaction).
  • BBORHS1 (open order header supplemental).
  • BBORDS1 (open order detail supplemental).
  • BBORA1 (accessorial open order).
  • BBORTX (tax overrides).
  • BBORDRH (open order header).
  • BBORDRD (open order detail).
  • BBORDRM (open order misc).
  • BBORDRI (open order invoice marks).
  • BBORDRO (open order entry marks).
  • BBORDRB (open order BOL marks).
  • CUSORD (customer order status).
  • BBORCL (order closeout?).
  • Input-Only Files (IF/IC - chained or setll/read):
  • BBTRTX (transaction tax? IS - input secondary).
  • BICONT (container info?).
  • ARCUST (customer master?).
  • GSCTUM (customer tax master?).
  • GSPROD (product master, replaced GSTABL).
  • Output-Only Files (O):
  • BBORHHS (order header history).
  • BBORDHS (order detail history).
  • BBORMHS (order misc history).

No printer files (printing disabled per JB10).

External Programs Called

  • BB117: Called to delete line items from order history table (BBOH) when delete code = 'D'. Used for duplicate order checking prevention (per DC02/JB12 comments). Parms not shown in truncated code, but likely company/order#/seq#.

(Note: The code is truncated (~33k characters missing), so additional logic (e.g., full CALL statement, more subroutines) may exist but aligns with comments.)