Skip to content

BB150 RPG36

The BB150.rpg36.txt RPG program is a complex program used for printing Bills of Lading (BOLs) in an IBM System/36 or AS/400 environment, called by the main OCL program (BB150P). It handles both regular and railcar BOLs, with specific logic for EDI 856 (Viscosity) orders, multi-load shipments, and various formatting requirements. The program has been extensively modified over time (as indicated by change logs from 2008 to 2024) to address specific business needs, such as freight processor handling, container type processing, and formatting improvements. Below, I’ll explain the process steps, business rules, tables (files) used, and external programs called.


Process Steps of the BB150 RPG Program

The BB150 program processes order and shipment data to generate printed BOLs, handling both regular (order pick list time, U5) and railcar (railcar BOL time, U6) scenarios. It reads multiple files, applies business logic, and produces formatted output to the LIST and LIST1 printer files. The program’s logic is driven by the order header, detail, and marks records, with special handling for EDI orders and multi-load shipments. Here’s a breakdown of the process steps:

  1. Initialization:
  2. The program initializes by reading input files (BBTRAN, BBOTHS1, BBBLHS1, etc.) and setting up printer files (LIST, LIST1).
  3. It retrieves system date (UDATE) for printing and initializes variables like PAGE for pagination.
  4. It processes the U5 (order pick list time) or U6 (railcar BOL time) indicators to determine the type of BOL to print.
  5. It sets up arrays for messages (MSG, MSG1, MSG2, MSG3, MSG4) and key fields (KYOR, KYFS, KYTS) for selected order numbers and shipment reference numbers (SRNs).

Purpose: Prepares the environment for processing orders and printing BOLs.

  1. Order Header Processing:
  2. Reads header records from BBTRAN, BBOTHS1 (for U5), or BBBLHS1 (for U6) based on the company (BOCO) and order number (BORDNO).
  3. Validates the header record:
    • Skips records marked as deleted (BODEL = 'D') or with an error for EDI orders (BODEL = 'E' for JB20).
    • Checks the order process status (BOORPR = 'H') to skip pick ticket printing (MG34).
  4. Retrieves additional header data, such as customer number (BOCUST), ship-to number (BOSHIP), freight processor code (BOFPCD), and shipment reference number (BOSRN).
  5. For multi-load orders (BOMULO = 'Y'), processes multiple shipments using KYFS (from SRN) and KYTS (to SRN) to handle unique order-SRN combinations (JB07, JB09).

Purpose: Identifies valid orders and gathers header information for BOL printing.

  1. Customer and Shipment Data Retrieval:
  2. Chains to ARCUST and SHIPTO to retrieve customer name (ARNAME) and ship-to address (CSNAME, CSADR1, etc.).
  3. Calls MSHPADR to get compressed ship-to address (DC01, JB23).
  4. Retrieves freight processor details from BBFRPR (JB05) and checks if the processor is internal or external (JB24).
  5. For EDI 856 orders (JB13), chains to EDICUS, BBASNH, BBASND, and BBASNM to retrieve shipper details and product descriptions.
  6. Retrieves routing information from TRRTCD and container details from GSCONT, BICONT, and GSCNTR1 (JK02).

Purpose: Collects customer, ship-to, freight processor, and routing data for inclusion on the BOL.

  1. Detail Line Processing:
  2. Reads detail records from BBTRAN (NS 02) for order lines, checking for non-deleted records (BDDEL ≠ 'D').
  3. Retrieves product details from GSTABL (or GSPROD for JK04) for descriptions (TBDESC, TBSHDS), hazmat codes (TBSMSG), and gravity (TBGRAV).
  4. Determines container size based on container type (BDCNTR) from GSCNTR1 (JK02, JB18):
    • If bulk, uses unit of measure (BDIUM) as size.
    • If packaged, uses container short description (TBSHDS).
  5. Calculates weights and gallons:
    • Gross weight (BDGVWT), net gallons (BDNGAL), and product weight (BDPRWT) are retrieved or calculated.
    • Calls MINLBGL1 (JB26) to convert between pounds and gallons, replacing earlier logic (JB02).
  6. Handles hazmat information from GSHAZM (HMSHD1HMSHD4) for printing safety messages.

Purpose: Processes order line items, including product details, weights, and hazmat information for BOL details.

  1. Marks and Accessorials Processing:
  2. Reads marks records from BBOTA1 (for U5) or BBBLA1 (for U6) for order remarks, invoice remarks, dispatch remarks, and BOL remarks (BXBMK1BXBMK4).
  3. Filters marks based on print flags (BAPICK, BABOL, BADSPH for dispatch marks, JB17).
  4. Processes freight processor address (BXFRNM, BXFRA1BXFRA3) for printing on BOLs when applicable (JB06, JB24).

