BI944 RPG36
The provided document, BI944.rpg36.txt, is an RPG (Report Program Generator) program for the IBM System/36 environment (or AS/400 in compatibility mode), named BI944. It is invoked by the OCL script BI944B.ocl36.txt as part of the pricing generation process for blended lubes, initiated by PRICEGEN.clp. The program processes customer sales agreement price changes, updating the BB203W work file, generating reports (PRTDOWN, PRTEXCEL), and populating the BICUAGC file for CRM uploads. It incorporates multiple revisions to handle container codes, freight terms, and other pricing-related logic. Below, I will explain the process steps, business rules, tables used, and external programs called, noting that the document is truncated but sufficient to infer key functionality based on the provided input, output, and context .
Process Steps of the RPG Program¶
- File Definitions:
- Input Files:
BICUAGXX(IP, 263 bytes, disk): Primary input file, mapped to?9?BI944T(e.g.,ABI944T), containing sorted pricing agreement records fromBI9444.BICONT(IF, 256 bytes, indexed, disk): Contract file.BBPRCY(IF, 128 bytes, indexed, disk): Pricing history file.ARCUST(IF, 384 bytes, indexed, disk): Customer master file.GSTABL(IF, 256 bytes, indexed, disk): Table file for product class/division data.SHIPTO(IF, 2048 bytes, indexed, disk): Ship-to file.ARCUPR(IF, 80 bytes, indexed, disk): Customer price file.ARCUSP(IF, 1344 bytes, indexed, disk): Customer pricing file.INLOC(IF, 512 bytes, indexed, disk): Location file.BICUA7(IF, 261 bytes, indexed, disk): Indexed pricing file (replacesBICUA5per MG04).GSCTWT(IF, 64 bytes, indexed, disk): Contract weight file (added per JB12).GSUMCV(IF, 64 bytes, indexed, disk): Summary conversion file.GSCNTR1(IF, 512 bytes, indexed, disk): Container file (replacesGSTABLfor container codes per JK01).GSPROD(IF, 512 bytes, indexed, disk): Product file (replacesGSTABLfor product codes per JK02).
-
Output Files:
BB203W(O, 327 bytes, indexed, disk): Work file for updated pricing data.PRTDOWN(O, 164 bytes, printer): Report file for printed output.PRTEXCEL(O, 224 bytes, printer): Excel-compatible report file.BICUAGC(O, 271 bytes, disk, conditional on switchU3): Output file for CRM uploads.
-
Extension Specifications:
-
Arrays for processing:
SEP(79 elements, 2 bytes): Likely separators for report formatting.BAP(10 elements, 4 bytes): Stores product codes (BAPR01–BAPR10).BAD(10 elements, 10 bytes): Stores product descriptions.FLD(28 elements, 1 byte): Field indicators.CTY(26 elements, 1 byte): City/county codes.ST(2 elements, 1 byte): State codes.DESC(5 elements, 10 bytes): Freight descriptions (e.g., COLLECT, PPD & ADD).COM(2 elements, 15 bytes): Division descriptions (e.g., REFINERY, BLENDED LUBES).ERR(4 elements, 30 bytes): Error messages (e.g., NO PRODUCT CLASS LISTED).
-
Input Specifications (for
BICUAGXX,NS 01): - Key fields:
ARKEY(2–9): Company + customer number.BAP(13–52): Product codes (BAPR01–BAPR10).BADEL(1): Delete code.BACONOL7,CO(2–3): Company number.BACUSTL2,CUST(4–9): Customer number.BALOC(10–12): Location.BAPR01L3–BAPR10(13–52): Product codes.BASTDT(53–59),BAENDT(64–70): Start/end dates (YMD).BASTTM(60–63),BAENTM(71–74): Start/end times (HM).
-
Other fields include price (
BAPRCE), off-price (BAOFFP), quantities (BAMNGL,BAMXGL), indicators (BAPPD,BAALSH,BAPRIM,BADELV,BAFRCD), timestamps (BACRDT,BACRTM,BALUDT,BALUTM), container (BACNTR), ship-to (BASHIP), contract (BACNT#), and unit of measure (BAUNMS). -
Calculation Specifications (inferred due to truncation):
- Main Loop: Processes each
BICUAGXXrecord (01 DO). - Lookups:
- Chains
BICONTfor contract details using company number (CO). - Chains
ARCUSTfor customer name (ARNAME) usingARKEY. - Chains
SHIPTOfor ship-to data (e.g., freight terms, per JB08/MG09). - Chains
ARCUPRfor previous pricing, trying container type (BACNTR) first, then blank or 'P' for non-fluids (per JB05). - Chains
GSPRODfor product descriptions (BADarray, per JK02). - Chains
GSCNTR1for container details (per JK01). - Chains
GSCTWTfor gallons/container (per JB12, bypassingGSUMCVif found). - Chains
BICUA7for previous pricing data (per MG04).
- Chains
- Freight Logic (JB08, MG09, JB10):
- Uses
BAFRCDfromBICUAGXXfor freight description (FRTDSC, per MG09). - Handles special freight calculations for non-Bradford locations (e.g., Anchor) when
BAFRCD = 'C'(per JB10).
- Uses
- Date Handling:
- Uses
KYSTDT(new start date, per JB03) forBB203W. - Compares
BASTDT,BAENDT, andKYDAT8(fromBI944A) for validity.
- Uses
- Error Handling:
- Logs errors (e.g., missing product class, ship-to, or bad product) to
ERRarray.
- Logs errors (e.g., missing product class, ship-to, or bad product) to
- Output:
- Writes to
BB203Wwith updated pricing data (includingKYSTDT). - Writes to
PRTDOWNandPRTEXCELfor reports, including customer, product, price, freight, and quantity details. - Writes to
BICUAGC(ifU3switch is on) for CRM uploads (per MG05).
- Writes to
-
Counter: Increments
COUNTfor total records processed. -
Output Specifications:
- BB203W: Writes updated pricing records (327 bytes, including new start date).
- PRTDOWN (
D 2,01 38):- Fields: Product code (
BAP,1), description (BAD,1), customer (BACUSTZ,ARNAME), ship-to (BASHIPor 'ALL'), city/state (CTYST), container (BACNTR), prices (BAPRCEJ,PRVPRCJ,BAOFFPJ), location (BALOC), unit of measure (BAUNMS), freight terms (FRTDSC,FRTDIFper JB08), dates (STDT,ENDT), quantities (BAMNQYJ,BAMXQYJ). - Conditional formatting based on indicators (e.g.,
50,71,72,73).
- Fields: Product code (
- PRTEXCEL (
D 101,L7 39):- Header: Company name (
BCNAME), division (DIVNAM), date (SYSDAT), time (SYSTIM), page (PAGE1). - Detail: Similar to
PRTDOWN, with additional fields like new price (PRICE), start date (KYSTDT).
- Header: Company name (
- BICUAGC (
U3switch): Writes 271-byte records for CRM, including all pricing details.
Business Rules¶
- Purpose: Processes pricing agreements to update
BB203W, generate reports (PRTDOWN,PRTEXCEL), and populateBICUAGCfor CRM uploads, handling price changes, freight terms, and container-specific pricing. - Filtering and Validation:
- Excludes records with
BADEL = 'D'(deleted). - Validates ship-to (
SHIPTO), customer (ARCUST), and product (GSPROD) data. - Logs errors (e.g., missing ship-to, product class) to
ERRarray. - Previous Price Logic (JB02, JB05, MG04):
- Retrieves previous price from
ARCUPRusing container type (BACNTR), falling back to blank or 'P' for non-fluids. - Uses
BICUA7(indexed fromBICUAGX) for accurate previous pricing. - Freight Handling (JB08, MG09, JB10):
- Uses
BAFRCDfromBICUAGXXfor freight terms (e.g., COLLECT, PPD & ADD) per MG09, reversing JB08’s ship-to-based logic. - Special freight calculation for non-Bradford locations when
BAFRCD = 'C'(per JB10). - Gallons Calculation (JB12):
- Uses
GSCTWTfor gallons/container if available, bypassingGSUMCV. - Date Handling (JB03):
- Writes new start date (
KYSTDT) toBB203W. - Sets default end date (
00/00/00) if indicator50is on (no end date). - CRM Output (MG05):
- Populates
BICUAGConly whenU3switch is on (hourly CRM upload). - Context: Final step in
BI944B, building onBI9443andBI9444to produce final pricing data for blended lubes in?9?BICUAGP.
Tables (Files) Used¶
- BICUAGXX (
?9?BI944T): Input pricing agreements (263 bytes). - BICONT (
?9?BICONT): Contract data (shared). - BBPRCY (
?9?BBPRCY): Pricing history (shared read, record locking). - ARCUST (
?9?ARCUST): Customer master (shared read, record locking). - GSTABL (
?9?GSTABL): Product class/division (shared read, record locking). - SHIPTO (
?9?SHIPTO): Ship-to data (shared read, record locking). - ARCUPR (
?9?ARCUPR): Customer prices (shared read, record locking). - ARCUSP (
?9?ARCUSP): Customer pricing (shared read, record locking). - INLOC (
?9?INLOC): Location data (shared read, record locking). - BICUA7 (
?9?BICUA7): Indexed pricing (shared read, record locking). - GSCTWT (
?9?GSCTWT): Contract weights (shared read, record locking). - GSUMCV (
?9?GSUMCV): Summary conversions (shared read, record locking). - GSCNTR1 (
?9?GSCNTR1): Container data (shared). - GSPROD (
?9?GSPROD): Product data (shared). - BB203W (
?9?BB203?WS?): Work file output (shared). - PRTDOWN: Printed report output.
- PRTEXCEL: Excel-compatible report output.
- BICUAGC (
?9?BICUAGP): CRM output (shared, conditional onU3).
External Programs Called¶
- None: The program does not explicitly call external programs, performing all logic internally.
Additional Notes¶
- Context: Final step in
BI944B, processing sorted?9?BI944Tto produce?9?BICUAGP, reports, andBB203W. - Revisions:
- JB02 (2010): Enhanced previous price logic with container codes.
- JB03 (2012): Renamed work file, added new start date to
BB203W. - MG04 (2013): Replaced
BICUA5withBICUA7for pricing accuracy. - JB05 (2015): Added container type to
ARCUPRkey. - JK01 (2016): Used
GSCNTR1for container codes. - MG05 (2017): Added
BICUAGCfor CRM uploads. - JB08/MG09 (2018–2019): Switched freight code source between
SHIPTOandBICUAG. - JB10 (2020): Added freight calculation for non-Bradford locations.
- JK02 (2023): Used
GSPRODfor product codes. - JB12 (2024): Added
GSCTWTfor gallons calculation. - Truncation: The document is truncated, but output specifications and context provide sufficient detail. Missing calculations likely involve chaining, price comparisons, and freight logic.
- System/36: Runs in a System/36 environment, likely on AS/400.
- Error Handling: Uses
ERRarray for logging, relies on OCL for file errors.
If you have the full BI944.rpg36.txt or source code for BI942E or PRICES, I can refine the analysis. Please provide additional details or files if available!