BB101 RPG36
Process Steps of the RPG Program (BB101.rpgle.txt)¶
The RPG program BB101 is designed for the IBM System/36 environment and is called by the BB170 OCL procedure during batch deletion to reset counters or batch state. Its primary function is to facilitate the entry and update of open orders in the BBORDR file, with extensive validation and interaction via a workstation display file (SCREEN). The program supports complex order entry workflows, including header and detail management, product validation, freight processing, and integration with supplemental tables. The source includes a detailed revision history indicating enhancements for carrier validation, freight handling, customer-owned products, and more. Due to the truncation of the source (553,272 characters omitted), this analysis focuses on the provided header, file definitions, and comments, extrapolating likely process steps based on the context and revision notes. Below is a step-by-step breakdown of the inferred process:
- Initialization:
- The program initializes variables and clears error messages (based on typical RPG patterns).
- Sets up the local data area (UDS) for communication with the OCL, including fields like KYHDG (screen heading), CANCEL, PAR13C (order type), BATCH#, USER, WSID, PGM, and RECCNT.
-
Likely performs one-time setup (similar to BB001’s ONETIM subroutine) to prepare files and screen formats.
-
Interactive Screen Processing:
- Uses the SCREEN file (workstation, implied from comments) to display formats like BB101S2, BB101S3, BB101S9, and BB101SA for order entry, validation, and error display.
- BB101S9 (List Orders in Batch): Displays batch orders with fields like company (CO), order number (S9O), name (S9N), status (S9S), request date (S9R), and messages (MSG).
- BB101S2/S3: Likely header and detail entry screens, with fields for carrier ID, incoterms (DC02), freight arranged by, and product details.
-
BB101SA: Displays credit limit error messages (COM1, e.g., account on credit hold).
-
Order Header Validation:
- Validates company number (COM 01), customer number (COM 03), ship-to number (COM 04), order date (COM 05), pick-up date (COM 07), sales tax code (COM 08), salesman number (COM 09), terms code (COM 10), and sales G/L number (COM 11).
- Checks order type (COM 02, valid types: blank, M, R, P, J, T) and ensures it matches customer restrictions (COM 95).
-
For product move orders (PAR13C='PM'), enforces specific rules (COM 96, 97).
-
Order Detail Validation:
- Validates product code (COM 22), quantity (COM 13), price (COM 14), unit of measure (COM 15), and no-charge code (COM 16, ' ', 'N', 'Y').
- Ensures container codes are valid or blank (COM 30, 52) and checks container weight for packaged types (COM 54, JB21).
- Validates freight codes (COM 26, 27, 47-49, 57-67) and ensures consistency across detail lines.
-
For customer-owned products (JB11, JB15), forces no-charge ('Y') and bypasses tank validation.
-
Freight and Shipping:
- Validates carrier ID (COM 25, JB01) and freight arranged by (COM 73, JB09).
- Handles multi-load orders (COM 40-45, 86) and ensures valid pick-up/delivery dates (COM 68, 92, 93, 107, 108).
-
Supports incoterms for export orders (COM 78-80, DC02) and validates locations (COM 53, 99, 100).
-
Batch and Lock Management:
- Checks for batch locks (TABC/TABD, e.g., invoicing, modification, railcar BOL, shipping) and displays lockout messages (01-04).
-
Resets batch state during deletion (as called by BB170 OCL), likely clearing counters (RECCNT) or lock fields.
-
External Program Calls:
- Calls BB1014 to retrieve INLOC (inventory location) information (shared with BB495, BB500).
- Calls BB1011 for IMS (Inventory Management System) data, including fluid code and unit of measure.
-
Calls BB1015 for accessorials/marks from BBSHSA (JB13).
-
Output and File Updates:
- Updates BBORDR (order headers) and related files (BBORTR, BBOTHS, BBOTDS, BBOTA) with validated data.
- Writes supplemental records (JB07) and ship-to records (DC01, 901-999 range).
-
Outputs error messages (COM, COM1) to SCREEN for user correction.
-
Program Cycle:
- Loops via the RPG cycle for interactive input, validation, and correction until the order is saved or canceled.
- On batch deletion (OCL context), resets batch state and exits.
Business Rules¶
- Order Validation:
- Company, customer, ship-to, dates, and codes must exist in respective files (e.g., GSPREX, GSCTWT, GSTABL).
- Order type restricts customer eligibility (COM 95-97).
- Customer-owned products (JB11, JB15) bypass tank validation and enforce no-charge lines.
- Freight and Shipping:
- Freight codes must be consistent (C, P, A; COM 47-49) and align with delivery settings (COM 57-67).
- Multi-load orders require specific validations (COM 40-45, 86).
- Incoterms mandatory for export orders (COM 78-80, DC02).
- Batch Management:
- Locks prevent concurrent invoicing, modification, or shipping (TABC/TABD).
- Batch deletion resets counters and clears locks (OCL context).
- Error Handling:
- Over 100 error messages (COM 01-108, COM1) enforce data integrity.
- Overrides allowed for specific errors (e.g., F6 for product restrictions, F10 for holiday dates).
- EDI Orders:
- Special handling for EDI orders (JB19), including lockout checks and RACD validation.
- Data Integrity:
- Cross-references product codes (COM 77, JB19) and ensures description alignment (JB02).
- Validates container weights (COM 54, JB21) and group-by codes (COM 76, JB12).
Tables Used¶
Based on the header, revisions, and output specs: - BBORDR: Order header file (primary file for updates). - BBORTR: Order transaction file. - BBOTHS, BBOTHS1: Order header supplemental files. - BBOTDS, BBOTDS1: Order detail files. - BBOTA, BBOTA1: Auxiliary order files. - GSPREX: Product exception file (MG 090508). - GSCTWT: Non-fluid validation table (MG 090508). - GSTABL: Sales G/L and product code table (JB15). - BBSHSA: Accessorials/marks file (JB13). - INLOC: Inventory location file (via BB1014). - SCREEN: Workstation file for formats BB101S2, BB101S3, BB101S9, BB101SA. - SHPADR: Shipment address file (JB13).
External Programs Called¶
- BB1014: Retrieves INLOC (inventory location) data.
- BB1011: Retrieves IMS data (fluid code, unit of measure).
- BB1015: Retrieves accessorials/marks from BBSHSA.
The program is a complex order entry system with extensive validations, integrated with multiple files and programs to manage order creation and batch reset during deletion.