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 (replacesBICUA5
per 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 (replacesGSTABL
for container codes per JK01).GSPROD
(IF
, 512 bytes, indexed, disk): Product file (replacesGSTABL
for 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
BICUAGXX
record (01 DO
). - Lookups:
- Chains
BICONT
for contract details using company number (CO
). - Chains
ARCUST
for customer name (ARNAME
) usingARKEY
. - Chains
SHIPTO
for ship-to data (e.g., freight terms, per JB08/MG09). - Chains
ARCUPR
for previous pricing, trying container type (BACNTR
) first, then blank or 'P' for non-fluids (per JB05). - Chains
GSPROD
for product descriptions (BAD
array, per JK02). - Chains
GSCNTR1
for container details (per JK01). - Chains
GSCTWT
for gallons/container (per JB12, bypassingGSUMCV
if found). - Chains
BICUA7
for previous pricing data (per MG04).
- Chains
- Freight Logic (JB08, MG09, JB10):
- Uses
BAFRCD
fromBICUAGXX
for 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
ERR
array.
- Logs errors (e.g., missing product class, ship-to, or bad product) to
- Output:
- Writes to
BB203W
with updated pricing data (includingKYSTDT
). - Writes to
PRTDOWN
andPRTEXCEL
for reports, including customer, product, price, freight, and quantity details. - Writes to
BICUAGC
(ifU3
switch is on) for CRM uploads (per MG05).
- Writes to
-
Counter: Increments
COUNT
for 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 (BASHIP
or 'ALL'), city/state (CTYST
), container (BACNTR
), prices (BAPRCEJ
,PRVPRCJ
,BAOFFPJ
), location (BALOC
), unit of measure (BAUNMS
), freight terms (FRTDSC
,FRTDIF
per 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 (
U3
switch): Writes 271-byte records for CRM, including all pricing details.
Business Rules¶
- Purpose: Processes pricing agreements to update
BB203W
, generate reports (PRTDOWN
,PRTEXCEL
), and populateBICUAGC
for 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
ERR
array. - Previous Price Logic (JB02, JB05, MG04):
- Retrieves previous price from
ARCUPR
using 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
BAFRCD
fromBICUAGXX
for 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
GSCTWT
for gallons/container if available, bypassingGSUMCV
. - Date Handling (JB03):
- Writes new start date (
KYSTDT
) toBB203W
. - Sets default end date (
00/00/00
) if indicator50
is on (no end date). - CRM Output (MG05):
- Populates
BICUAGC
only whenU3
switch is on (hourly CRM upload). - Context: Final step in
BI944B
, building onBI9443
andBI9444
to 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?BI944T
to 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
BICUA5
withBICUA7
for pricing accuracy. - JB05 (2015): Added container type to
ARCUPR
key. - JK01 (2016): Used
GSCNTR1
for container codes. - MG05 (2017): Added
BICUAGC
for CRM uploads. - JB08/MG09 (2018–2019): Switched freight code source between
SHIPTO
andBICUAG
. - JB10 (2020): Added freight calculation for non-Bradford locations.
- JK02 (2023): Used
GSPROD
for product codes. - JB12 (2024): Added
GSCTWT
for 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
ERR
array 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!