Skip to content

BB750 RPG36

The document BB750.rpg36.txt is an RPG/36 program for the IBM System/36 or AS/400, responsible for generating a Detailed Open Railcar Bill of Lading (BOL) Listing by Order. It is called by the OCL program BB750.ocl36.txt when a detailed report is requested (i.e., when the KYDETL flag is 'Y' in BB750P.rpg36.txt). This program processes sorted BOL data and produces a detailed report with header, detail, and remark records. Below, I’ll explain the process steps, business rules, tables/files used, and external programs called.


Process Steps of the RPG Program

The BB750 RPG program processes BOL data from a sorted file (BB750S, renamed as BBBOL) and generates a detailed report using data from multiple reference files. It handles header records, detail line records, and various remark records, formatting them for output to a printer file (LIST). Here’s a step-by-step breakdown:

  1. Program Initialization:
  2. Header (H) Specification (Line 1):
    • Defines the program name (BB750) with option P064 (possibly a program version or parameter).
    • B indicates batch processing mode.
  3. File Specifications (F):
    • BBBOL: Input file (512 bytes), primary file for BOL data, sorted by #GSORT in BB750.ocl36.txt.
    • ARCUST: Indexed customer file (384 bytes, 8-byte key), used for customer data.
    • SHIPTO: Indexed ship-to file (2048 bytes, 11-byte key), used for shipping addresses.
    • GSCONT: Indexed control file (512 bytes, 2-byte key), used for system or configuration data.
    • BICONT: Indexed inventory control file (256 bytes, 2-byte key), used for railcar or company data.
    • GSCTUM: Indexed unit of measure file (64 bytes, 12-byte key), used for measurement data.
    • LIST: Output printer file (164 bytes), used to generate the report.
  4. Array Definitions (E):

    • AST: Array of 82 asterisks (2 occurrences) for formatting report separators.
    • HYP: Array of 82 hyphens (2 occurrences) for formatting report separators.
  5. Input Processing:

  6. Input Specifications (I):
    • Header Record (NS 01) (Lines starting at IBBBOL NS 01):
    • Fields include company number (BOCO), order number (BORDNO), sequence number (BORSEQ), customer number (BOCUST), ship-to number (BOSHIP), dates, railcar number (BOCAR#), carrier code (BOCACD), freight code (BOFRCD), etc.
    • Key fields for level breaks: positions 10-12 (BORSEQ) control record sequencing.
    • Detail Line Record (NS 02):
    • Fields include item number (BDITEM), location (BDLOC), product code (BDPROD), quantity (BDQTY), price (BDPRCE), unit of measure (BDUM), description (BDDESC), etc.
    • Order Entry Remarks (NS 04):
    • Fields include remark lines (BXOMK1 to BXOMK4) for order-related notes.
    • Invoice/Dispatch Remarks (NS 05):
    • Fields include invoice remarks (BXIMK1, BXIMK2), dispatch remarks (BXDSP1, BXDSP2), and others (partially truncated in the document).
  7. Level Breaks:

    • Uses L1 (level 1) for order-level breaks (based on BOCO and BORDNO).
    • Uses indicators 10, 11, 12 for record type identification (header, detail, remarks).
  8. HDR Subroutine (Header Processing):

  9. Order Type Validation (Lines starting at C BOTYPE COMP 'R' 27):
    • Checks if BOTYPE (order type) is 'R' (return) or, historically, 'M' (cash return, removed per change JB03).
    • Sets indicator 27 if true (used for conditional processing or output).
  10. Customer Lookup:
    • Chains to ARCUST using ARKEY (built from BOCO and BOCUST) to retrieve customer data (e.g., ARNAME, ARADR1ARADR4).
    • Sets indicator 52 if the customer record is not found.
  11. Ship-to Processing:
    • If BOSHIP is 0, uses customer data (ARNAME, ARADR1ARADR4) for ship-to fields (SNAM, SAD1SAD4) and sets indicator 99.
    • If BOSHIP is 999 or 900, uses a special key (KEY11) to chain to SHIPTO for ship-to data.
    • Calls MSHPADR (with parameters updated per DC01 and JB02) to retrieve compressed ship-to address (SNAM, SAD1SAD5, SCTY for country).
    • Sets indicators 70–72 based on non-blank address lines (SAD2SAD4) and 61 if SAD5 is non-blank.
  12. End of Subroutine:

    • Tags ARDSHP to mark the end of ship-to processing.
  13. Report Output (O Specifications):

  14. Outputs to the LIST printer file with various formats:

    • Page Header (D 102 L1):
    • Prints “OPEN RAILCAR BOL LISTING”, page number, date (SYDATEY), and time (SYTIME).
    • Order Header (D 21 L1, D 2 L1):
    • Prints company (BOCO), order number (BORDNO), railcar number (KRCCAR), order type (BOTYPE), customer number (BOCUST), customer name (ARNAME), ship-to number (BOSHIP), ship-to name (SNAM), and address lines (ARADR1ARADR4, SAD1SAD5).
    • Includes dates, carrier code (BOCACD), freight code (BOFRCD), PO numbers, terms (BOTERM), salesman (BOSLMN), and delivery flags.
    • Detail Lines (D 1 02 60):
    • Prints location (BDLOC), product code (BDPROD), quantity (BDQTY), price (BDPRCE), unit of measure (BDUM), no-charge code (BDNOCH), description (BDDESC), and total (BDTOT).
    • Miscellaneous Lines (D 1 03 60):
    • Prints miscellaneous quantities, amounts, G/L numbers, and descriptions for non-detail records.
    • Remarks (E 1 PRTOEM, PRTIVM, PRTBOM, PRTFRM):
    • Prints order entry remarks (BXOMK1BXOMK4), invoice remarks (BXIMK1, BXIMK2), dispatch remarks (BXDSP1, BXDSP2), and freight remarks (BXFRNM, BXFRA1BXFRA3).
    • Totals (T 1 L1, T 11 L1):
    • Prints order-level total (L1TOT) and a final asterisk separator.
  15. Program Flow:

  16. Reads BBBOL records sequentially, processing header records (NS 01), detail records (NS 02), and remark records (NS 04, NS 05).
  17. Uses level breaks (L1) to group output by order.
  18. Calls the HDR subroutine for each header record to populate customer and ship-to data.
  19. Outputs formatted data to the LIST file, including headers, details, remarks, and totals.

Business Rules

  1. Order Type Filtering:
  2. Processes orders with type 'R' (return) or, historically, 'M' (cash return, removed per JB03).
  3. Excludes deleted records (BODEL = 'D' or BDDEL = 'D'), as enforced by the sort in BB750.ocl36.txt.

  4. Customer and Ship-to Data:

  5. Retrieves customer name and address from ARCUST using company and customer number.
  6. For ship-to number 0, uses customer address; for 900 or 999, uses a special key to retrieve ship-to data from SHIPTO.
  7. Calls MSHPADR to format ship-to addresses, including country (SCTY per JB02).

  8. Report Structure:

  9. Groups output by order (company and order number) using level breaks (L1).
  10. Includes header details (company, order, customer, ship-to, railcar, etc.), detail lines (items, quantities, prices), and remarks (order, invoice, dispatch, freight).
  11. Prints totals for each order and formats the report with headers, separators (asterisks/hyphens), and page breaks.

  12. Data Validation:

  13. Ensures valid customer and ship-to data via CHAIN operations (indicators 52 and 53 for not found).
  14. Excludes non-relevant records via sort criteria (e.g., non-deleted records, specific company).

  15. Formatting:

  16. Uses compressed addresses from MSHPADR for ship-to data.
  17. Formats monetary fields (e.g., BOPAMT, BDPRCE) and quantities with specific decimal precision.
  18. Includes user-defined fields (BOVAR1, BOVAR2) and routing information (BORTG1, BORTG2).

Tables/Files Used

  1. BBBOL:
  2. Primary input file (512 bytes), sorted by #GSORT in BB750.ocl36.txt (renamed from BB750S).
  3. Contains header records (company, order, customer, ship-to, railcar, etc.), detail records (items, quantities, prices), and remark records (order, invoice, dispatch, freight).
  4. Fields include BOCO, BORDNO, BORSEQ, BOCUST, BOSHIP, BDLOC, BDPROD, BDQTY, BXOMK1BXOMK4, etc.

  5. ARCUST:

  6. Indexed customer file (384 bytes, 8-byte key).
  7. Used to retrieve customer name (ARNAME) and address (ARADR1ARADR4).
  8. Key: ARKEY (company + customer number).

  9. SHIPTO:

  10. Indexed ship-to file (2048 bytes, 11-byte key).
  11. Used to retrieve ship-to name (SNAM) and address (SAD1SAD5).
  12. Key: KEY11 (company, customer, order, or special code like '999').

  13. GSCONT:

  14. Indexed control file (512 bytes, 2-byte key).
  15. Likely used for system or configuration data (specific fields not referenced in the provided code).

  16. BICONT:

  17. Indexed inventory control file (256 bytes, 2-byte key).
  18. Likely used for railcar or company data validation (specific fields not referenced in the provided code).

  19. GSCTUM:

  20. Indexed unit of measure file (64 bytes, 12-byte key).
  21. Likely used for unit of measure data (BDUM) in detail records (specific fields not referenced in the provided code).

  22. LIST:

  23. Output printer file (164 bytes).
  24. Used to generate the formatted BOL listing with headers, details, remarks, and totals.

External Programs Called

  1. MSHPADR:
  2. Called in the HDR subroutine to retrieve compressed ship-to addresses.
  3. Parameters: KEY11 (input key), SNAM, SAD1SAD5 (address fields), SCTY (country, added per JB02).
  4. Purpose: Formats ship-to address data for the report.

Summary

  • Purpose: The BB750 RPG program generates a detailed Open Railcar BOL Listing by Order, processing sorted BOL data (BBBOL) and enriching it with customer (ARCUST), ship-to (SHIPTO), and other reference data to produce a formatted report (LIST).
  • Process Flow:
  • Initializes files and arrays.
  • Processes BBBOL records (header, detail, remarks) with level breaks (L1) for order grouping.
  • Validates customer and ship-to data using ARCUST and SHIPTO, calling MSHPADR for address formatting.
  • Outputs a detailed report to LIST, including order headers, detail lines, remarks, and totals.
  • Business Rules:
  • Filters for valid order types ('R') and non-deleted records.
  • Retrieves and formats customer and ship-to data, handling special cases (e.g., BOSHIP = 0, 900, 999).
  • Groups output by order and includes detailed item and remark information.
  • Files Used: BBBOL (input BOL data), ARCUST (customer), SHIPTO (ship-to), GSCONT (control), BICONT (inventory), GSCTUM (unit of measure), LIST (output report).
  • External Programs: MSHPADR (for ship-to address formatting).

If you have the code for MSHPADR or file layouts for BBBOL, ARCUST, etc., I can provide further details on specific field mappings or processing logic!