BB953P RPG36
The provided document, BB953P.rpg36.txt, is an RPG (Report Program Generator) program written for an IBM System/36 or AS/400 environment. It is called from the OCL (Operation Control Language) program BB953P.ocl36.txt and is responsible for processing prompts for a customer rack pricing list. Below, I will explain the process steps, business rules, tables (files) used, and any external programs called.
Process Steps of the RPG Program¶
The RPG program BB953P is designed to validate user input for generating a customer rack pricing list. It processes data related to divisions, locations, product classes, containers, products, and date ranges, ensuring that the input parameters are valid before proceeding. The program uses a workstation file (SCREEN) for user interaction and performs validations against data stored in several files. Here’s a detailed breakdown of the process steps:
- Header and File Definitions:
- H-Spec: The header specification (
H P064) includes a program identifier (P064) and indicates the program is namedBB953P. - File Definitions (F-Specs):
SCREEN: A workstation file (512 bytes) for user interaction, likely a display file for input/output on a terminal.GSTABL: A disk file (256 bytes, indexed with 12 keys, typeCNTRCD), replaced byGSCNTR1per modificationJK01.INLOC: A disk file (512 bytes, indexed with 5 keys) for location data.BICONT: A disk file (256 bytes, indexed with 2 keys) for company/control data.GSCNTR1: A disk file (512 bytes, indexed with 3 keys), added perJK01to replaceGSTABLfor container data.GSPROD: A disk file (512 bytes, indexed with 6 keys), added perJK02to replace product code lookups inGSTABL.
- Array Definitions (E-Specs):
DCO: Array of 3 elements (35 bytes each) for company data.CTR: Array of 5 elements (3 bytes each) for container codes.LOC: Array of 5 elements (3 bytes each) for location codes.CLS: Array of 10 elements (3 bytes each) for product class codes.PRD: Array of 10 elements (4 bytes each) for product codes.COM: Array of 11 elements (40 bytes each) for error messages.
-
Input Specifications (I-Specs):
- Defines fields for the
SCREENfile, including keys for division (KYDIV), locations (KYLOSL,KYLOC1-5), product classes (KYPCSL,KYPC01-10), containers (KYCTSL,KYCT01-05), products (KYPDSL,KYPD01-10), date ranges (KYDTSL,KYFRDT,KYTODT), job queue (KYJOBQ), and copy count (KYCOPY). - Defines fields for
BICONT,INLOC,GSTABL,GSCNTR1, andGSPRODfiles, such as company number (BCCO), location code (ILLOC), descriptions (TBDESC,TPDESC), and delete flags (BCDEL,ILDEL,TPDEL). - User data structure (
UDS) defines additional fields for validation and processing.
- Defines fields for the
-
Initialization (C-Specs):
- Indicator Reset: Lines
0042-0045useSETOFto turn off indicators31-90, which are used for error handling and control flow. - Message Initialization: Line
0046clears theMSGfield (40 bytes) to ensure no residual error messages. -
KG Condition: If the
KGcondition (likely a program status or key indicator) is active:- Sets on indicators
U1andLR(last record, program termination). - Turns off indicators
01,09, and81. - Jumps to the
ENDtag, terminating the program.
- Sets on indicators
-
Main Processing Logic:
- Condition
09(Initial Run):- If indicator
09is on (likely set by the first input screen), theONETIMsubroutine is executed (line0052), and the program jumps toEND.
- If indicator
-
Condition
01(Main Validation):- If indicator
01is on (likely set by a subsequent screen input), theS1subroutine is executed (line0055), and the program jumps toEND.
- If indicator
-
ONETIM Subroutine (Lines
0160-0200): -
Initializes variables and sets default values for the pricing list prompt:
- Clears the
DCOarray (company data). - Sets
Xto 1 andBILIMto 00. - Positions the file pointer for
BICONTusingSETLL(line0165). - Reads
BICONTrecords in a loop (AGNCOtoENDCO): - Skips records marked for deletion (
BCDEL = 'D'). - Continues until the end of file (indicator
20). - Sets default values:
KYLOSL,KYDTSL,KYPDSL,KYPCSL,KYCTSLto'ALL'.KYDIVto'R'(division code).CTRto blanks.KYCOto 10 (company code).KYJOBQto'N'(no job queue).KYCOPYto 1 (one copy of the report).- Sets indicator
81to indicate the screen should be displayed.
- Clears the
-
S1 Subroutine (Lines
0062-0156): - Validates user input from the
SCREENfile for generating the rack pricing list:- Division Validation:
- Checks if
KYDIVis'R','L', or'B'(valid division codes). If invalid, sets indicators81,90, and29, moves error messageCOM,2("DIVISION MUST BE 'R' 'L' OR 'B'") toMSG, and jumps toENDS1. - Sets
KYDVNOto'00'for'R'or'50'for'L'. - Location Validation:
- If
KYLOSL = 'ALL', checks ifLOCFLD(concatenatedLOCarray) is blank. If not blank, sets error (COM,10: "CANNOT BE 'ALL' IF SELECTION IS MADE"). - If
KYLOSL = 'SEL', checks eachLOC,Xentry. If non-blank, chains toINLOCusingLOCKEY. If the record is not found (indicator41), sets error (COM,3: "INVALID LOCATION ENTERED"). - Product Class Validation:
- If
KYPCSL = 'ALL', checks ifCLS,1is blank. If not, sets error (COM,10). - If
KYPCSL = 'SEL', checks eachCLS,Xentry. If non-blank, chains toGSPROD(previouslyGSTABL) usingPRCLKY. If not found (indicator32), sets error (COM,5: "INVALID PRODUCT CLASS ENTERED"). - Container Validation:
- If
KYCTSL = 'ALL', checks ifCTFLD(concatenatedCTRarray) is blank. If not, sets error (COM,10). - If
KYCTSL = 'SEL', checks eachCTR,Xentry. If non-blank, chains toGSCNTR1usingW$CNTA. If not found (indicator33), sets error (COM,6: "INVALID CONTAINER CODE ENTERED"). - Product Validation:
- If
KYPDSL = 'ALL', checks ifPRD,1is blank. If not, sets error (COM,10). - If
KYPDSL = 'SEL', checks eachPRD,Xentry. If non-blank, chains toGSPRODusingKLPROD. If not found (indicator31), sets error (COM,4: "INVALID PRODUCT CODE ENTERED"). - Date Validation:
- If
KYDTSL = 'ALL', checks ifKYFRDTis zero. If not, sets error (COM,10). - If
KYDTSL = 'SEL', checks ifKYFRDTorKYTODTis zero. If so, sets errors (COM,7: "FROM DATE CANNOT BE BLANK" orCOM,8: "TO DATE CANNOT BE BLANK"). - Job Queue Validation:
- Checks if
KYJOBQis blank,'N', or'Y'. If invalid, sets error (COM,9: "ENTER BLANK, N OR Y"). - Copy Count:
- If
KYCOPYis zero, sets it to 1 (default number of copies). - Date Processing:
- Computes
KYDAT8(8-digit date) usingUDATE(system date) andY2KCEN(century indicator, 19 or 20 based onUYEARvs.Y2KCMP).
- Calls
SETINDsubroutine to set indicators based on the validation loop counterX. -
Jumps to
ENDS1if any validation fails. -
SETIND Subroutine (Lines
0160-0156): - Sets indicators (
21-30,51-60,61-65,42-46) based on the value ofX(loop counter) for product, product class, container, or location errors, respectively. -
Ensures the correct error indicators are set for display on the screen.
-
Output Specifications (O-Specs):
- Writes validated or default input fields to the
SCREENfile (formatBB953PFM) if indicator81is on. -
Outputs fields like
KYDIV,KYLOSL,KYLOC1-5,KYPCSL,KYPC01-10,KYCTSL,KYCT01-05,KYPDSL,KYPD01-10,KYDTSL,KYFRDT,KYTODT,KYJOBQ,KYCOPY, andMSG. -
Termination:
- The program terminates at the
ENDtag (line0058) after processing theONETIMorS1subroutines, ensuring all validations are complete and the screen is updated with results or errors.
Business Rules¶
The RPG program enforces the following business rules for the customer rack pricing list prompt:
- Division (
KYDIV): - Must be
'R','L', or'B'. Invalid values trigger error message"DIVISION MUST BE 'R' 'L' OR 'B'". -
Sets
KYDVNOto'00'for'R'or'50'for'L'. -
Location (
KYLOSL,KYLOC1-5): - If
KYLOSL = 'ALL', no specific locations (KYLOC1-5) can be entered (error:"CANNOT BE 'ALL' IF SELECTION IS MADE"). -
If
KYLOSL = 'SEL', at least one location (KYLOC1-5) must be non-blank and must exist in theINLOCfile (error:"INVALID LOCATION ENTERED"). -
Product Class (
KYPCSL,KYPC01-10): - If
KYPCSL = 'ALL', no specific product classes (KYPC01-10) can be entered (error:"CANNOT BE 'ALL' IF SELECTION IS MADE"). -
If
KYPCSL = 'SEL', at least one product class must be non-blank and must exist inGSPROD(error:"INVALID PRODUCT CLASS ENTERED"). -
Container (
KYCTSL,KYCT01-05): - If
KYCTSL = 'ALL', no specific containers (KYCT01-05) can be entered (error:"CANNOT BE 'ALL' IF SELECTION IS MADE"). -
If
KYCTSL = 'SEL', at least one container must be non-blank and must exist inGSCNTR1(error:"INVALID CONTAINER CODE ENTERED"). -
Product (
KYPDSL,KYPD01-10): - If
KYPDSL = 'ALL', no specific products (KYPD01-10) can be entered (error:"CANNOT BE 'ALL' IF SELECTION IS MADE"). -
If
KYPDSL = 'SEL', at least one product must be non-blank and must exist inGSPROD(error:"INVALID PRODUCT CODE ENTERED"). -
Date Range (
KYDTSL,KYFRDT,KYTODT): - If
KYDTSL = 'ALL', no specific dates can be entered (error:"CANNOT BE 'ALL' IF SELECTION IS MADE"). -
If
KYDTSL = 'SEL', bothKYFRDTandKYTODTmust be non-zero (errors:"FROM DATE CANNOT BE BLANK"or"TO DATE CANNOT BE BLANK"). -
Job Queue (
KYJOBQ): -
Must be blank,
'N', or'Y'(error:"ENTER BLANK, N OR Y"). -
Copy Count (
KYCOPY): -
If zero, defaults to 1.
-
Company Data:
- Reads
BICONTto skip deleted records (BCDEL = 'D'). -
Ensures valid company data is available before setting defaults.
-
Default Values:
- If no input is provided (initial run), sets defaults:
KYLOSL,KYDTSL,KYPDSL,KYPCSL,KYCTSLto'ALL',KYDIVto'R',KYCOto 10,KYJOBQto'N', andKYCOPYto 1.
- If no input is provided (initial run), sets defaults:
-
Error Handling:
- Uses the
COMarray to store error messages (e.g.,"INVALID LOCATION ENTERED","FROM DATE CANNOT BE BLANK"). - Sets indicators
81and90to display errors on the screen and halt processing.
- Uses the
Tables (Files) Used¶
The RPG program uses the following files (tables):
1. SCREEN: A workstation file (display file) for user input/output, defining fields like division, locations, product classes, containers, products, dates, job queue, and copy count.
2. BICONT: Contains company/control data (e.g., BCCO: company number, BCNAME: company name, BCDEL: delete flag).
3. INLOC: Contains location data (e.g., ILLOC: location code, ILNAME: location name, ILDEL: delete flag).
4. GSTABL: Originally used for product class/container lookups, now replaced by GSCNTR1 and GSPROD (contains TBDESC: table description, TBABDS: short description).
5. GSCNTR1: Contains container data (e.g., TCDESC: container description), added per modification JK01.
6. GSPROD: Contains product data (e.g., TPDESC: product description, TPPRGP: product group code, TPPRCL: product class code, TPABDS: short description), added per modification JK02.
External Programs Called¶
No external programs are explicitly called within the RPG program. The program operates independently, performing validations and screen updates within its own logic. However, it is invoked by the OCL program BB953P.ocl36.txt, which may queue or run a program named BB953. It’s unclear if BB953 is a separate program or a misnomer for BB953P, but within the RPG code, no external program calls (e.g., via CALL operations) are present.
Summary¶
The BB953P RPG program is a prompt validation program for a customer rack pricing list. It:
- Initializes variables and sets default values via the ONETIM subroutine.
- Validates user input for division, locations, product classes, containers, products, date ranges, job queue, and copy count via the S1 subroutine.
- Enforces business rules to ensure valid data, checking against files like INLOC, GSCNTR1, and GSPROD.
- Displays errors or validated data on the SCREEN file.
- Uses the SETIND subroutine to manage error indicators.
Tables (Files) Used:
- SCREEN
- BICONT
- INLOC
- GSTABL (replaced by GSCNTR1 and GSPROD)
- GSCNTR1
- GSPROD
External Programs Called: - None explicitly called within the RPG program.
The program ensures that user inputs are valid before proceeding with the pricing list generation, likely triggering further processing (e.g., report generation) via the OCL program or a subsequent job (BB953).