Purpose: Includes order-specific remarks and freight processor details on the BOL.

  1. BOL Printing:
  2. Outputs to LIST (regular BOL) and LIST1 (temporary PDF spooling, MG38) using exception output records (PRTHDG, PRTDTL, PRTRIL, PRTEID, PRTTF, etc.).
  3. Prints header information:
    • Company address (BCADR1, BCADR2 from BICONT, MG25).
    • Order number with SRN (BORDNOZSRN, JB07, JB09).
    • Customer, ship-to, and freight processor details.
    • Batch number (BOFAC1BOFAC2, MG29).
    • Routing codes (BORTCD, BORTG1BORTG3, JB27).
  4. Prints detail lines:
    • Quantity (BDQTY), unit of measure (PRTUM), hazmat indicators (HAZMAT), product description (PRDSC1, PRDSC2), and gross weight (GROSWTM).
    • For railcar BOLs (U6), includes capacity (BDCACAJ), outage (BDOUTAJ), temperature (BDTEMPZ), and net gallons (BDNGALJ, JB21).
    • For EDI 856 orders, prints vendor part (SDVPPT), buyer part (SDBYPT), and custom descriptions (SDDSC1, SDDSC2, JB13).
  5. Prints footer information:
    • Freight terms (MSG,1 for collect, MSG,2 for prepaid, MSG,21 for prepaid+, MSG,22 for third party, MSG,24 for calculated freight, JB40).
    • Hazmat messages (MSG,3, MSG,4 for dyed diesel/kero, MSG,6, MSG,7 for DOT/CHEMTREC).
    • Shipper name and address (SHPRNM, SHPRA1, etc., JB13).
    • Page number (PAGE, JB12).

Purpose: Generates formatted BOLs with all required header, detail, and footer information.

  1. File Updates:
  2. Updates BBORTO or BBORTOB with the BOL printed flag (BOPBOL = 'Y') and SRN (HSRN, JB07).
  3. Updates BBSRNH with the printed BOL indicator (SRPBOL = 'Y', JB15) for tracking.
  4. Uses exception output (UPDTE, UPDSRN) to update these files.

Purpose: Records that the BOL has been printed and updates shipment tracking.

  1. Multi-Load and Overflow Handling:
  2. For multi-load orders (BOMULO = 'Y'), prints additional BOLs (PRTHD2, PRTDT2, PRTRI2, PRTTF2) with consistent fields (JB19).
  3. Handles overflow formatting to avoid printing unnecessary sections (e.g., freight processor for EDI orders, JB19).

Purpose: Ensures all shipments in a multi-load order are printed correctly.

  1. EDI 856 (Viscosity) Handling:
  2. Checks EDICUS for customers with EDI 856 orders (EIIBOB = 'O') and processes data from BBASNH, BBASND, and BBASNM for custom product descriptions and FOB details (JB13).
  3. Suppresses certain fields (e.g., freight processor address) for EDI orders (JB19).

Purpose: Customizes BOL output for Viscosity orders received via EDI.


Business Rules

The program enforces the following business rules: 1. BOL Type Differentiation: - Regular BOLs are printed at order pick list time (U5). - Railcar BOLs are printed at railcar BOL time (U6), with specific fields like car capacity, outage, and temperature (JB21).

  1. Order Validation:
  2. Skips deleted orders (BODEL = 'D') or EDI orders with errors (BODEL = 'E', JB20).
  3. Skips pick ticket printing for orders with BOORPR = 'H' (MG34).

  4. Multi-Load Orders:

  5. Uses order number and SRN (BORDNOSRN) to uniquely identify shipments (JB07, JB09).
  6. Prints extra BOLs for multi-load orders with consistent formatting (JB19).

  7. Freight Processor Handling:

  8. Prints freight processor address (FPNAME, FPADR1, etc.) only for external processors or customer/ARG third-party processors (JB06, JB24).
  9. Uses FREIGHT ARRANGED BY instead of THIRD PARTY FRT PROCESSOR for clarity (JB11).

  10. Container and Size Logic:

  11. Determines size based on container type (BDFLCD): bulk uses unit of measure, packaged uses container description (JB18).
  12. Does not require GSUMCV records for units like KG, LI, ML, OZ (JB30, JB31).

  13. Weight and Gallon Conversion:

  14. Calls MINLBGL1 to calculate gallons or pounds directly, replacing earlier conversion logic (JB02, JB26).
  15. Supports non-fluid products by adjusting calculations (VV04).

  16. Hazmat and Messaging:

  17. Prints hazmat messages (MSG,3, MSG,4) for dyed diesel/kero only when applicable (JB14).
  18. Includes DOT emergency response and CHEMTREC messages (MSG,6, MSG,7) when required.
  19. Adds specific messages for PP destinations (MSG,23, MG36).

  20. Formatting and Layout:

  21. Adjusts field positions to prevent printing off the page (JB16).
  22. Removes blank lines for railcar BOL overflow (JB39).
  23. Prints compressed addresses via MSHPADR (DC01, JB23).

  24. Data Integrity:

  25. Updates BBORTO/BBORTOB and BBSRNH to track BOL printing (JB15).
  26. Uses system date (UDATE) for printing and updates (MG42).

  27. Railcar-Specific Rules:

    • Prints car capacity, outage, and temperature only when capacity is entered (JB21).
    • Includes railcar-specific messages like demurrage charges (MSG,19, MSG,20).

