Skip to content

BB603N RPG

The RPG program BB603N.rpg.txt is called by the main OCL program (likely BB600.ocl36.txt) within the invoice posting workflow on an IBM System/36 or AS/400 environment. Its primary function is to create and update freight-related records for the Load Management System (LMS) by processing freight transaction records from the BBTRF file and writing them to FRBINF, FRBINH, FRORST, and other files. The program includes numerous revisions to handle specific freight scenarios, multi-loads, and tolerance tests, ensuring accurate freight data for invoices, including customer-owned product, third-party freight, and product movement transactions. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.


Process Steps of the BB603N RPG Program

The BB603N program reads freight transaction records from BBTRF, processes them based on specific conditions (e.g., freight processor code, transaction type, serial number), and writes to multiple freight-related files (FRBINF, FRBINH, FRORST, FRCINH2, FRBINA). It performs tolerance tests after each order and supports multi-load scenarios, ensuring accurate freight data for LMS integration.

Process Steps:

  1. File Initialization:
  2. The program opens the following files:

    • Input Files:
    • BBTRF: Primary input file (IP), 512 bytes per record, disk-based. Contains freight transaction records.
    • BBIBCH: Input file (IF), 512 bytes per record, 6-byte alternate index (AI), disk-based. Contains invoice batch header data.
    • BBIBCHX: Input file (IF), 512 bytes per record, disk-based. Contains additional invoice batch header data.
    • BBTRA1: Input file (IF), 512 bytes per record, disk-based. Contains additional transaction data.
    • BBTRANU: Input file (IF), 512 bytes per record, disk-based. Contains updated transaction data.
    • BBTRTX: Input file (IF), 512 bytes per record, disk-based. Contains transaction extension data.
    • Output Files (all disk-based, with add A or update capability):
    • FRBINF: Freight invoice file, 534 bytes per record, update capability (UA). Stores freight invoice details.
    • FRBINH: Freight invoice header file, 534 bytes per record, add capability (A). Stores freight invoice headers.
    • FRBINA: Freight invoice analysis file, add capability (A). Stores additional freight data (per MG24).
    • FRORST: Freight order status file, add capability (A). Stores order status updates.
    • FRCINH2: Freight control invoice header file, add capability (A). Stores control header updates.
  3. Record Processing (BBTRF):

  4. The program reads each record from BBTRF sequentially using the RPG cycle.
  5. Key fields extracted include:
    • BODEL: Delete flag ('D' for deleted records).
    • BOCO: Company number (3 bytes).
    • BORDNO: Order number (6 bytes).
    • BORSEQ: Header line sequence (3 bytes).
    • BOFPCD: Freight processor code (6 bytes).
    • BFOTYP: Order type (1 byte, e.g., 'R' for returns).
    • BFSRN: Serial number (3 bytes).
    • BFTSEQ: Transaction sequence (3 bytes, per JB16).
    • BFGGAL: Total gross gallons (9 bytes, per JB02).
    • BFOTFR: Override freight amount (9 bytes, per JB20).
    • BFMSFR: Miscellaneous freight amount (9 bytes, per JB21).
    • Additional fields for freight calculations (e.g., BFTWGT, BFTGAL, BFTQTY, BFLNHA, BFSCHA, etc.).
  6. The program processes each record to determine whether to write to FRBINF, FRBINH, FRBINA, FRORST, or FRCINH2 based on conditions like freight processor code, transaction type, and serial number.

  7. Tolerance Tests:

  8. After processing each order (per revision 11/2010), the program performs tolerance tests to validate freight data, ensuring accuracy before writing to output files.
  9. Specific details of the tests are not provided in the code snippet but likely involve checking quantities, weights, or freight amounts against predefined thresholds.

  10. Freight Record Creation and Updates:

  11. FRBINF Processing:
    • For each BBTRF record (per JB04), the program writes a record to FRBINF unless the record is deleted (BODEL = 'D') or a tax adjustment (per JB08).
    • Fields copied include BOCO, BORDNO, BFSRN, BFTSEQ, BFGGAL, BFOTFR, BFMSFR, and others (e.g., BFTWGT, BFTGAL, BFTQTY, etc.).
    • For multi-load orders (per LT09), the program handles multiple serial numbers (BFSRN) and updates FRBINF with appropriate freight amounts (BGTFAM, BFTFAM, CFTFAM, CSTFAM).
    • Override freight (BFOTFR, per JB20) and miscellaneous freight (BFMSFR, per JB21) are updated for both multi-load and non-multi-load orders (per JB22).
    • For freight-only invoices with P N N (prepaid, third-party, per JB13, JB15), records are created in FRBINF.
    • Serial number handling ensures BFSRN = '001' if zero (per JB11, JB14, JB18).
    • Quantities for type 'R' (returns) have their sign reversed (per JB12).
  12. FRBINH Processing:
    • Writes freight invoice header records, including carrier ID (BFCARR, per LT06).
    • Fields include BOCO, BORDNO, BFSRN, and others.
  13. FRBINA Processing (per MG24):
    • Writes invoice number (BOINV#) and other freight analysis data to FRBINA.
  14. FRORST Processing:
    • Writes order status records (STADD, STUPD) with fields like BOCO, BORDNO, SRN#, SVSRNM, BOFPCD, system date (SYDT), and test flags (TEST2, TTE3, TTE4).
    • Indicates active status with 'Y' at position 19.
  15. FRCINH2 Processing:

    • Writes control header updates (ALSTUP) with system date (SYDT) and active flag 'Y' at position 91.
  16. Special Freight Handling:

  17. Prepaid and Third-Party Freight (per JB01, JB13):
    • Initially, records for prepaid third-party freight or collect freight were not created (per JB01), but this was revised to include P N N freight-only invoices (per JB13, JB15).
  18. Collect Freight from Non-Bradford Locations (per JB23):
    • Handles special cases for freight collect (CNY) shipped from non-Bradford locations (e.g., Anchor), calculating freight appropriately.
  19. Multi-Load Support (per LT09):
    • Manages multiple serial numbers (BFSRN) for multi-load orders, ensuring correct freight family amounts (BFTFAM, CSTFAM).
  20. Field Initialization (per JB05):
    • Initializes new fields in FRBINF to ensure consistent data.
  21. Numeric FEGL (per JB19):

    • Ensures the FEGL field is numeric for accurate processing.
  22. Cycle Completion:

  23. The RPG cycle processes all records in BBTRF, matching with BBIBCH, BBIBCHX, BBTRA1, BBTRANU, and BBTRTX as needed, until the end of the file.
  24. Tolerance tests are performed after each order.
  25. The program terminates after writing all records to the appropriate output files, closing all files.

Business Rules

  1. Record Filtering:
  2. Deleted records (BODEL = 'D') and tax adjustments are not written to FRBINF (per JB08).
  3. Records are created for all BBTRF records regardless of freight processor code (per JB04, revising earlier restriction to BOFPCD = 'I').
  4. Prepaid third-party freight (P N N) and freight-only invoices are included (per JB13, JB15).

  5. Serial Number Handling:

  6. Serial numbers (BFSRN) are set to '001' if zero (per JB11, JB14, JB18) to ensure valid data.
  7. Multi-load orders are supported by handling multiple serial numbers (LT09).

  8. Freight Amount Updates:

  9. Override freight (BFOTFR, per JB20) and miscellaneous freight (BFMSFR, per JB21) are updated in FRBINF for both multi-load and non-multi-load orders (per JB22).
  10. Freight family amounts (BFTFAM, CSTFAM) are updated for multi-loads (per LT09).

  11. Quantity Sign for Returns:

  12. Quantities for transaction type 'R' (returns) have their sign reversed in FRBINF (per JB12).

  13. Tolerance Tests:

  14. Performed after each order to validate freight data (e.g., weights, quantities, amounts) against tolerances, ensuring accuracy (per 11/2010 revision).

  15. Special Freight Scenarios:

  16. Freight collect (CNY) from non-Bradford locations (e.g., Anchor) is calculated appropriately (per JB23).
  17. Freight-only invoices (P N N) are processed to include freight data (per JB15).

  18. Field Enhancements:

  19. Total gross gallons (BFGGAL) are copied to FRBINF (per JB02).
  20. Carrier ID (BFCARR) is output to FRBINH (per LT06).
  21. Invoice number (BOINV#) is written to FRBINA for analysis (per MG24).
  22. New fields are initialized (per JB05), and FEGL is ensured numeric (per JB19).

  23. No Error Handling:

  24. The program assumes input files (BBTRF, etc.) exist and contain valid data, and output files can be written to without issues.

  25. LMS Integration:

  26. The program creates and updates freight records for the Load Management System (LMS), ensuring compatibility with freight processing and invoice posting.

Tables (Files) Used

  1. BBTRF:
  2. Description: Freight transaction file.
  3. Attributes: 512 bytes per record, primary input file (IP), disk-based.
  4. Fields Used:
    • BODEL: Delete flag.
    • BOCO: Company number (3 bytes).
    • BORDNO: Order number (6 bytes).
    • BORSEQ: Header line sequence (3 bytes).
    • BOFPCD: Freight processor code (6 bytes).
    • BFOTYP: Order type (1 byte, e.g., 'R').
    • BFSRN: Serial number (3 bytes).
    • BFTSEQ: Transaction sequence (3 bytes, per JB16).
    • BFGGAL: Total gross gallons (9 bytes, per JB02).
    • BFOTFR: Override freight amount (9 bytes, per JB20).
    • BFMSFR: Miscellaneous freight amount (9 bytes, per JB21).
    • BFTWGT, BFTGAL, BFTQTY, BFLNHA, BFSCHA, BFTFAM, BFINSA, etc.: Freight-related fields.
  5. Purpose: Contains freight transaction data for invoice posting.
  6. Usage: Read sequentially to create/update freight records.

  7. BBIBCH:

  8. Description: Invoice batch header file.
  9. Attributes: 512 bytes per record, input file (IF), 6-byte alternate index, disk-based.
  10. Purpose: Provides batch header data for matching with BBTRF.
  11. Usage: Read to retrieve batch-related information.

  12. BBIBCHX:

  13. Description: Additional invoice batch header file.
  14. Attributes: 512 bytes per record, input file (IF), disk-based.
  15. Purpose: Provides supplemental batch header data.
  16. Usage: Read to support freight processing.

  17. BBTRA1:

  18. Description: Additional transaction file.
  19. Attributes: 512 bytes per record, input file (IF), disk-based.
  20. Purpose: Contains additional transaction data for freight processing.
  21. Usage: Read to match with BBTRF records.

  22. BBTRANU:

  23. Description: Updated transaction file.
  24. Attributes: 512 bytes per record, input file (IF), disk-based.
  25. Purpose: Contains updated transaction data.
  26. Usage: Read to support freight record updates.

  27. BBTRTX:

  28. Description: Transaction extension file.
  29. Attributes: 512 bytes per record, input file (IF), disk-based.
  30. Purpose: Contains extended transaction data.
  31. Usage: Read to provide additional freight-related data.

  32. FRBINF:

  33. Description: Freight invoice file.
  34. Attributes: 534 bytes per record, update file (UA), disk-based.
  35. Fields Used:
    • BOCO, BORDNO, BFSRN, BFTSEQ, BFGGAL, BFOTFR, BFMSFR, BFTWGT, BFTGAL, BFTQTY, BFLNHA, BFSCHA, BFTFAM, BFINSA, CFSCHG, CFRPUM, BFCAC2, BFCAC3, BFINSP, CFINSP, BFFTCN, BFMILE, etc.
  36. Purpose: Stores freight invoice details for LMS.
  37. Usage: Updated with BINFU, RELFU specifications for freight data.

  38. FRBINH:

  39. Description: Freight invoice header file.
  40. Attributes: 534 bytes per record, output file (O), add capability (A), disk-based.
  41. Fields Used:
    • BOCO, BORDNO, BFSRN, BFCARR (carrier ID, per LT06).
  42. Purpose: Stores freight invoice header data.
  43. Usage: Written with header records.

  44. FRBINA:

  45. Description: Freight invoice analysis file (per MG24).
  46. Attributes: Output file (O), add capability (A), disk-based.
  47. Fields Used:
    • BOINV#: Invoice number.
  48. Purpose: Stores freight analysis data, including invoice numbers.
  49. Usage: Written with analysis records.

  50. FRORST:

    • Description: Freight order status file.
    • Attributes: Output file (O), add capability (A), disk-based.
    • Fields Used:
    • BOCO, BORDNO, SRN#, SVSRNM, BOFPCD, SYDT, TEST2, TTE3, TTE4, active flag ('Y').
    • Purpose: Stores order status updates for freight processing.
    • Usage: Written with STADD, STUPD specifications.
  51. FRCINH2:

    • Description: Freight control invoice header file.
    • Attributes: Output file (O), add capability (A), disk-based.
    • Fields Used:
    • SYDT, active flag ('Y').
    • Purpose: Stores control header updates for freight processing.
    • Usage: Written with ALSTUP specification.

External Programs Called

The BB603N RPG program does not explicitly call any external programs. It is a self-contained program that processes input from BBTRF and related files and writes to freight-related output files.


Summary

The BB603N RPG program, called by BB600.ocl36.txt, supports the Load Management System (LMS) by: - Reading freight transaction records from BBTRF and matching with BBIBCH, BBIBCHX, BBTRA1, BBTRANU, and BBTRTX. - Writing records to FRBINF, FRBINH, FRBINA, FRORST, and FRCINH2 based on conditions like transaction type (BFOTYP), serial number (BFSRN), and freight processor code (BOFPCD). - Performing tolerance tests after each order to validate freight data. - Handling special cases like prepaid third-party freight (P N N), freight collect from non-Bradford locations (CNY), and multi-load orders. - Supporting enhancements for gross gallons, override freight, miscellaneous freight, and viscosity barcode data (per revisions JB01JB23, LT06, LT09, MG24). - Ensuring serial number accuracy and numeric fields (e.g., FEGL).

Tables Used: BBTRF (freight transactions), BBIBCH, BBIBCHX, BBTRA1, BBTRANU, BBTRTX (input files), FRBINF (freight invoices), FRBINH (freight headers), FRBINA (freight analysis), FRORST (order status), FRCINH2 (control headers). External Programs Called: None.

This program ensures accurate freight data for LMS integration, supporting invoice posting with robust handling of various freight scenarios and data validations.