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:
- Program Initialization:
- Header (H) Specification (Line 1):
- Defines the program name (
BB750) with optionP064(possibly a program version or parameter). Bindicates batch processing mode.
- Defines the program name (
- File Specifications (F):
BBBOL: Input file (512 bytes), primary file for BOL data, sorted by#GSORTinBB750.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.
-
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.
-
Input Processing:
- 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 (
BXOMK1toBXOMK4) 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).
- Header Record (NS 01) (Lines starting at
-
Level Breaks:
- Uses
L1(level 1) for order-level breaks (based onBOCOandBORDNO). - Uses indicators
10,11,12for record type identification (header, detail, remarks).
- Uses
-
HDR Subroutine (Header Processing):
- 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 changeJB03). - Sets indicator 27 if true (used for conditional processing or output).
- Checks if
- Customer Lookup:
- Chains to
ARCUSTusingARKEY(built fromBOCOandBOCUST) to retrieve customer data (e.g.,ARNAME,ARADR1–ARADR4). - Sets indicator 52 if the customer record is not found.
- Chains to
- Ship-to Processing:
- If
BOSHIPis 0, uses customer data (ARNAME,ARADR1–ARADR4) for ship-to fields (SNAM,SAD1–SAD4) and sets indicator 99. - If
BOSHIPis 999 or 900, uses a special key (KEY11) to chain toSHIPTOfor ship-to data. - Calls
MSHPADR(with parameters updated perDC01andJB02) to retrieve compressed ship-to address (SNAM,SAD1–SAD5,SCTYfor country). - Sets indicators 70–72 based on non-blank address lines (
SAD2–SAD4) and 61 ifSAD5is non-blank.
- If
-
End of Subroutine:
- Tags
ARDSHPto mark the end of ship-to processing.
- Tags
-
Report Output (O Specifications):
-
Outputs to the
LISTprinter 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 (ARADR1–ARADR4,SAD1–SAD5). - 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 (
BXOMK1–BXOMK4), invoice remarks (BXIMK1,BXIMK2), dispatch remarks (BXDSP1,BXDSP2), and freight remarks (BXFRNM,BXFRA1–BXFRA3). - Totals (T 1 L1, T 11 L1):
- Prints order-level total (
L1TOT) and a final asterisk separator.
-
Program Flow:
- Reads
BBBOLrecords sequentially, processing header records (NS 01), detail records (NS 02), and remark records (NS 04, NS 05). - Uses level breaks (
L1) to group output by order. - Calls the
HDRsubroutine for each header record to populate customer and ship-to data. - Outputs formatted data to the
LISTfile, including headers, details, remarks, and totals.
Business Rules¶
- Order Type Filtering:
- Processes orders with type
'R'(return) or, historically,'M'(cash return, removed perJB03). -
Excludes deleted records (
BODEL = 'D'orBDDEL = 'D'), as enforced by the sort inBB750.ocl36.txt. -
Customer and Ship-to Data:
- Retrieves customer name and address from
ARCUSTusing company and customer number. - For ship-to number 0, uses customer address; for 900 or 999, uses a special key to retrieve ship-to data from
SHIPTO. -
Calls
MSHPADRto format ship-to addresses, including country (SCTYperJB02). -
Report Structure:
- Groups output by order (company and order number) using level breaks (
L1). - Includes header details (company, order, customer, ship-to, railcar, etc.), detail lines (items, quantities, prices), and remarks (order, invoice, dispatch, freight).
-
Prints totals for each order and formats the report with headers, separators (asterisks/hyphens), and page breaks.
-
Data Validation:
- Ensures valid customer and ship-to data via
CHAINoperations (indicators 52 and 53 for not found). -
Excludes non-relevant records via sort criteria (e.g., non-deleted records, specific company).
-
Formatting:
- Uses compressed addresses from
MSHPADRfor ship-to data. - Formats monetary fields (e.g.,
BOPAMT,BDPRCE) and quantities with specific decimal precision. - Includes user-defined fields (
BOVAR1,BOVAR2) and routing information (BORTG1,BORTG2).
Tables/Files Used¶
- BBBOL:
- Primary input file (512 bytes), sorted by
#GSORTinBB750.ocl36.txt(renamed fromBB750S). - Contains header records (company, order, customer, ship-to, railcar, etc.), detail records (items, quantities, prices), and remark records (order, invoice, dispatch, freight).
-
Fields include
BOCO,BORDNO,BORSEQ,BOCUST,BOSHIP,BDLOC,BDPROD,BDQTY,BXOMK1–BXOMK4, etc. -
ARCUST:
- Indexed customer file (384 bytes, 8-byte key).
- Used to retrieve customer name (
ARNAME) and address (ARADR1–ARADR4). -
Key:
ARKEY(company + customer number). -
SHIPTO:
- Indexed ship-to file (2048 bytes, 11-byte key).
- Used to retrieve ship-to name (
SNAM) and address (SAD1–SAD5). -
Key:
KEY11(company, customer, order, or special code like'999'). -
GSCONT:
- Indexed control file (512 bytes, 2-byte key).
-
Likely used for system or configuration data (specific fields not referenced in the provided code).
-
BICONT:
- Indexed inventory control file (256 bytes, 2-byte key).
-
Likely used for railcar or company data validation (specific fields not referenced in the provided code).
-
GSCTUM:
- Indexed unit of measure file (64 bytes, 12-byte key).
-
Likely used for unit of measure data (
BDUM) in detail records (specific fields not referenced in the provided code). -
LIST:
- Output printer file (164 bytes).
- Used to generate the formatted BOL listing with headers, details, remarks, and totals.
External Programs Called¶
- MSHPADR:
- Called in the
HDRsubroutine to retrieve compressed ship-to addresses. - Parameters:
KEY11(input key),SNAM,SAD1–SAD5(address fields),SCTY(country, added perJB02). - Purpose: Formats ship-to address data for the report.
Summary¶
- Purpose: The
BB750RPG 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
BBBOLrecords (header, detail, remarks) with level breaks (L1) for order grouping. - Validates customer and ship-to data using
ARCUSTandSHIPTO, callingMSHPADRfor 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!