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 (
SETOF
statements). - Blank Message: Initializes the
MSG
field to blanks to clear any prior error messages (MOVEL*BLANKS MSG
). -
KG Indicator Check: If the
KG
indicator (keyboard error or cancel) is on, the program sets indicatorsU1
andLR
(last record), resets indicators 01, 09, 81, and 82, and branches to theEND
tag, 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 (
TIME
operation) intoSYSTIM
andSYSDAT
. - Clear Arrays: Initializes the
DCO
array to blanks. - Set Counter: Sets loop counter
X
to 1 andBILIM
to 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). SetsKYDIV
to'R'
,KYJOBQ
,KYSPRD
, andKYADDA
to'N'
, andKYCOPY
to 1. - Indicator Setup: Sets indicator 81 on to signal successful initialization.
-
Exit: Branches to
END
after 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
, andKYUMSL
for values'ALL'
or'SEL'
. If neither, sets error indicators 81 and 90, moves an error message from theCOM
array (e.g.,COM,1
for 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
KYDIV
for valid values ('R'
,'L'
, or'B'
). If invalid, sets error indicators and assignsCOM,2
. - Sets
KYDVNO
to'00'
for'R'
or'50'
for'L'
.
- Checks
- Location Validation (
KYLOSL = 'SEL'
):- Loops through the
LOC
array (up to 5 locations,KYLOC1
–KYLOC5
). - For non-blank/non-zero entries, chains to
INLOC
usingLOCKEY
. If not found (indicator 41), sets error indicators, callsSETIND
to set error flags, and assignsCOM,3
.
- Loops through the
- Product Class Validation (
KYPCSL = 'SEL'
):- Loops through the
CLS
array (up to 10 classes,KYPC01
–KYPC10
). - Chains to
GSTABL
usingPRCLKY
. If not found (indicator 32), sets error indicators, callsSETIND
, and assignsCOM,5
.
- Loops through the
- Customer Validation (
KYCSSL = 'SEL'
):- Loops through the
CS
array (up to 20 customers,KYCS01
–KYCS20
). - Chains to
ARCUST
usingKEY8
. If not found (indicator 33), sets error indicators, callsSETIND
, and assignsCOM,6
.
- Loops through the
- Product Validation (
KYPDSL = 'SEL'
):- Loops through the
PRD
array (up to 10 products,KYPD01
–KYPD10
). - Chains to
GSPROD
usingKLPROD
. If not found (indicator 31), sets error indicators, callsSETIND
, and assignsCOM,4
.
- Loops through the
- Salesman Validation (
KYSMSL = 'SEL'
):- Chains to
GSTABL
usingPRSLKY
forKYFRSM
andKYTOSM
. If either is invalid (indicators 47 or 48), sets error indicators and assignsCOM,7
orCOM,8
.
- Chains to
- Unit of Measure Validation (
KYUMSL = 'SEL'
):- Checks
KYUMYP
for'INCLUDE'
or'EXCLUDE'
. If invalid, sets error indicators and assignsCOM,18
. - If
'ALL'
, ensuresKYUMYP
is blank (COM,20
if not). - Chains to
GSTABL
forKYUM01
usingUMKEY
. If not found (indicator 18), sets error indicators and assignsCOM,14
.
- Checks
- Additional Parameters:
- Validates
KYADDA
andKYJOBQ
for 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
UDATE
to an 8-digit format (KYDAT8
) with century adjustment based onY2KCMP
andY2KCEN
.
- Converts
-
Output: Writes validated or error data to
SCREEN
with 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
KYSTDT
to an 8-digit format (KYSTD8
) with century adjustment, similar toKYDAT8
.
- Converts
- Industry Code Validation:
- Checks
KYINDC
for'INCREASE'
or'DECREASE'
. If invalid, sets indicators 82 and 90 and assignsCOM,12
.
- Checks
- Unit of Measure Validation:
- Chains to
GSTABL
forKYUOFM
usingUMKEY
. If not found (indicator 88), sets indicators 82 and 90 and assignsCOM,14
.
- Chains to
- Start Date Validation:
- If
KYUOFM
is non-blank andKYSTDT
is zero, sets indicators 82, 90, and 89 and assignsCOM,15
. - Calls
@DTEDT
to validateKYSTDT
. If invalid (indicator 86), sets error indicators and assignsCOM,16
. - Compares
KYSTDT
to system date (SYSDAT
). IfKYSTDT
is not after today, sets error indicators and assignsCOM,17
.
- If
-
Output: Writes validated or error data to
SCREEN
with record formatBI944PS2
, including error messageMSG
. -
Indicator Setting Subroutine (
SETIND
, Lines 0160–0156): -
Sets specific indicators (21–80) based on the value of
X
and 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
KYSTDT
by 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
END
after processing each screen or if errors occur (viaKG
or validation failures). - Outputs to
SCREEN
are 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,1
is displayed. - If
'ALL'
, corresponding selection arrays (LOC
,CLS
,CS
,PRD
) must be blank (COM,10
if not). -
If
'SEL'
, at least one entry in the corresponding array must be non-blank (COM,11
if all blank). -
Division (
KYDIV
): - Must be
'R'
,'L'
, or'B'
. Otherwise, error messageCOM,2
is displayed. -
Sets
KYDVNO
to'00'
for'R'
or'50'
for'L'
. -
Locations (
KYLOC1
–KYLOC5
): -
If
KYLOSL = 'SEL'
, each non-blank/non-zero entry must exist inINLOC
(COM,3
if not found). -
Product Classes (
KYPC01
–KYPC10
): -
If
KYPCSL = 'SEL'
, each non-blank entry must exist inGSTABL
(COM,5
if not found). -
Customers (
KYCS01
–KYCS20
): - If
KYCSSL = 'SEL'
, each non-blank/non-zero entry must exist inARCUST
(COM,6
if not found). - If
KYCSSL = 'SEL'
,KYSTYP
must be'INCLUDE'
or'EXCLUDE'
(COM,18
if invalid). -
If
KYCSSL = 'ALL'
,KYSTYP
must be blank (COM,19
if not). -
Products (
KYPD01
–KYPD10
): -
If
KYPDSL = 'SEL'
, each non-blank entry must exist inGSPROD
(COM,4
if not found). -
Salesmen (
KYFRSM
,KYTOSM
): -
If
KYSMSL = 'SEL'
, both must exist inGSTABL
(COM,7
orCOM,8
if not found). -
Units of Measure (
KYUMSL
,KYUMYP
,KYUM01
): - If
KYUMSL = 'SEL'
,KYUMYP
must be'INCLUDE'
or'EXCLUDE'
(COM,18
if invalid). - If
KYUMSL = 'ALL'
,KYUMYP
must be blank (COM,20
if not). -
If
KYUMSL = 'SEL'
,KYUM01
must exist inGSTABL
(COM,14
if not found). -
Additional Parameters:
KYADDA
andKYJOBQ
must be blank,'N'
, or'Y'
(COM,9
if invalid).-
If
KYADDA = 'Y'
,KYSPRD
cannot be'Y'
(COM,13
if both are'Y'
). -
Industry Code (
KYINDC
):- Must be
'INCREASE'
or'DECREASE'
if non-blank (COM,12
if invalid).
- Must be
-
Unit of Measure and Start Date (
KYUOFM
,KYSTDT
):- If
KYUOFM
is non-blank,KYSTDT
must be non-zero (COM,15
if zero). KYSTDT
must be a valid date (COM,16
if invalid, checked via@DTEDT
).KYSTDT
must be after the system date (COM,17
if 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
KG
is 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
KYSTYP
andKYUMYP
are'INCLUDE'
or'EXCLUDE'
when applicable, or blank for'ALL'
. - Validate
KYADDA
,KYJOBQ
, andKYSPRD
for correct values. - Ensure
KYSTDT
is valid and future-dated ifKYUOFM
is non-blank. -
Default
KYCOPY
to 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
BI944
based 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.