Tables (Files) Used

The program interacts with the following files: 1. BBTRAN (IP, 512 bytes): Order header and detail records. 2. BBOTHS1 (IF, 512 bytes, U5): Order header for regular BOLs. 3. BBOTDS1 (UF, 512 bytes): Order detail for regular BOLs. 4. BBBLHS1 (IF, 512 bytes, U6): Order header for railcar BOLs. 5. BBORTO (UC, 512 bytes, U5): Order header update for regular BOLs. 6. BBORTOB (UC, 512 bytes, U6): Order header update for railcar BOLs. 7. BBOTA1 (IF, 512 bytes, U5): Accessorial/marks for regular BOLs. 8. BBBLA1 (IF, 512 bytes, U6): Accessorial/marks for railcar BOLs. 9. BBORCL (IC, 256 bytes): Order close data. 10. ARCUST (IC, 384 bytes): Customer master data. 11. ARCUPR (IF, 80 bytes): Customer product data, updated to include container type (JB33). 12. SHIPTO (IC, 2048 bytes): Ship-to address data. 13. GSCONT (IC, 512 bytes): Container data. 14. BICONT (IC, 256 bytes): Billing container data. 15. GSTABL (IC, 256 bytes): General table for product codes, descriptions, etc. 16. GSCTWT (IC, 64 bytes): Container weight data, updated for larger gallon field (JB43). 17. GSCTUM (IC, 64 bytes): Unit of measure conversion. 18. GSUMCV (IC, 64 bytes): Unit conversion, optional for certain units (JB30, JB31). 19. GSHAZM (IC, 384 bytes): Hazmat data. 20. BBFRPR (IF, 256 bytes): Freight processor data (JB05). 21. TRRTCD (IC, 324 bytes): Routing code data. 22. BOLEDIY (UF, 386 bytes, U6): EDI order data. 23. BBSRNH (UF, 128 bytes): Shipment reference number tracking, updated with BOL print flag (JB15). 24. SHPADR (IF, 448 bytes): Shipment address data (JB12). 25. EDICUS (IF, 384 bytes): EDI customer data for 856 orders (JB13). 26. BBASNH (IF, 512 bytes): Advanced shipping notice header (JB13). 27. BBASND (IF, 512 bytes): Advanced shipping notice detail (JB13). 28. BBASNM (IF, 256 bytes): Advanced shipping notice marks (JB13). 29. GSCNTR1 (IF, 512 bytes): Container data with alpha key (JK02). 30. GSPRCT (IF, 256 bytes): Product cross-reference for grease descriptions (MG35). 31. BBCAID (IF, 200 bytes): Carrier ID data (JK03). 32. GSPROD (IF, 512 bytes): Product data, replacing GSTABL for product codes (JK04). 33. LIST (O, 132 bytes): Primary printer file for BOL output. 34. LIST1 (O, 132 bytes): Temporary printer file for PDF spooling (MG38).

Key Fields: - BOCO (company), BORDNO (order number), BOSRN (shipment reference number), BOCUST (customer), BOSHIP (ship-to), BOFPCD (freight processor), BDQTY (quantity), BDPROD (product), BDCNTR (container), BDGVWT (gross weight), BDNGAL (net gallons).


External Programs Called

The program explicitly calls the following external programs: 1. MSHPADR (DC01, JB23): - Returns compressed ship-to address, including country. 2. MINLBGL1 (JB26): - Calculates gallons or pounds for weight conversions, replacing MINLBGL (JB02).


Summary

The BB150 RPG program is a critical component for printing Bills of Lading, handling both regular and railcar BOLs with extensive customization for EDI 856 orders, multi-load shipments, and freight processor details. It: - Reads order header, detail, and marks records from multiple files. - Validates orders, retrieves customer/shipment data, and calculates weights/gallons. - Prints formatted BOLs with headers, details, hazmat messages, and freight terms. - Updates tracking files (BBORTO, BBORTOB, BBSRNH) to record BOL printing. - Supports numerous business rules for formatting, validation, and special cases (e.g., EDI, railcar, non-fluid products).

Files Used: 33 files, including BBTRAN, BBOTHS1, BBBLHS1, BBORTO, BBORTOB, BBSRNH, ARCUST, SHIPTO, and others. External Programs: MSHPADR, MINLBGL1.

If you need further details (e.g., specific field mappings, output format examples, or OCL interaction), let me know!