BI944P RPG36
The RPG program BI944P.rpg36.txt is an RPG/400 program designed to prompt users for input parameters and validate them for generating a Customer Sales Agreement Master File Listing. It is called from the OCL program BI944P.ocl36.txt and interacts with a display file (SCREEN) and several database files to validate user inputs such as divisions, locations, customers, products, and units of measure. 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 is structured to handle user input through a workstation display file (SCREEN) with two screens (BI944PS1 and BI944PS2) and validate the input data against database files. The program uses subroutines to perform one-time initialization, validate inputs, and handle date editing. Here’s a detailed breakdown of the process steps:
- Program Initialization (Lines 0042–0050):
- Indicator Reset: The program starts by resetting multiple indicators (31–90) used for error handling and control flow (
SETOFstatements). - Blank Message: Initializes the
MSGfield to blanks to clear any prior error messages (MOVEL*BLANKS MSG). -
KG Indicator Check: If the
KGindicator (keyboard error or cancel) is on, the program sets indicatorsU1andLR(last record), resets indicators 01, 09, 81, and 82, and branches to theENDtag, effectively terminating the program. -
One-Time Setup Subroutine (
ONETIM, Lines 0160–0200): - Execution Condition: Executed when indicator 09 is on, typically on the first program call.
- System Time and Date: Captures the current system time and date (
TIMEoperation) intoSYSTIMandSYSDAT. - Clear Arrays: Initializes the
DCOarray to blanks. - Set Counter: Sets loop counter
Xto 1 andBILIMto 00 for file positioning. - Read Control File (
BICONT):- Positions the file pointer at the beginning (
SETLL BICONT). - Reads records sequentially (
READ BICONT). - Skips records marked as deleted (
BCDEL = 'D') by looping back toAGNCO. - Stops reading at end-of-file (indicator 20).
- Positions the file pointer at the beginning (
- Default Values: Sets default selection parameters to
'ALL'forKYLOSL(locations),KYSMSL(salesmen),KYPDSL(products),KYPCSL(product classes),KYCSSL(customers), andKYUMSL(units of measure). SetsKYDIVto'R',KYJOBQ,KYSPRD, andKYADDAto'N', andKYCOPYto 1. - Indicator Setup: Sets indicator 81 on to signal successful initialization.
-
Exit: Branches to
ENDafter execution. -
Screen 1 Processing Subroutine (
S1, Lines 0062–0156): - Execution Condition: Triggered when indicator 01 is on, corresponding to the first screen (
BI944PS1) submission. - Validate Selection Fields:
- Checks fields like
KYLOSL,KYPCSL,KYCSSL,KYPDSL,KYSMSL, andKYUMSLfor values'ALL'or'SEL'. If neither, sets error indicators 81 and 90, moves an error message from theCOMarray (e.g.,COM,1for invalid selection), and branches toENDS1. - For
'ALL', ensures no specific selections are entered (e.g.,LOC,CLS,CS,PRD) by comparing them to blanks. If non-blank, sets error indicators and assigns messageCOM,10. - For
'SEL', ensures specific selections are provided (non-blank). If blank, sets error indicators and assigns messageCOM,11.
- Checks fields like
- Division Validation:
- Checks
KYDIVfor valid values ('R','L', or'B'). If invalid, sets error indicators and assignsCOM,2. - Sets
KYDVNOto'00'for'R'or'50'for'L'.
- Checks
- Location Validation (
KYLOSL = 'SEL'):- Loops through the
LOCarray (up to 5 locations,KYLOC1–KYLOC5). - For non-blank/non-zero entries, chains to
INLOCusingLOCKEY. If not found (indicator 41), sets error indicators, callsSETINDto set error flags, and assignsCOM,3.
- Loops through the
- Product Class Validation (
KYPCSL = 'SEL'):- Loops through the
CLSarray (up to 10 classes,KYPC01–KYPC10). - Chains to
GSTABLusingPRCLKY. If not found (indicator 32), sets error indicators, callsSETIND, and assignsCOM,5.
- Loops through the
- Customer Validation (
KYCSSL = 'SEL'):- Loops through the
CSarray (up to 20 customers,KYCS01–KYCS20). - Chains to
ARCUSTusingKEY8. If not found (indicator 33), sets error indicators, callsSETIND, and assignsCOM,6.
- Loops through the
- Product Validation (
KYPDSL = 'SEL'):- Loops through the
PRDarray (up to 10 products,KYPD01–KYPD10). - Chains to
GSPRODusingKLPROD. If not found (indicator 31), sets error indicators, callsSETIND, and assignsCOM,4.
- Loops through the
- Salesman Validation (
KYSMSL = 'SEL'):- Chains to
GSTABLusingPRSLKYforKYFRSMandKYTOSM. If either is invalid (indicators 47 or 48), sets error indicators and assignsCOM,7orCOM,8.
- Chains to
- Unit of Measure Validation (
KYUMSL = 'SEL'):- Checks
KYUMYPfor'INCLUDE'or'EXCLUDE'. If invalid, sets error indicators and assignsCOM,18. - If
'ALL', ensuresKYUMYPis blank (COM,20if not). - Chains to
GSTABLforKYUM01usingUMKEY. If not found (indicator 18), sets error indicators and assignsCOM,14.
- Checks
- Additional Parameters:
- Validates
KYADDAandKYJOBQfor blank,'N', or'Y'. If invalid, sets error indicators and assignsCOM,9. - If
KYADDA = 'Y'andKYSPRD = 'Y', sets error indicators and assignsCOM,13.
- Validates
- Date Handling:
- Converts
UDATEto an 8-digit format (KYDAT8) with century adjustment based onY2KCMPandY2KCEN.
- Converts
-
Output: Writes validated or error data to
SCREENwith record formatBI944PS1, including error messageMSG. -
Screen 2 Processing Subroutine (
S2, Lines 0157–0150): - Execution Condition: Triggered when indicator 02 is on, corresponding to the second screen (
BI944PS2) submission. - Start Date Conversion:
- Converts
KYSTDTto an 8-digit format (KYSTD8) with century adjustment, similar toKYDAT8.
- Converts
- Industry Code Validation:
- Checks
KYINDCfor'INCREASE'or'DECREASE'. If invalid, sets indicators 82 and 90 and assignsCOM,12.
- Checks
- Unit of Measure Validation:
- Chains to
GSTABLforKYUOFMusingUMKEY. If not found (indicator 88), sets indicators 82 and 90 and assignsCOM,14.
- Chains to
- Start Date Validation:
- If
KYUOFMis non-blank andKYSTDTis zero, sets indicators 82, 90, and 89 and assignsCOM,15. - Calls
@DTEDTto validateKYSTDT. If invalid (indicator 86), sets error indicators and assignsCOM,16. - Compares
KYSTDTto system date (SYSDAT). IfKYSTDTis not after today, sets error indicators and assignsCOM,17.
- If
-
Output: Writes validated or error data to
SCREENwith record formatBI944PS2, including error messageMSG. -
Indicator Setting Subroutine (
SETIND, Lines 0160–0156): -
Sets specific indicators (21–80) based on the value of
Xand the error condition (indicators 31, 32, 33, or 41) to flag which specific selection (location, product, class, or customer) caused the error. -
Date Editing Subroutine (
@DTEDT, Lines 0014–0125): - Validates
KYSTDTby breaking it into month, day, and year components. - Checks month (1–12) and day validity, accounting for leap years:
- For February, checks for leap year using year divisibility by 4 or 400 for century years.
- For other months, checks day limits (30 or 31).
-
Sets indicator 86 if the date is invalid.
-
Program Termination:
- The program branches to
ENDafter processing each screen or if errors occur (viaKGor validation failures). - Outputs to
SCREENare used to display errors or prompt for corrections.
Business Rules¶
The program enforces the following business rules for validating user inputs:
- Selection Fields (
KYLOSL,KYPCSL,KYCSSL,KYPDSL,KYSMSL,KYUMSL): - Must be
'ALL'or'SEL'. Otherwise, error messageCOM,1is displayed. - If
'ALL', corresponding selection arrays (LOC,CLS,CS,PRD) must be blank (COM,10if not). -
If
'SEL', at least one entry in the corresponding array must be non-blank (COM,11if all blank). -
Division (
KYDIV): - Must be
'R','L', or'B'. Otherwise, error messageCOM,2is displayed. -
Sets
KYDVNOto'00'for'R'or'50'for'L'. -
Locations (
KYLOC1–KYLOC5): -
If
KYLOSL = 'SEL', each non-blank/non-zero entry must exist inINLOC(COM,3if not found). -
Product Classes (
KYPC01–KYPC10): -
If
KYPCSL = 'SEL', each non-blank entry must exist inGSTABL(COM,5if not found). -
Customers (
KYCS01–KYCS20): - If
KYCSSL = 'SEL', each non-blank/non-zero entry must exist inARCUST(COM,6if not found). - If
KYCSSL = 'SEL',KYSTYPmust be'INCLUDE'or'EXCLUDE'(COM,18if invalid). -
If
KYCSSL = 'ALL',KYSTYPmust be blank (COM,19if not). -
Products (
KYPD01–KYPD10): -
If
KYPDSL = 'SEL', each non-blank entry must exist inGSPROD(COM,4if not found). -
Salesmen (
KYFRSM,KYTOSM): -
If
KYSMSL = 'SEL', both must exist inGSTABL(COM,7orCOM,8if not found). -
Units of Measure (
KYUMSL,KYUMYP,KYUM01): - If
KYUMSL = 'SEL',KYUMYPmust be'INCLUDE'or'EXCLUDE'(COM,18if invalid). - If
KYUMSL = 'ALL',KYUMYPmust be blank (COM,20if not). -
If
KYUMSL = 'SEL',KYUM01must exist inGSTABL(COM,14if not found). -
Additional Parameters:
KYADDAandKYJOBQmust be blank,'N', or'Y'(COM,9if invalid).-
If
KYADDA = 'Y',KYSPRDcannot be'Y'(COM,13if both are'Y'). -
Industry Code (
KYINDC):- Must be
'INCREASE'or'DECREASE'if non-blank (COM,12if invalid).
- Must be
-
Unit of Measure and Start Date (
KYUOFM,KYSTDT):- If
KYUOFMis non-blank,KYSTDTmust be non-zero (COM,15if zero). KYSTDTmust be a valid date (COM,16if invalid, checked via@DTEDT).KYSTDTmust be after the system date (COM,17if not).
- If
-
Copy Count (
KYCOPY):- Defaults to 1 if zero.
Tables (Files) Used¶
The program uses the following files, as defined in the File Specification (F-spec) and Input Specification (I-spec):
- SCREEN (Workstation File):
- Type: Combined (
CP), used for interactive input/output. - Record formats:
BI944PS1(screen 1) andBI944PS2(screen 2). -
Fields: Input fields like
KYDIV,KYLOSL,KYLOC1–KYLOC5,KYPCSL,KYPC01–KYPC10,KYCSSL,KYCS01–KYCS20,KYPDSL,KYPD01–KYPD10,KYSMSL,KYFRSM,KYTOSM,KYSPRD,KYJOBQ,KYCOPY,KYADDA,KYUMSL,KYUMYP,KYUM01,KYINDC,KYDLCH,KYUOFM,KYSTDT, and output fieldMSG. -
BICONT (Control File):
- Type: Input (
IF), disk file, 256 bytes, logical access. - Fields:
BCDEL(delete flag),BCCO(company number),BCNAME(company name). -
Usage: Read to check for non-deleted company records.
-
GSTABL (General System Table):
- Type: Input (
IF), disk file, 256 bytes, indexed. - Fields:
TBDESC(table description),TBDES2(alternate description),TBABDS(short description). -
Usage: Chained to validate product classes (
PRCLKY), salesmen (PRSLKY), and units of measure (UMKEY). -
ARCUST (Customer Master File):
- Type: Input (
IF), disk file, 384 bytes, indexed. - Fields:
ARNAME(customer name). -
Usage: Chained to validate customer numbers (
KEY8). -
INLOC (Location File):
- Type: Input (
IF), disk file, 512 bytes, indexed. - Fields:
ILDEL(delete flag),ILCONO(company),ILLOC(location),ILNAME(location name). -
Usage: Chained to validate location codes (
LOCKEY). -
GSPROD (Product Master File):
- Type: Input (
IF), disk file, 512 bytes, indexed. - Fields:
TPDEL(delete flag),TPDESC(description),TPDES1(complete description),TPPRGP(product group code),TPPRCL(product class code),TPABDS(short description),TPFLCD. - Usage: Chained to validate product codes (
KLPROD).
External Programs Called¶
The RPG program does not explicitly call any external programs via CALL operations. It interacts with the display file SCREEN and database files but relies on the OCL program (BI944P.ocl36.txt) to initiate its execution and potentially call a related program (BI944) based on the KYJOBQ parameter. The reference to BI944 in the OCL suggests it may be a follow-up program, but no direct calls are made within the RPG code.
Summary¶
- Process Steps:
- Initialize indicators and message field; exit if
KGis on. - Perform one-time setup (
ONETIM): readBICONT, set defaults, and initialize parameters. - Process screen 1 (
S1): validate division, locations, product classes, customers, products, salesmen, units of measure, and additional parameters; output toBI944PS1. - Process screen 2 (
S2): validate industry code, unit of measure, and start date; output toBI944PS2. - Set error indicators (
SETIND) for specific invalid selections. - Validate dates (
@DTEDT) forKYSTDT. -
Terminate after processing or errors, writing results to
SCREEN. -
Business Rules:
- Enforce valid values for selection fields (
'ALL'or'SEL'), division ('R','L','B'), and other parameters. - Validate specific selections against database files (
INLOC,GSTABL,ARCUST,GSPROD). - Ensure
KYSTYPandKYUMYPare'INCLUDE'or'EXCLUDE'when applicable, or blank for'ALL'. - Validate
KYADDA,KYJOBQ, andKYSPRDfor correct values. - Ensure
KYSTDTis valid and future-dated ifKYUOFMis non-blank. -
Default
KYCOPYto 1. -
Tables Used:
SCREEN(workstation file)BICONT(control file)GSTABL(general system table)ARCUST(customer master file)INLOC(location file)-
GSPROD(product master file) -
External Programs Called:
- None directly called within the RPG program. The OCL may call
BI944based onKYJOBQ.
This RPG program serves as a front-end validation step for the Customer Sales Agreement Master File Listing, ensuring all user inputs are correct before proceeding to further processing, likely handled by BI944 as indicated in the OCL. If you need further analysis of the BI944 program or specific file layouts, please provide additional details or files.