BB9534 RPG
The provided document, BB9534.rpg.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 serves as a filtering step in the rack price list generation process. The program processes records from the temporary file BB9531 (created by BB9531.rpg36.txt) and writes a subset of records to another temporary file, BB9532, based on user-specified selection criteria for location, product class, container, and product. Below, I will explain the process steps, business rules, tables (files) used, and any external programs called.
Process Steps of the RPG Program¶
The BB9534 RPG program filters records from the input file BB9531 based on user prompts (e.g., location, product class, container, product) and writes valid records to the output file BB9532. It uses a series of subroutines to validate each criterion, ensuring only records matching the user’s selections are included. Here’s a detailed breakdown of the process steps:
- Header and File Definitions:
- H-Spec: The header specification (
H/TITLE ... BB9534) identifies the program asBB9534and describes its purpose: excluding data in the workfile based on sort criteria. - File Definitions (F-Specs):
BB9531: Primary input file (169 bytes, disk-based), containing preprocessed rack price data fromBB9531.rpg36.txt.BB9532: Output file (169 bytes, disk-based, append modeA), where filtered records are written.
- Array Definitions (E-Specs):
LOC: Array of 5 elements (3 bytes each) for location codes.CLS: Array of 10 elements (3 bytes each) for product class codes.CTR: Array of 5 elements (3 bytes each) for container codes.PROD: Array of 10 elements (4 bytes each) for product codes.
-
Input Specifications (I-Specs):
BB9531: Defines fields likeRKCONO(company, pos 1-2),RKLOC(location, pos 3-5),RKPROD(product code, pos 8-11),RKCNTR(container, pos 12-14),RKDIV(division, pos 163-164),RKPRCL(product class, pos 165-167),RKRKRQ(rack required flag, pos 168, added perJB01),RKINAC(inactive flag, pos 169, added perJB01), andRECORD(entire 169-byte record).- User Data Structure (UDS): Defines fields from user prompts, including:
KYDIV(division, pos 103)KYLOSL(location selection, pos 104-106,'ALL'or'SEL')KYLOC1-5(specific locations, pos 107-121, stored inLOCarray)KYPCSL(product class selection, pos 122-124,'ALL'or'SEL')KYPC01-10(specific product classes, pos 125-154, stored inCLSarray)KYCTSL(container selection, pos 155-157,'ALL'or'SEL')KYCT01-05(specific containers, pos 158-172, stored inCTRarray)KYPDSL(product selection, pos 173-175,'ALL'or'SEL')KYPD01-10(specific products, pos 176-215, stored inPRODarray)KYDTSL(date selection, pos 216-218)KYFRDT,KYTODT(from/to dates, pos 219-230)KYJOBQ(job queue, pos 231)KYCOPY(copy count, pos 232-233)KYDVNO(division number, pos 234-235)KYDAT8(8-digit date, pos 236-243)Y2KCEN(century, 19, pos 509-510)Y2KCMP(comparison year, 80, pos 511-512)
-
Main Processing Loop (Lines
0040-0054): - Indicator
01(Input Cycle):- For each record read from
BB9531, the program performs filtering based on user-specified criteria.
- For each record read from
- Initialization:
- Turns off indicators
50and51(used for validation control). - Sets indicator
52on (initial assumption that the record is valid).
- Turns off indicators
- Location Filtering:
- If
KYLOSL = 'SEL'(specific locations selected): - Turns off indicator
52(record is not valid until proven). - Executes
LOCSRsubroutine to check ifRKLOCmatches anyKYLOC1-5.
- If
- Product Class Filtering:
- If
KYPCSL = 'SEL': - Turns off indicator
52. - Executes
PRCLSRsubroutine to check ifRKPRCLmatches anyKYPC01-10.
- If
- Product Filtering:
- If
KYPDSL = 'SEL': - Turns off indicator
52. - Executes
PRODSRsubroutine to check ifRKPRODmatches anyKYPD01-10.
- If
- Container Filtering:
- If
KYCTSL = 'SEL': - Turns off indicator
52. - Executes
CNTRSRsubroutine to check ifRKCNTRmatches anyKYCT01-05.
- If
-
Validation Outcome:
- If indicator
51is on (any validation failed), skips toEND(record is not written). - If indicators
50or52are on (record passed all checks or no specific selections were made), writes the record usingEXCPTGOOD.
- If indicator
-
LOCSR Subroutine (Lines
0015): - Purpose: Validates if the record’s location (
RKLOC) matches any user-specified locations (KYLOC1-5). - Logic:
- Initializes indicator
50to off (record not valid yet). - Loops through
LOCarray (1 to 5): - If
50is on (match found), jumps toENDLOC. - If
LOC,X = RKLOC, sets50on (match found). - If no match (
N50), sets51on (validation failed).
- Initializes indicator
-
Outcome: Sets
50if a match is found; otherwise, sets51to skip the record. -
PRCLSR Subroutine (Lines
0015): - Purpose: Validates if the record’s product class (
RKPRCL) matches any user-specified product classes (KYPC01-10). - Logic:
- Initializes indicator
50to off. - Loops through
CLSarray (1 to 10): - If
50is on, jumps toENDPRC. - If
CLS,X = RKPRCL, sets50on. - If no match (
N50), sets51on.
- Initializes indicator
-
Outcome: Sets
50if a match is found; otherwise, sets51. -
CNTRSR Subroutine (Lines
0015): - Purpose: Validates if the record’s container (
RKCNTR) matches any user-specified containers (KYCT01-05). - Logic:
- Initializes indicator
50to off. - Loops through
CTRarray (1 to 5): - If
50is on, jumps toENDCTR. - If
CTR,X = RKCNTR, sets50on. - If no match (
N50), sets51on.
- Initializes indicator
-
Outcome: Sets
50if a match is found; otherwise, sets51. -
PRODSR Subroutine (Lines
0015): - Purpose: Validates if the record’s product code (
RKPROD) matches any user-specified products (KYPD01-10). - Logic:
- Initializes indicator
50to off. - Loops through
PRODarray (1 to 10): - If
50is on, jumps toENDPRD. - If
PROD,X = RKPROD, sets50on. - If no match (
N50), sets51on.
- Initializes indicator
-
Outcome: Sets
50if a match is found; otherwise, sets51. -
Output Writing (Lines
0016): - If indicators
50or52are on, executesEXCPTGOODto write the entire 169-byteRECORDtoBB9532. -
The output record is identical to the input record, preserving all fields (e.g.,
RKCONO,RKLOC,RKPROD,RKCNTR,RKDIV,RKPRCL,RKRKRQ,RKINAC). -
Termination:
- The program ends at the
ENDtag after processing each input record, either writing it toBB9532or skipping it based on validation.
Business Rules¶
The BB9534 program enforces the following business rules for filtering rack price records:
- Location Filtering:
- If
KYLOSL = 'ALL', all locations are included (no filtering). -
If
KYLOSL = 'SEL', the record’sRKLOCmust match one of the user-specified locations (KYLOC1-5). If no match, the record is excluded. -
Product Class Filtering:
- If
KYPCSL = 'ALL', all product classes are included. -
If
KYPCSL = 'SEL', the record’sRKPRCLmust match one of the user-specified product classes (KYPC01-10). If no match, the record is excluded. -
Container Filtering:
- If
KYCTSL = 'ALL', all containers are included. -
If
KYCTSL = 'SEL', the record’sRKCNTRmust match one of the user-specified containers (KYCT01-05). If no match, the record is excluded. -
Product Filtering:
- If
KYPDSL = 'ALL', all products are included. -
If
KYPDSL = 'SEL', the record’sRKPRODmust match one of the user-specified products (KYPD01-10). If no match, the record is excluded. -
Record Inclusion:
- A record is written to
BB9532only if it passes all applicable filters (i.e.,50or52is on). -
If any filter fails (indicator
51on), the record is skipped. -
Default Behavior:
-
If no specific selections are made (e.g.,
KYLOSL,KYPCSL,KYCTSL,KYPDSLare'ALL'), all records are written (52remains on). -
Data Preservation:
- The entire input record (169 bytes) is written unchanged to
BB9532if it passes validation, preserving fields like company, location, product, container, division, product class, rack required, and inactive flags.
Tables (Files) Used¶
The RPG program uses the following files (tables):
1. BB9531: Primary input file (169 bytes), containing preprocessed rack price data from BB9531.rpg36.txt. Fields include RKCONO, RKLOC, RKPROD, RKCNTR, RKDIV, RKPRCL, RKRKRQ, and RKINAC.
2. BB9532: Output file (169 bytes, append mode), where filtered records are written, preserving the same structure as BB9531.
External Programs Called¶
No external programs are explicitly called within the BB9534 RPG program. It operates independently, processing input from BB9531 and writing to BB9532. The program is invoked by the OCL program BB953.ocl36.txt, and its output is used by subsequent steps (e.g., #GSORT and BB953).
Summary¶
The BB9534 RPG program filters records from BB9531 to create BB9532 by:
- Reading each record from BB9531.
- Validating location (RKLOC), product class (RKPRCL), container (RKCNTR), and product (RKPROD) against user-specified selections (KYLOSL, KYPCSL, KYCTSL, KYPDSL) using subroutines LOCSR, PRCLSR, CNTRSR, and PRODSR.
- Writing valid records (entire 169-byte RECORD) to BB9532 if they pass all filters or if no specific selections are made.
- Skipping records that fail any filter.
Tables (Files) Used:
- BB9531 (input)
- BB9532 (output)
External Programs Called: - None
This program ensures that only records matching the user’s selection criteria are included in BB9532, which is then sorted by #GSORT and used by BB953 to generate the final rack price report.