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:
- Initialization:
- The program initializes by reading input files (
BBTRAN
,BBOTHS1
,BBBLHS1
, etc.) and setting up printer files (LIST
,LIST1
). - It retrieves system date (
UDATE
) for printing and initializes variables likePAGE
for pagination. - It processes the
U5
(order pick list time) orU6
(railcar BOL time) indicators to determine the type of BOL to print. - 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.
- Order Header Processing:
- Reads header records from
BBTRAN
,BBOTHS1
(forU5
), orBBBLHS1
(forU6
) based on the company (BOCO
) and order number (BORDNO
). - Validates the header record:
- Skips records marked as deleted (
BODEL = 'D'
) or with an error for EDI orders (BODEL = 'E'
forJB20
). - Checks the order process status (
BOORPR = 'H'
) to skip pick ticket printing (MG34
).
- Skips records marked as deleted (
- Retrieves additional header data, such as customer number (
BOCUST
), ship-to number (BOSHIP
), freight processor code (BOFPCD
), and shipment reference number (BOSRN
). - For multi-load orders (
BOMULO = 'Y'
), processes multiple shipments usingKYFS
(from SRN) andKYTS
(to SRN) to handle unique order-SRN combinations (JB07
,JB09
).
Purpose: Identifies valid orders and gathers header information for BOL printing.
- Customer and Shipment Data Retrieval:
- Chains to
ARCUST
andSHIPTO
to retrieve customer name (ARNAME
) and ship-to address (CSNAME
,CSADR1
, etc.). - Calls
MSHPADR
to get compressed ship-to address (DC01
,JB23
). - Retrieves freight processor details from
BBFRPR
(JB05
) and checks if the processor is internal or external (JB24
). - For EDI 856 orders (
JB13
), chains toEDICUS
,BBASNH
,BBASND
, andBBASNM
to retrieve shipper details and product descriptions. - Retrieves routing information from
TRRTCD
and container details fromGSCONT
,BICONT
, andGSCNTR1
(JK02
).
Purpose: Collects customer, ship-to, freight processor, and routing data for inclusion on the BOL.
- Detail Line Processing:
- Reads detail records from
BBTRAN
(NS 02) for order lines, checking for non-deleted records (BDDEL ≠ 'D'
). - Retrieves product details from
GSTABL
(orGSPROD
forJK04
) for descriptions (TBDESC
,TBSHDS
), hazmat codes (TBSMSG
), and gravity (TBGRAV
). - Determines container size based on container type (
BDCNTR
) fromGSCNTR1
(JK02
,JB18
):- If bulk, uses unit of measure (
BDIUM
) as size. - If packaged, uses container short description (
TBSHDS
).
- If bulk, uses unit of measure (
- 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
).
- Gross weight (
- Handles hazmat information from
GSHAZM
(HMSHD1
–HMSHD4
) for printing safety messages.
Purpose: Processes order line items, including product details, weights, and hazmat information for BOL details.
- Marks and Accessorials Processing:
- Reads marks records from
BBOTA1
(forU5
) orBBBLA1
(forU6
) for order remarks, invoice remarks, dispatch remarks, and BOL remarks (BXBMK1
–BXBMK4
). - Filters marks based on print flags (
BAPICK
,BABOL
,BADSPH
for dispatch marks,JB17
). - Processes freight processor address (
BXFRNM
,BXFRA1
–BXFRA3
) for printing on BOLs when applicable (JB06
,JB24
).
Purpose: Includes order-specific remarks and freight processor details on the BOL.
- BOL Printing:
- Outputs to
LIST
(regular BOL) andLIST1
(temporary PDF spooling,MG38
) using exception output records (PRTHDG
,PRTDTL
,PRTRIL
,PRTEID
,PRTTF
, etc.). - Prints header information:
- Company address (
BCADR1
,BCADR2
fromBICONT
,MG25
). - Order number with SRN (
BORDNOZ
–SRN
,JB07
,JB09
). - Customer, ship-to, and freight processor details.
- Batch number (
BOFAC1
–BOFAC2
,MG29
). - Routing codes (
BORTCD
,BORTG1
–BORTG3
,JB27
).
- Company address (
- 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
).
- Quantity (
- 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
).
- Freight terms (
Purpose: Generates formatted BOLs with all required header, detail, and footer information.
- File Updates:
- Updates
BBORTO
orBBORTOB
with the BOL printed flag (BOPBOL = 'Y'
) and SRN (HSRN
,JB07
). - Updates
BBSRNH
with the printed BOL indicator (SRPBOL = 'Y'
,JB15
) for tracking. - Uses exception output (
UPDTE
,UPDSRN
) to update these files.
Purpose: Records that the BOL has been printed and updates shipment tracking.
- Multi-Load and Overflow Handling:
- For multi-load orders (
BOMULO = 'Y'
), prints additional BOLs (PRTHD2
,PRTDT2
,PRTRI2
,PRTTF2
) with consistent fields (JB19
). - 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.
- EDI 856 (Viscosity) Handling:
- Checks
EDICUS
for customers with EDI 856 orders (EIIBOB = 'O'
) and processes data fromBBASNH
,BBASND
, andBBASNM
for custom product descriptions and FOB details (JB13
). - 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
).
- Order Validation:
- Skips deleted orders (
BODEL = 'D'
) or EDI orders with errors (BODEL = 'E'
,JB20
). -
Skips pick ticket printing for orders with
BOORPR = 'H'
(MG34
). -
Multi-Load Orders:
- Uses order number and SRN (
BORDNO
–SRN
) to uniquely identify shipments (JB07
,JB09
). -
Prints extra BOLs for multi-load orders with consistent formatting (
JB19
). -
Freight Processor Handling:
- Prints freight processor address (
FPNAME
,FPADR1
, etc.) only for external processors or customer/ARG third-party processors (JB06
,JB24
). -
Uses
FREIGHT ARRANGED BY
instead ofTHIRD PARTY FRT PROCESSOR
for clarity (JB11
). -
Container and Size Logic:
- Determines size based on container type (
BDFLCD
): bulk uses unit of measure, packaged uses container description (JB18
). -
Does not require
GSUMCV
records for units likeKG
,LI
,ML
,OZ
(JB30
,JB31
). -
Weight and Gallon Conversion:
- Calls
MINLBGL1
to calculate gallons or pounds directly, replacing earlier conversion logic (JB02
,JB26
). -
Supports non-fluid products by adjusting calculations (
VV04
). -
Hazmat and Messaging:
- Prints hazmat messages (
MSG,3
,MSG,4
) for dyed diesel/kero only when applicable (JB14
). - Includes DOT emergency response and CHEMTREC messages (
MSG,6
,MSG,7
) when required. -
Adds specific messages for PP destinations (
MSG,23
,MG36
). -
Formatting and Layout:
- Adjusts field positions to prevent printing off the page (
JB16
). - Removes blank lines for railcar BOL overflow (
JB39
). -
Prints compressed addresses via
MSHPADR
(DC01
,JB23
). -
Data Integrity:
- Updates
BBORTO
/BBORTOB
andBBSRNH
to track BOL printing (JB15
). -
Uses system date (
UDATE
) for printing and updates (MG42
). -
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
).
- Prints car capacity, outage, and temperature only when capacity is entered (
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!