BB705P RPG36
The provided RPG program, BB705P.rpg36.txt, is written for the IBM System/36 and is called by the OCL program BB705P.ocl36.txt previously discussed. This RPG program generates a Pending Order Listing based on parameters such as location, container, date, and carrier. Below, I’ll explain the process steps, business rules, tables used, and any external programs called.
Process Steps of the RPG Program¶
The RPG program processes user input from a workstation screen, validates parameters, and prepares data for generating an open order listing. Here’s a step-by-step breakdown of the process:
- File and Data Definitions:
- Files:
SCREEN: A workstation file (display file) for user interaction, with a record formatSCREENused to prompt for input parameters.INLOC: A disk file (512 bytes, indexed, shared read mode) containing location data.BICONT: A disk file (256 bytes, indexed, shared read mode) containing company or container data.
- Data Structures:
COM: A table (array) with 5 elements, each 40 characters, used to store error messages (defined in the** COMsection at the end).UDS: User Data Structure for holding input parameters likeKYCO(company),KYLOC(location),KYFRDT(from date),KYTODT(to date),KYZEYN(zero date flag),KYJOBQ(job queue flag),KYCOPY(number of copies),FRDT8(8-digit from date),TODT8(8-digit to date),Y2KCEN(century for Y2K), andY2KCMP(comparison year for Y2K).
- Screen Input Fields (record format
SCREEN, NS 01):KYCO(company, positions 3-4)KYLOC(location, positions 5-7)KYFRDT(from date, positions 8-13)KYTODT(to date, positions 14-19)KYZEYN(zero date flag, position 20)KYJOBQ(job queue flag, position 21)KYCOPY(number of copies, positions 22-23)
-
File Input Fields:
INLOC: Fields likeILDEL(delete flag),ILCONO(company),ILLOC(location),ILNAME(location name).BICONT: Fields likeBCDEL(delete flag).
-
Initialization:
- Line 0040-0042: Set indicators
30,31,32,33,34,81,90,99to off to reset the program state. - Line 0043: Initialize
MSG(error message field) to blanks. -
Line 0045-0048: If indicator
09is on (first cycle), execute theONETIMsubroutine to set default values and exit:ONETIM(lines 0142-0152):- Sets
KYCOto 10,KYLOCto '001',KYZEYNto 'N',KYJOBQto 'N',KYCOPYto 1. - Sets indicator
81to display the screen. - Exits to the
ENDtag.
-
Main Processing Logic:
- Line 0050-0054: If indicator
KG(likely a cancel key) is on, set indicatorU8(cancel job), setLR(last record), and exit toEND. -
Line 0055-0057: If indicator
01is on (screen input received), execute theS1subroutine and exit toEND. -
S1 Subroutine (Validation Logic) (lines 0061-0140):
- Company Validation (lines 0063-0067):
- Chain (lookup)
BICONTusingKYCO. If not found (30on) or ifBCDEL= 'D' (deleted record), set error messageCOM,1("INVALID COMPANY NUMBER ENTERED") and indicators81,90. Jump toENDS1.
- Chain (lookup)
- Date Conversion for Y2K (lines 0069-0088):
- Convert
KYFRDTandKYTODT(6-digit dates, YYMMDD) to 8-digit formats (FRDT8,TODT8) by adding century: - Multiply dates by 10000.01 to shift format.
- Extract year (
FYY,TYY) and compare withY2KCMP(comparison year, e.g., 80 for 1980). - If year ≥
Y2KCMP, useY2KCEN(e.g., 19 for 1900s); else, add 1 toY2KCEN(e.g., 20 for 2000s). - Construct
FRDT8andTODT8(e.g., CCYYMMDD).
- Convert
- Location Validation (lines 0090-0095):
- Build
INKEYfromKYCOandKYLOC, then chainINLOC. If not found (99on), set error messageCOM,3("INVALID LOCATION ENTERED") and indicators81,90,32. Jump toENDS1.
- Build
- Zero Date Validation (lines 0098-0113):
- If
KYZEYN= 'Y' (allow zero dates), check ifFRDTorTODTis non-zero. If so, set error messageCOM,5("CANNOT ENTER DATE IF ZERO REQUEST = 'Y'") and indicators81,90,31. Jump toENDS1.
- If
- Date Range Validation (lines 0115-0119):
- If
FRDT8>TODT8, set error messageCOM,2("FROM DATE GREATER THAN TO DATE") and indicators81,90,31. Jump toENDS1.
- If
- Parameter Validation (lines 0122-0135):
- Check
KYZEYNfor valid values (' ', 'N', 'Y'). If invalid (33on), set error messageCOM,4("INVALID PARAMETER ENTERED - ' ', N OR Y") and indicators81,90. Jump toENDS1. - Check
KYJOBQfor valid values (' ', 'N', 'Y'). If invalid (34on), set error messageCOM,4and indicators81,90. Jump toENDS1.
- Check
-
Copy Count Adjustment (lines 0136-0138):
- If
KYCOPYis zero, set it to 1 (default number of copies).
- If
-
Screen Output (lines 0155-0164):
-
If indicator
81is on, display theSCREENfile with:- Program name (
BB705PFMin fieldK8). - Input fields (
KYCO,KYLOC,KYFRDT,KYTODT,KYZEYN,KYJOBQ,KYCOPY). - Error message (
MSG).
- Program name (
-
Program Termination:
- The program ends at the
ENDtag (line 0059) after processing or cancellation. - If validation fails, it redisplays the screen with an error message. If validation passes, it likely prepares data for the
BB705program (called by the OCL).
Business Rules¶
The RPG program enforces the following business rules for generating the pending order listing:
- Company Validation:
- The company number (
KYCO) must exist in theBICONTfile and not be marked as deleted (BCDEL ≠ 'D'). -
Invalid company triggers error message: "INVALID COMPANY NUMBER ENTERED".
-
Location Validation:
- The location (
KYLOC) combined withKYCOmust exist in theINLOCfile. -
Invalid location triggers error message: "INVALID LOCATION ENTERED".
-
Date Range Validation:
- The from date (
KYFRDT) must not be later than the to date (KYTODT) when converted to 8-digit format (FRDT8,TODT8). -
Invalid date range triggers error message: "FROM DATE GREATER THAN TO DATE".
-
Zero Date Handling:
-
If
KYZEYN= 'Y' (allow zero dates), bothKYFRDTandKYTODTmust be zero. Non-zero dates trigger error message: "CANNOT ENTER DATE IF ZERO REQUEST = 'Y'". -
Parameter Validation:
KYZEYN(zero date flag) must be ' ', 'N', or 'Y'.KYJOBQ(job queue flag) must be ' ', 'N', or 'Y'.-
Invalid values trigger error message: "INVALID PARAMETER ENTERED - ' ', N OR Y".
-
Copy Count:
-
If the number of copies (
KYCOPY) is zero, it is set to 1 to ensure at least one copy of the report is generated. -
Y2K Date Handling:
- Dates are converted from 6-digit (YYMMDD) to 8-digit (CCYYMMDD) format using a century calculation based on
Y2KCMPandY2KCENto handle dates before and after 2000 correctly.
Tables Used¶
- COM:
- Defined as an array (
Especification, line 0007) with 5 elements, each 40 characters. - Stores error messages listed at the end of the program:
COM,1: "INVALID COMPANY NUMBER ENTERED"COM,2: "FROM DATE GREATER THAN TO DATE"COM,3: "INVALID LOCATION ENTERED"COM,4: "INVALID PARAMETER ENTERED - ' ', N OR Y"COM,5: "CANNOT ENTER DATE IF ZERO REQUEST = 'Y'"
-
Used to display error messages on the screen when validation fails.
-
Files as Data Sources:
INLOC: Contains location data (fields:ILDEL,ILCONO,ILLOC,ILNAME). Functions as a table for validating location and company combinations.BICONT: Contains company or container data (field:BCDEL). Functions as a table for validating company numbers.
No additional RPG tables (e.g., TABxxx) are defined explicitly in the program.
External Programs Called¶
- BB705: Referenced in the screen output (line 0156,
K8 'BB705PFM') and likely called by the OCL program after validation. The RPG program prepares input parameters forBB705, which generates the actual pending order listing. - Note:
BB705PFMin the screen output suggests a display file or program name, but it aligns with theBB705program called in the OCL (JOBQ ?CLIB?,BB705orBB705 ,,,,,,,,?9?).
Summary¶
- Process Steps:
- Initialize indicators and clear error messages.
- On first cycle (
09), set default parameters viaONETIMand exit. - If cancel key (
KG) is pressed, cancel the job and exit. - On screen input (
01), validate parameters in theS1subroutine:- Check company (
BICONT), location (INLOC), date range, zero date flag, and parameter values. - Convert dates to 8-digit format for Y2K compliance.
- Set default copy count if zero.
- Check company (
- Display the screen with input fields and error messages if validation fails.
-
If validation passes, prepare parameters for the
BB705program called by the OCL. -
Business Rules:
- Validate company, location, date range, zero date flag, and parameter inputs.
- Ensure Y2K-compliant date handling.
- Default to one copy if none specified.
-
Display appropriate error messages for invalid inputs.
-
Tables Used:
COM: Array for error messages.-
INLOCandBICONT: Files used as data tables for validation. -
External Programs Called:
BB705: The program that generates the pending order listing, called by the OCL after validation.
If you have further details (e.g., the BB705 RPG code or file layouts for INLOC/BICONT), I can provide a deeper analysis. Let me know if you’d like me to search for related information or clarify anything!