BB9511 RPG36
The provided RPG/36 program, BB9511.rpg36.txt
, is a preprocessing program called by the BB951.ocl36.txt
OCL program to prepare data for the rack price list report. It processes the rack price master file (BBPRCE
), retrieves additional data from product and table files, and creates a temporary output file (BB9511
) with enriched data. Below, I’ll explain the process steps, business rules, tables/files used, and external programs called.
Process Steps of the RPG Program¶
The BB9511
RPG program reads records from the BBPRCE
file, validates and filters them, retrieves descriptive data from GSPROD
and GSTABL
, and writes processed records to the BB9511
output file. Here’s a detailed breakdown of the process steps:
- File and Data Structure Definitions:
- Files:
BBPRCE
: Input file (128 bytes, indexed, key length 27 bytes), the rack price master file.GSTABL
: Input file (256 bytes, indexed, key length 12 bytes), a table file for reference data (e.g., product class).GSPROD
: Input file (512 bytes, indexed, key length 6 bytes), a product file replacingGSTABL
for product code data (per revision JK01).BB9511
: Output file (166 bytes), a temporary file for processed rack price data.
- Arrays:
RKPR
(5 elements, 9.4): Stores rack prices fromBBPRCE
.RKQT
(5 elements, 7.0): Stores quantity levels fromBBPRCE
.HLPR
(5 elements, 9.4): Holds current rack prices for comparison.HLQT
(5 elements, 7.0): Holds current quantity levels for comparison.PRPR
(5 elements, 9.4): Stores previous prices (not used in output but initialized).
- Data Structures:
PRCEKY
(25 bytes): Key forBBPRCE
(not used in chaining but defined).- Unnamed DS (lines 0040–0048): Defines fields for a key structure (
CUPROD
,CUCNTR
,CUUNMS
,XXULO
,XXCYMD
,XXHHMM
). - Unnamed DS (lines 0236–0239): Defines date fields (
$CYMD
,$CN
,$YMD
) for date calculations. UDS
(User Data Structure): ContainsKYCO
(company number),Y2KCEN
(century, e.g., 19), andY2KCMP
(year comparison, e.g., 80).
-
Input Fields:
BBPRCE
: IncludesRKDEL
(delete flag),RKCONO
(company),RKLOC
(location),RKPROD
(product code),RKCNTR
(container),RKUNMS
(unit of measure),RKDATE
(date, CYMD),RKTIME
(time, HHMM),RKPR
(prices),RKQT
(quantities),RKMINQ
(minimum quantity),RKRKRQ
(rack price required),RKINAC
(inactive flag).GSTABL
: IncludesTBDEL
(delete flag),TBTYPE
(table type),TBCODE
(table code),TBPROD
(product),TBDESC
(description),TBDES1
(complete description),TBPRGP
(product group),TBPRCL
(product class),TBABDS
(short description),TBCSRT
(inventory sort code).GSPROD
: IncludesTPDEL
(delete flag),TPDESC
(description),TPDES1
(complete description),TPPRGP
(product group),TPPRCL
(product class),TPABDS
(short description).
-
Initialization and Date Calculation (Indicator
N09
): - Date Calculation (lines 0270–0287):
- Calculates today’s date (
UDATE
) in YYYYMMDD format (KYDAT8
): - Multiplies
UDATE
(MMDDYY) by 10000.01 to getKYDAT6
(YYMMDD). - Determines century (
UCN
): IfUYEAR
≥Y2KCMP
(80), usesY2KCEN
(19); else, adds 1 toY2KCEN
(e.g., 20). - Combines century and
KYDAT6
intoKYDAT8
. - Calculates date 30 days ago (
DT3AGO
): - Converts
KYDAT8
to$CYMD
(YYYYMMDD). - Extracts MMDDYY (
$YMD
), multiplies by 100.0001 to get MMDD.YY ($MDY
). - Calls
@GTOJ
to convert to Julian date (G$JD
). - Subtracts 31 days (
SUB 31 G$JD
). - Calls
@JTOG
to convert back to Gregorian date ($CYMD
). - Stores result in
DT3AGO
(YYYYMMDD). - Sets indicator
09
to prevent re-execution.
- Calculates today’s date (
-
Purpose: Ensures date calculations for filtering or reporting are ready.
-
Main Processing Loop (Level
L1
): - Skip Special Product (lines 0053–0054):
- If
RKPROD = '7287'
, setsYES = 'YES'
(likely a flag for special handling, but not used further).
- If
- Filter Deleted Records (lines 0055–0057):
- If
RKDEL = 'D'
, skips toEND
(ignores deleted records).
- If
- Filter by Company (lines 0060–0062):
- If
RKCONO ≠ KYCO
(company fromUDS
), skips toEND
.
- If
- Initialize Hold Fields (lines 0066–0069, JB02):
- Clears
HLQT
(quantity array),HLPR
(price array),PRPR
(previous price array),HLRKRQ
(rack required), andHLINAC
(inactive flag). - Sets
WRITIT = ' '
.
- Clears
- Retrieve Product Data (lines 0073–0077, JK01):
- Builds key
KLPROD
withRKCONO
andRKPROD
. - Chains to
GSPROD
usingKLPROD
. If not found (92
on), clearsTPDES1
,TPABDS
,TPPRGP
; else, movesTPDES1
toDES1
(20 bytes),TPABDS
toABDS
(10 bytes), andTPPRGP
toPRGP
(2 bytes).
- Builds key
- Retrieve Product Class Data (lines 0072–0077):
- Builds key
TBLKEY
with'PRODCL'
andTPPRCL
(product class fromGSPROD
). - Chains to
GSTABL
usingTBLKEY
. If found (N92
), movesTBCSRT
toCSRT
(inventory sort code); else, clearsCSRT
.
- Builds key
-
Set Write Flag (line 0083):
- Sets
WRITIT = 'Y'
to indicate the record should be written.
- Sets
-
Price and Quantity Comparison (lines 0085–0099, JB02):
- Compares current record’s prices (
RKPR,1
toRKPR,5
), quantities (RKQT
), rack required (RKRKRQ
), and inactive flag (RKINAC
) with hold arrays (HLPR
,HLQT
,HLRKRQ
,HLINAC
). -
If any differ (
10
on), updates hold arrays:- Moves
RKPR
toHLPR
. - Moves
RKQT
toHLQT
. - Moves
RKRKRQ
toHLRKRQ
. - Moves
RKINAC
toHLINAC
.
- Moves
-
Write Output Record (lines 0106–0108):
-
If
WRITIT = 'Y'
and levelL1
is active, writes toBB9511
using theADD951
exception output:RKCONO
(company, pos 1–2).RKLOC
(location, pos 3–5).PRGP
(product group, pos 6–7, binary).RKPROD
(product code, pos 8–11).RKCNTR
(container, pos 12–14).RKUNMS
(unit of measure, pos 15–17).HLQT
(quantity array, pos 18–52).HLPR
(price array, pos 53–82, packed).PRPR
(previous price array, pos 83–112, packed).DES1
(complete description, pos 113–132, binary).ABDS
(short description, pos 133–142, binary).RKDATE
(date, pos 143–150).RKTIME
(time, pos 151–154).RKMINQ
(minimum quantity, pos 155–161).HLRKRQ
(rack required, pos 163).HLINAC
(inactive flag, pos 164).CSRT
(inventory sort code, pos 165–166).
-
Date Conversion Subroutines:
- @GTOJ (lines 0320–0384):
- Converts Gregorian date (
$MDY
, MMDDYY;$CN
, century) to Julian date (G$JD
). - Breaks down
$MDY
into year, month, day. - Adjusts century if not provided (similar to initialization).
- Converts month and year to Julian days, adds day, and calculates day of week (
G$JW
).
- Converts Gregorian date (
-
@JTOG (lines 0388–0438):
- Converts Julian date (
G$JD
) to Gregorian date ($MDY
, MMDDYY;$CN
, century). - Calculates year, month, and day from Julian days, adjusting for leap years and month boundaries.
- Converts Julian date (
-
Program Termination:
- The program ends at the
END
tag (line 0102) after processing each record or skipping invalid ones, looping throughBBPRCE
until all records are processed.
Business Rules¶
The RPG program enforces the following business rules for preprocessing the rack price list:
- Record Filtering:
- Excludes deleted records (
RKDEL = 'D'
). -
Processes only records for the specified company (
RKCONO = KYCO
). -
Product Data Enrichment:
- Retrieves product description (
TPDES1
), short description (TPABDS
), and product group (TPPRGP
) fromGSPROD
usingRKCONO
andRKPROD
. -
If not found, uses blank values.
-
Product Class Data:
- Retrieves inventory sort code (
TBCSRT
) fromGSTABL
usingPRODCL
andTPPRCL
(product class fromGSPROD
). -
If not found, uses blank
CSRT
. -
Price and Quantity Tracking:
- Compares current record’s prices (
RKPR
), quantities (RKQT
), rack required (RKRKRQ
), and inactive flag (RKINAC
) with hold arrays. -
Updates hold arrays (
HLPR
,HLQT
,HLRKRQ
,HLINAC
) if differences are found, ensuring the latest values are written. -
Date Handling:
- Calculates today’s date and 30 days prior in YYYYMMDD format for potential filtering (though not explicitly used in filtering logic).
-
Handles century calculation for Y2K compliance (years ≥ 80 use 19xx, else 20xx).
-
Output Record:
- Writes only valid records (
WRITIT = 'Y'
) with enriched data (descriptions, sort code) toBB9511
. -
Includes company, location, product group, product, container, unit of measure, prices, quantities, descriptions, date, time, minimum quantity, rack required, and inactive flags.
-
Special Product Handling:
- Flags product code
'7287'
withYES = 'YES'
, but no further action is taken (possibly a legacy or debugging flag).
Tables/Files Used¶
The RPG program uses the following files:
1. BBPRCE (?9?BBPRCE
): Input rack price master file, containing company, location, product, container, unit of measure, prices, quantities, date, time, minimum quantity, rack required, and inactive flags.
2. GSTABL (?9?GSTABL
): Input table file, used for product class data (e.g., inventory sort code TBCSRT
).
3. GSPROD (?9?GSPROD
): Input product file, used for product descriptions, product group, and product class.
4. BB9511 (?9?BB9511
): Output temporary file, containing processed rack price data with enriched fields.
External Programs Called¶
The RPG program does not explicitly call any external programs. It performs file operations (CHAIN
, READ
, EXCPT
) and internal subroutines (@GTOJ
, @JTOG
) but does not invoke other programs. It is called by the BB951.ocl36.txt
OCL program as part of the rack price list process.
Summary¶
- Process Overview: The
BB9511
RPG program preprocesses theBBPRCE
rack price master file, filtering by company and non-deleted records, enriching with product data fromGSPROD
and product class data fromGSTABL
, and writing a temporary file (BB9511
) with prices, quantities, descriptions, and other fields for the rack price report. - Business Rules: Filters out deleted records and non-matching companies, retrieves product and class data, tracks price/quantity changes, and handles Y2K-compliant dates. Writes enriched records to
BB9511
. - Files/Tables:
BBPRCE
(input),GSTABL
(input table),GSPROD
(input product file),BB9511
(output). - External Programs: None called directly.
If you need further details (e.g., file structures, output format ADD951
, or interactions with other programs like BB951
or BB9518
), please provide them, or I can search for related information if desired!