BB951P RPG36
The provided RPG program, BB951P.rpg36.txt, is an RPG/36 program designed for IBM System/36, called by the BB951P.ocl36.txt OCL program to manage rack price file updates, specifically tracking the last two price changes. Below, I’ll explain the process steps, business rules, tables/files used, and any external programs called, based on the RPG code.
Process Steps of the RPG Program¶
The RPG program BB951P processes user input from a workstation screen, validates it against various files, and prepares data for further processing (e.g., updating price files). Here’s a detailed breakdown of the process steps:
- File and Data Structure Definitions:
- Files:
SCREEN: A workstation file (display file) for user interaction, 512 bytes.BICONT: A disk file (256 bytes, indexed, shared read/modify) for company control data.INLOC: A disk file (512 bytes, indexed, shared read/modify) for location data.GSCNTR1: A disk file (512 bytes, indexed, shared read-only) for container control data (replacedGSTABLper revision JK01).GSPROD: A disk file (512 bytes, indexed, shared read/modify) for product data (replacedGSTABLfor product codes per revision JK02).
-
Data Structures:
DCO: An array (3 elements, 35 bytes each) to store company data.COM: An array (7 elements, 40 bytes each) for error messages.- Input specifications define fields from the screen (
SCREEN) and files (BICONT,INLOC,GSCNTR1,GSPROD), such as company number (KYCO), location ranges (KYLOFR,KYLOTO), product ranges (KYPRFR,KYPRTO), container ranges (KYCNFR,KYCNTO), job queue flag (KYJOBQ), copy flag (KYCOPY), and date ranges (KYFRDT,KYTODT). UDS(User Data Structure) holds key fields passed from the OCL program.
-
Initialization (Cycle Start):
- Indicator Setup (
C*lines 0024–0026): Resets indicators (32, 38, 40–48, 81, 90) toOFFto clear prior states. - Message Clearing (
MOVEL*BLANKS MSG): Initializes the message field to blanks. - KG (End of File) Condition (
C* KGlines 0029–0031):- If the end-of-file condition (
KG) is met, sets indicatorsU1(update) andLR(last record), clears indicators 01, 09, 81, and jumps to theENDtag, terminating the program.
- If the end-of-file condition (
-
Screen Input Processing:
- If indicator
09is on (initial screen read), theONETIMsubroutine is executed, and the program jumps toEND. - If indicator
01is on (subsequent screen read), theS1subroutine is executed, and the program jumps toEND.
- If indicator
-
ONETIM Subroutine (Lines 0073–0106):
- Purpose: Initializes data and populates the company array (
DCO) from theBICONTfile. - Steps:
- Clears the
DCOarray (MOVEL*BLANKS DCO). - Initializes index
Xto 1 and limitBILIMto 0. - Positions the file pointer at the beginning of
BICONT(SETLLBICONT). - Reads
BICONTrecords in a loop (AGNCOtoENDCO): - If a record’s
BCDELfield is'D'(deleted), skips to the next record. - Copies company number (
BCCO) and name (BCNAME) to theDCOarray at indexX. - Increments
Xuntil it exceeds 3 or the end ofBICONTis reached (20indicator). - Resets
KYCOto zeros, setsKYJOBQto'N', and setsKYCOPYto 1. - Sets indicator
81to signal output to the screen.
- Clears the
-
Output: Writes to the
SCREENfile with formatBB951PFM, displaying fields likeKYCO,DCO,KYLOFR,KYLOTO,KYPRFR,KYPRTO,KYCNFR,KYCNTO,KYJOBQ,KYCOPY,MSG,KYFRD8, andKYTOD8. -
S1 Subroutine (Lines 0043–0069):
- Purpose: Validates user input from the screen against the files and sets error messages if invalid.
-
Steps:
- Company Validation:
- If
KYCO(company number) is zero, sets indicators 32, 81, 90, moves error messageCOM,5("ENTER COMPANY NUMBER") toMSG, and jumps toENDS1. - Chains to
BICONTusingKYCO. If not found (32on) orBCDELis'D', sets indicators 81, 90, moves error messageCOM,2("INVALID COMPANY NUMBER ENTERED") toMSG, and jumps toENDS1. - Date Conversion (if
KYFRDTis non-zero): - Converts
KYFRDTandKYTODT(MMDDYY format) toKYFRD8andKYTOD8(YYYYMMDD format) by multiplying by 10000.01 and extracting year prefixes (FRYY,TOYY). - If the year is ≥ 80, prefixes with
19; otherwise, prefixes with20(e.g., 23 becomes 2023, 85 becomes 1985). - Location From Validation (if
KYLOFRis non-blank): - Builds key
INKEYwithKYCOandKYLOFR, chains toINLOC. If not found (40on), sets indicators 81, 90, moves error messageCOM,1("INVALID LOCATION ENTERED") toMSG, and jumps toENDS1. - Location To Validation (if
KYLOTOis non-blank): - Similar to
KYLOFR, chains toINLOCwithKYCOandKYLOTO. If not found (43on), sets error messageCOM,1and jumps toENDS1. - Product From Validation (if
KYPRFRis non-blank): - Builds key
KLPRODwithKYCOandKYPRFR, chains toGSPROD. If not found (41on), sets error messageCOM,3("INVALID PRODUCT CODE ENTERED") and jumps toENDS1. - Product To Validation (if
KYPRTOis non-blank): - Similar to
KYPRFR, chains toGSPRODwithKYCOandKYPRTO. If not found (44on), sets error messageCOM,3and jumps toENDS1. - Container From Validation (if
KYCNFRis non-blank): - Chains to
GSCNTR1usingKYCNFR. If not found (42on), sets error messageCOM,7("INVALID CONTAINER CODE") and jumps toENDS1. - Container To Validation (if
KYCNTOis non-blank): - Similar to
KYCNFR, chains toGSCNTR1withKYCNTO. If not found (45on), sets error messageCOM,7and jumps toENDS1. - Job Queue Validation:
- Checks if
KYJOBQis blank,'N', or'Y'. If not, sets error messageCOM,4("ENTER BLANK, N OR Y") and jumps toENDS1. - Copy Flag:
- If
KYCOPYis zero, sets it to 1. - Output: If any validation fails, indicators 81, 90 are set, and an error message is displayed. The program loops back to display the screen for user correction.
-
Program Termination:
- The
ENDtag is reached afterONETIM,S1, orKGconditions, terminating the program cycle. - The program outputs validated data to the
SCREENfile, which may be passed back to the OCL program for further processing (e.g., submittingBB951to a job queue).
Business Rules¶
The RPG program enforces the following business rules for validating user input to generate a rack price file report or update:
- Company Number (
KYCO): - Must be non-zero and exist in the
BICONTfile. - Must not be marked as deleted (
BCDEL ≠ 'D'). -
If invalid, displays "INVALID COMPANY NUMBER ENTERED" or "ENTER COMPANY NUMBER".
-
Location Range (
KYLOFR,KYLOTO): - If non-blank, must exist in the
INLOCfile for the given company (KYCO). -
If invalid, displays "INVALID LOCATION ENTERED".
-
Product Range (
KYPRFR,KYPRTO): - If non-blank, must exist in the
GSPRODfile for the given company (KYCO). -
If invalid, displays "INVALID PRODUCT CODE ENTERED".
-
Container Range (
KYCNFR,KYCNTO): - If non-blank, must exist in the
GSCNTR1file. -
If invalid, displays "INVALID CONTAINER CODE".
-
Job Queue Flag (
KYJOBQ): - Must be blank,
'N', or'Y'. -
If invalid, displays "ENTER BLANK, N OR Y".
-
Date Range (
KYFRDT,KYTODT): - If provided, converted from MMDDYY to YYYYMMDD format.
- Years ≥ 80 are prefixed with
19(e.g., 1985); years < 80 are prefixed with20(e.g., 2023). -
Stored in
KYFRD8andKYTOD8for output. -
Copy Flag (
KYCOPY): -
If zero, automatically set to 1 to ensure at least one copy is processed.
-
Company Data Population:
-
Up to three non-deleted companies from
BICONTare loaded into theDCOarray for display on the screen. -
Error Handling:
- Validation failures set indicators 81 (screen output) and 90 (error condition), display an error message, and prompt the user to correct input.
Tables/Files Used¶
The RPG program uses the following files (some of which are tables or data files):
1. SCREEN: Workstation file for user input/output, using format BB951PFM.
2. BICONT: Company control file (256 bytes, indexed), containing company number (BCCO), name (BCNAME), and deletion flag (BCDEL).
3. INLOC: Location file (512 bytes, indexed), containing company (ILCONO), location code (ILLOC), name (ILNAME), and deletion flag (ILDEL).
4. GSCNTR1: Container control file (512 bytes, indexed), used for validating container codes (KYCNFR, KYCNTO).
5. GSPROD: Product file (512 bytes, indexed), containing product description (TPDESC), deletion flag (TPDEL), and other fields (e.g., TPFLCD).
Note: The GSTABL file is commented out (per revisions JK01 and JK02), replaced by GSCNTR1 for container data and GSPROD for product data.
External Programs Called¶
The RPG program does not explicitly call any external programs. It interacts with the SCREEN file for user input/output and performs file operations (e.g., CHAIN, READ, SETLL) on the defined files. The OCL program (BB951P.ocl36.txt) calls BB951, which is likely this RPG program, but no additional programs are invoked within the RPG code itself.
Summary¶
- Process Overview: The
BB951PRPG program handles user input for generating or updating a rack price file, validating company, location, product, container, and job queue parameters against respective files. It initializes company data, performs date conversions, and enforces strict validation rules, displaying error messages for invalid inputs. The validated data is output to the screen and likely passed back to the OCL program for further processing (e.g., job queue submission). - Business Rules: Ensures valid company, location, product, and container codes, correct job queue flags, and proper date formatting. Automatically sets copy count and handles up to three companies.
- Files/Tables:
SCREEN,BICONT,INLOC,GSCNTR1,GSPROD. - External Programs: None called directly by the RPG program.
If you need further details (e.g., specific file structures, screen format BB951PFM, or additional context about the OCL interaction), please provide them, and I can refine the explanation. Alternatively, I can search for related information if you’d like!