BB9531 RPG36
The provided document, BB9531.rpg36.txt
, is an RPG (Report Program Generator) program for the IBM System/36 environment (or AS/400 in compatibility mode), named BB9531
. It is invoked by the OCL script BB953B.ocl36.txt
as part of the rack pricing process within the PRICES.ocl36.txt
workflow, which is itself called by PRICEGEN.clp
. The program preprocesses pricing data from the BBPRCE
file, enriches it with product and table data, and writes to a temporary file BB9531
for further processing in the rack price reporting sequence. 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 .
Process Steps of the RPG Program¶
- File Definitions:
- Input Files:
BBPRCE
(Input Primary,IP
, 128 bytes, indexed with 27-byte key, disk): Pricing history file, mapped to?9?BBPRCE
(e.g.,ABBPRCE
), containing rack price records.GSTABL
(Input,IF
, 256 bytes, indexed with 12-byte key, disk): Table file for product class and division data.GSPROD
(Input,IF
, 512 bytes, indexed with 6-byte key, disk): Product file for product details (added per JK01 revision).
-
Output File:
BB9531
(Output,O
, 169 bytes, disk): Temporary file, mapped to?9?BB9531
(e.g.,ABB9531
), for preprocessed pricing data.
-
Extension Specifications:
-
Arrays for storing pricing and quantity data:
RKPR
(5 elements, 9 bytes, 4 decimals): Rack prices (RKPR,1
toRKPR,5
).RKQT
(5 elements, 7 bytes, 0 decimals): Quantity levels.HLPR
(5 elements, 9 bytes, 4 decimals): Holding prices (current prices).HLQT
(5 elements, 7 bytes, 0 decimals): Holding quantities.PRPR
(5 elements, 9 bytes, 4 decimals): Previous prices.
-
Input Specifications:
- BBPRCE (record type
NS
):RKDEL
(1): Delete code ('D'
for deleted records).RKCONOL3
(2–3): Company number.RKLOC
(4–6): Location.RKPRODL1
(7–10): Product code.RKCNTRL1
(11–13): Container code.RKUNMSL1
(14–16): Unit of measure.RKDATE
(17–24): Date (CYMD format, CCYYMMDD).RKTIME
(25–28): Time (HHMM).RKPR,1
toRKPR,5
(30–58): Rack prices (packed, 4 decimals).RKMINQ
(59–65): Minimum quantity.RKQT
(66–100): Quantity level array.RKRKRQ
(101): No rack price required flag (added per JB03).RKINAC
(102): Inactive flag (b
,I
,B
, added per JB03).
- GSTABL (record type
NS 01
):TBDEL
(1): Delete code.TBPRCL
(127–129): Product class code.TBCSRT
(178–179): Inventory company sort (division code).TBPRGP
(121–122): Product group code.
-
GSPROD (record type
NS
, per JK01):TPDEL
(1): Delete code.TPDESC
(14–43): Product description.TPPRGP
(89–90): Product group code.TPPRCL
(127–129): Product class code.TPABDS
(145–154): Short description.
-
Calculation Specifications (partially shown due to truncation):
- Main Loop:
- Processes each
BBPRCE
record (01 DO
, implied).
- Processes each
- Filtering:
- Skips records with
RKDEL = 'D'
(deleted). - Applies selection criteria from the User Data Structure (UDS), set by
BB953B.ocl36.txt
: KYDIV
('ALL' or 'CO'): Filters by division.KYLOSL
('SEL'): Filters by locations (KYLOC1
–KYLOC5
).KYPCSL
('SEL'): Filters by product classes (KYPC01
–KYPC10
).KYCTSL
('SEL'): Filters by containers (KYCT01
–KYCT05
).KYPDSL
('SEL'): Filters by products (KYPD01
–KYPD10
).KYDTSL
('SEL'): Filters by date range (KYFRDT
toKYTODT
).
- Skips records with
- Lookups:
- Chains
GSPROD
usingRKPROD
to get product group (TPPRGP
), class (TPPRCL
), and short description (TPABDS
, per JK01). - Chains
GSTABL
for division (TBCSRT
) and product group (TBPRGP
).
- Chains
- Date Conversion (
$DATE
subroutine):- Converts
RKDATE
(CYMD) to Julian format (G$JD
) and back to Gregorian ($MDY
, MMDDYY): G$JD / 365.25
calculates year (G$YYWK
).- Adjusts for leap years and calculates day (
G$YD
), month (G$M
), and day of month (G$D
). - Combines into
$MDY
(MMDDYY) with century ($CN
).
- Converts
- Price and Quantity Processing:
- Moves
RKPR,1
–RKPR,5
toHLPR
(current prices). - Moves
RKQT
toHLQT
(quantity levels). - Likely retrieves previous prices (
PRPR
) from another file or logic (not shown).
- Moves
-
Output:
- Writes to
BB9531
viaADD951
exception output for valid records.
- Writes to
-
Output Specifications:
BB9531
(E
,ADD951
):RKCONO
(1–2): Company number.RKLOC
(3–5): Location.TPPRGP
(6–7): Product group (fromGSPROD
, per JK01).RKPROD
(8–11): Product code.RKCNTR
(12–14): Container code.RKUNMS
(15–17): Unit of measure.HLQT
(18–52): Quantity levels (5 elements).HLPR
(53–82): Current prices (5 elements, packed).PRPR
(83–112): Previous prices (5 elements, packed).DES1CP
(113–132): Product description (likely fromGSPROD
).ABDSCP
(133–142): Short description (fromGSPROD
).RKDATE
(143–150): Date (CYMD).RKTIME
(151–154): Time (HHMM).RKMINQ
(155–161): Minimum quantity.DIV
(162–164): Division code (fromGSTABL
).PRCL
(165–167): Product class (fromGSPROD
orGSTABL
).HLRKRQ
(168): No rack price required flag (fromRKRKRQ
, per JB03).HLINAC
(169): Inactive flag (fromRKINAC
, per JB03).
Business Rules¶
- Purpose: Preprocesses pricing data from
BBPRCE
to create a temporary file (BB9531
) with enriched rack price data, including product group, descriptions, division, and flags for rack price requirements and inactivity, for use in subsequent rack price reporting steps. - Filtering:
- Excludes deleted records (
RKDEL = 'D'
). - Applies filters based on UDS fields (set by
BB953B.ocl36.txt
):- Division (
KYDIV = 'ALL'
or specific company). - Locations (
KYLOSL = 'SEL'
, matchingKYLOC1
–KYLOC5
). - Product classes (
KYPCSL = 'SEL'
, matchingKYPC01
–KYPC10
). - Containers (
KYCTSL = 'SEL'
, matchingKYCT01
–KYCT05
). - Products (
KYPDSL = 'SEL'
, matchingKYPD01
–KYPD10
). - Date range (
KYDTSL = 'SEL'
,KYFRDT
toKYTODT
).
- Division (
- Data Enrichment:
- Retrieves product group (
TPPRGP
), class (TPPRCL
), and short description (TPABDS
) fromGSPROD
(per JK01). - Retrieves division (
TBCSRT
) fromGSTABL
. - Copies prices (
RKPR
toHLPR
), quantities (RKQT
toHLQT
), and previous prices (PRPR
). - Includes flags
RKRKRQ
andRKINAC
(per JB03). - Date Conversion:
- Converts
RKDATE
(CYMD) to Julian (G$JD
) and back to Gregorian ($MDY
, MMDDYY) for reporting or compatibility. - Context: Part of the
BB953B.ocl36.txt
workflow, producing?9?BB9531
forBB9534
, which is sorted and used byBB953
to generate the final rack price report (?9?RKPRCE
).
Tables (Files) Used¶
- BBPRCE (
?9?BBPRCE
): - Access: Input Primary (
IP
), shared read with record locking. - Purpose: Source of rack pricing data (company, location, product, container, prices, quantities).
- GSTABL (
?9?GSTABL
): - Access: Input (
IF
), shared read with record locking. - Purpose: Provides division (
TBCSRT
) and product group (TBPRGP
) data. - GSPROD (
?9?GSPROD
): - Access: Input (
IF
), shared read with record locking. - Purpose: Provides product group (
TPPRGP
), class (TPPRCL
), and description (TPABDS
,TPDESC
). - BB9531 (
?9?BB9531
): - Access: Output (
O
). - Purpose: Temporary file for preprocessed pricing data (169 bytes).
External Programs Called¶
- None: The
BB9531
RPG program does not call external programs or subroutines. It performs internal processing using the$DATE
subroutine for date conversion.
Additional Notes¶
- Context: Invoked by
BB953B.ocl36.txt
afterBB953B
, producing?9?BB9531
forBB9534
, which is sorted and used byBB953
for the rack price report. - Revisions:
- 02/16/00 (Jan Beccari): Rewritten to simplify and fix issues.
- JB03 (09/2012): Added
RKRKRQ
andRKINAC
fields to output. - JB04 (10/08/12): Fixed division selection (
KYDIV
). - JK01 (01/26/23): Replaced
GSTABL
withGSPROD
for product data. - System/36 Environment: Uses RPG II/III syntax, likely on AS/400.
- Truncation: The document is truncated, but output specifications and context provide sufficient detail. Missing calculations likely involve chaining
GSPROD
andGSTABL
and applying filters. - Error Handling: Relies on indicators and System/36 environment for error handling.
If you have the RPG source code for BB9534
, BB953
, or the SA505*
programs, or need further analysis, please provide those details! Let me know if you have additional questions or files to share.