BB953 RPG36
The provided document, BB953.rpg36.txt
, is an RPG (Report Program Generator) program for an IBM System/36 or AS/400 environment. It is called by the OCL program BB953.ocl36.txt
and is responsible for generating the final rack price list report. The program processes records from the sorted temporary file BB9531
(labeled BB953S
in the OCL), retrieves additional data from reference files, and produces a formatted report on the printer (LIST
) and a disk file (OUTFILE
). The report displays the last two price changes for each product/container/unit of measure combination, formatted to fit within two print lines for easy customer quoting. Below, I will explain the process steps, business rules, tables (files) used, and any external programs called.
Process Steps of the RPG Program¶
The BB953
RPG program reads sorted records from BB9531
, performs lookups to enrich the data with company, location, product class, and container descriptions, and generates a formatted report. It handles page headers, detail lines, and separators, ensuring the output is concise and user-friendly. Here’s a detailed breakdown of the process steps:
- Header and File Definitions:
- H-Spec: The header specification (
H P064 BB953
) identifies the program asBB953
with a program identifierP064
. The comments describe its purpose: printing the last two price changes within a product/container/unit of measure, keeping data within two print lines. - File Definitions (F-Specs):
BB9531
: Primary input file (169 bytes, disk-based), containing sorted rack price data (labeledBB953S
in the OCL).BICONT
: Input file (256 bytes, indexed with 2 keys, record-address typeR
), for company data.GSTABL
: Input file (256 bytes, indexed with 12 keys, record-address typeR
), for product class and group descriptions.INLOC
: Input file (512 bytes, indexed with 5 keys), for location data.GSCNTR1
: Input file (512 bytes, indexed with 3 keys), for container descriptions (added perJK01
to replaceGSTABL
for container data).OUTFILE
: Output file (121 bytes, disk-based, append modeA
), for storing report data.LIST
: Printer file (164 bytes, overflow indicatorOF
), for printing the rack price list report.
- Array Definitions (E-Specs):
XXPR
: Array of 5 elements (9 bytes, 4 decimals) for current rack prices.XXQT
: Array of 5 elements (7 bytes, 0 decimals) for quantity levels.PRPR
: Array of 5 elements (9 bytes, 4 decimals) for previous rack prices (unused in output).SEP
: Array of 82 elements (2 bytes each) for printing separator lines (--
) between locations.QTY
: Array of 5 elements (10 bytes) for quantity headings.QTH
: Array of 10 elements (1 byte) for quantity heading flags.QT
: Array of 5 elements (1 byte) for beginning or ending quantity flags.BQT
: Array of 5 elements (1 byte) for beginning quantity flags.EQT
: Array of 5 elements (1 byte) for ending quantity flags.DESC
: Array of 4 elements (10 bytes) for delivery descriptions (e.g.,COLLECT
,PPD & ADD
).COM
: Array of 2 elements (15 bytes) for division descriptions (e.g.,REFINERY
,BLENDED LUBES
).ERR
: Array of 3 elements (30 bytes) for error messages (e.g.,NO PRODUCT CLASS LISTED
).
-
Input Specifications (I-Specs):
BB9531
: Defines fields likeXXCO
(company, pos 1-2),XXLOC
(location, pos 3-5),XXPRGR
(product group, pos 6-7),XXPROD
(product code, pos 8-11),XXCNTR
(container, pos 12-14),XXUNMS
(unit of measure, pos 15-17),XXQT
(quantity array, pos 18-52),XXPR,1-5
(current prices, pos 58-82),PRPR,1-5
(previous prices, pos 88-112),XXDES1
(full description, pos 113-132),XXDES2
(abbreviated description, pos 133-142),XXDATE
(date, pos 145-150),XXYY
(year, pos 145-146),XXMMDD
(month/day, pos 147-150),XXTIME
(time, pos 151-154),XXMINQ
(minimum quantity, pos 155-161),XXDIV
(division, pos 163-164),XXPRCL
(product class, pos 165-167),XXRKRQ
(rack required, pos 168, perJB04
),XXINAC
(inactive flag, pos 169, perJB04
).BICONT
: DefinesBCNAME
(company name, pos 4-33).GSTABL
: DefinesTBDES1
(complete description, pos 14-33) andTBDESC
(complete description, pos 14-43).INLOC
: DefinesILDEL
(delete flag),ILCONO
(company),ILLOC
(location),ILNAME
(location name).GSCNTR1
: DefinesTCDESC
(container description, pos 14-33, perJK01
).- Data Structures (DS): Define
QTYHDR
,QTH
,ENDQTY
,EQT
,BEGQTY
,BQT
for quantity formatting.
-
Initialization (Lines
0086-0089
): -
ONCE Check:
- If
ONCE = *ZERO
(first run), initializesSEP
array with--
for location separators and executesONETIM
subroutine. - Sets
ONCE
to prevent re-execution.
- If
-
ONETIM Subroutine (Not shown in truncated code but referenced):
-
Likely initializes variables, such as page counters, date/time fields (
SYDATEY
,SYTIME
), and other report formatting data. -
Main Processing Loop (Lines
0091-0123
): - Level Breaks:
- L5 (Company): Chains to
BICONT
usingXXCO
to retrieveBCNAME
(company name). If not found (indicator91
), setsBCNAME
to blanks. - L4 (Location): Builds
LOCKEY
(company + location) and chains toINLOC
to retrieveILNAME
(location name). If found (N91
), setsLOCNAM
; otherwise, sets to blanks. - L3 (Division): If
XXDIV = *ZEROS
, setsDIVNAM
toCOM,1
(REFINERY
); otherwise, sets toCOM,2
(BLENDED LUBES
). - L2 (Product Class): Builds
TBLKEY
with'PRODCL'
andXXCO + XXPRCL
, chains toGSTABL
to retrieveTBDESC
(product class description). If not found (93
), setsPRCLDS
toERR,1
(NO PRODUCT CLASS LISTED
); otherwise, sets toTBDESC
. Prints headers (PRTHDR
) and detail line (PRTLN2
). - L1 (Product/Container/Unit): Builds
TBLKEY
with'PRODGR'
andXXCO + XXPRGR
, chains toGSTABL
to retrieveTBDES1
(product group description). If not found (93
), setsGRPDSC
to blanks. Processes quantity and price data.
- L5 (Company): Chains to
- Container Description Lookup:
- Chains to
GSCNTR1
(perJK01
) to retrieveTCDESC
(container description).
- Chains to
-
Rack Required and Inactive Flags (per
JB04
):- Compares
XXRKRQ
to'N'
(sets indicator21
if true, indicating no rack price required). - Compares
XXINAC
to'I'
(sets indicator22
if true, indicating inactive). - Compares
XXINAC
to'B'
(sets indicator23
if true, indicating inactive but specific condition).
- Compares
-
Quantity and Price Formatting (Lines
0106-0218
, partial in truncated code): - REMBEG Subroutine (Lines
0221-0243
):- Removes leading zeros from quantity fields (
XXQT
) to formatQTY,1-4
for printing. - Loops through
BQT
array, skipping zeros, and constructsQT
array for display. - Calculates dash position for quantity ranges.
- Removes leading zeros from quantity fields (
- Formats quantities into
QTY
array for printing, ensuring clear presentation (e.g.,QTY,1
toQTY,4
). -
Processes
XXPR,1-4
(current prices) andXXMINQ
(minimum quantity) for output. -
Output Processing:
- Printer Output (
LIST
):- Headers (
PRTHDR
): - Prints program name (
BB953
), page number (PAGE
), company name (BCNAME
), report title (RACK PRICE LISTING
), division (DIVNAM
), location (XXLOC
,LOCNAM
), date (SYDATEY
), time (SYTIME
), and column headings (QUANTITY 1
,PRICE 1
, etc.). - Uses indicators
02
,03
,04
,05
,0
,1
to control header printing at different levels (overflow, company, location, division, etc.). - Detail Lines (
PRTLN1
,PRTLN2
): PRTLN1
: Prints product details (XXPROD
,XXDES1
,XXCNTR
,CNTDSC
,XXUNMS
), effective date (CURDAT
), time (CURTIM
), quantities (QTY,1-4
), prices (XXPR,1-4
), minimum quantity (XXMINQ
), and flags (XXRKRQ
,XXINAC
with labels likeRACK NOT REQ'D
,INACTIVE
,INACTIV BUT
).PRTLN2
: Prints product class (XXPRCL
,PRCLDS
) at levelL2
.- Separator (
PRTSEP
): PrintsSEP
(--
) between locations.
- Headers (
-
Disk Output (
OUTFILE
):- Writes records with fields like
XXCO
,XXLOC
,XXPRCL
,XXPROD
,XXDES1
,XXCNTR
,XXUNMS
,CURDT8
,CURTIM
,QTY,1-4
,XXPR,1-4
,XXMINQ
,XXRKRQ
,XXINAC
.
- Writes records with fields like
-
Termination:
- The program ends after processing all records, closing the printer and disk files.
Business Rules¶
The BB953
program enforces the following business rules for the rack price list report:
- Report Formatting:
- Displays the last two price changes for each product/container/unit of measure combination within two print lines for easy customer quoting.
-
Includes company, location, division, product class, product, container, unit of measure, quantities, prices, effective date, time, minimum quantity, and rack/inactive flags.
-
Data Enrichment:
- Retrieves company name (
BCNAME
) fromBICONT
usingXXCO
. - Retrieves location name (
ILNAME
) fromINLOC
usingXXCO + XXLOC
, skipping deleted records (ILDEL = 'D'
). - Retrieves product class description (
TBDESC
) fromGSTABL
using'PRODCL' + XXCO + XXPRCL
. If not found, uses error message (NO PRODUCT CLASS LISTED
). - Retrieves product group description (
TBDES1
) fromGSTABL
using'PRODGR' + XXCO + XXPRGR
. If not found, sets to blanks. -
Retrieves container description (
TCDESC
) fromGSCNTR1
usingXXCNTR
. -
Division Handling:
-
If
XXDIV = *ZEROS
, usesCOM,1
(REFINERY
); otherwise, usesCOM,2
(BLENDED LUBES
) for division name. -
Quantity and Price Formatting:
- Formats up to 4 quantity levels (
XXQT,1-4
) and prices (XXPR,1-4
) per record. - Removes leading zeros from quantities for clear presentation.
-
Prints minimum quantity (
XXMINQ
) and flags (XXRKRQ
,XXINAC
) to indicate special conditions. -
Special Flags (per
JB04
): - If
XXRKRQ = 'N'
, printsRACK NOT REQ'D
. - If
XXINAC = 'I'
, printsINACTIVE
. -
If
XXINAC = 'B'
, printsINACTIV BUT
. -
Error Handling:
- If lookups fail (e.g., company, location, product class, product group), uses default values (blanks or error messages).
-
Ensures invalid data does not halt the report but is flagged appropriately.
-
Output Consistency:
- Writes to both
LIST
(printer) for human-readable output andOUTFILE
(disk) for data retention. - Uses level breaks (
L1-L5
) to organize output by company, location, division, and product class.
Tables (Files) Used¶
The RPG program uses the following files (tables):
1. BB9531: Primary input file (169 bytes), containing sorted rack price data (labeled BB953S
in the OCL). Fields include XXCO
, XXLOC
, XXPRGR
, XXPROD
, XXCNTR
, XXUNMS
, XXQT
, XXPR
, XXDES1
, XXDES2
, XXDATE
, XXTIME
, XXMINQ
, XXDIV
, XXPRCL
, XXRKRQ
, XXINAC
.
2. BICONT: Input file for company data (e.g., BCNAME
).
3. INLOC: Input file for location data (e.g., ILCONO
, ILLOC
, ILNAME
, ILDEL
).
4. GSTABL: Input file for product class and group descriptions (e.g., TBDES1
, TBDESC
).
5. GSCNTR1: Input file for container descriptions (e.g., TCDESC
, added per JK01
).
6. OUTFILE: Output file (121 bytes) for storing report data.
7. LIST: Printer file (164 bytes) for the formatted rack price list report.
External Programs Called¶
No external programs are explicitly called within the BB953
RPG program. It operates independently, processing input from BB9531
, performing lookups in BICONT
, INLOC
, GSTABL
, and GSCNTR1
, and writing to OUTFILE
and LIST
. The program is invoked by the OCL program BB953.ocl36.txt
.
Summary¶
The BB953
RPG program generates the final rack price list by:
- Reading sorted records from BB9531
(labeled BB953S
).
- Enriching data with company (BICONT
), location (INLOC
), product class/group (GSTABL
), and container (GSCNTR1
) descriptions.
- Formatting quantities and prices, removing leading zeros, and handling special flags (XXRKRQ
, XXINAC
).
- Printing headers and detail lines to LIST
(printer) and writing records to OUTFILE
(disk).
- Using level breaks to organize output by company, location, division, and product class.
Tables (Files) Used:
- BB9531
(input)
- BICONT
(input)
- INLOC
(input)
- GSTABL
(input)
- GSCNTR1
(input)
- OUTFILE
(output)
- LIST
(printer output)
External Programs Called: - None
This program completes the rack price list workflow by producing a user-friendly report that summarizes the latest price changes, optimized for customer quoting.