BI946P RPG36
The provided document is an RPG III program named BI946P.rpg36.txt
, which is called from the OCL program BI946P.ocl36.txt
. This RPG program appears to handle the prompting and validation for generating a customer freight tables print report. Below, I’ll explain the process steps, business rules, tables/files used, and any external programs called.
Process Steps of the RPG Program¶
The RPG program BI946P
is designed to prompt the user for input parameters (via a display file) and validate those inputs to prepare for generating a freight table report. It processes data from the BICONT
file and outputs validated parameters to a display file (SCREEN
). Here’s a step-by-step breakdown of the process:
- File and Data Structure Definitions (Lines 0005–0032):
- Files:
SCREEN
: A workstation file (display file) with a record length of 512 bytes, used for user interaction (input/output prompts).BICONT
: A disk file (256 bytes, keyed, indexed) opened for input with two access paths (logical files or indexes,L02AI
).
- Data Structures:
DCO
: An array of 3 elements, each 35 bytes, used to store company data (company number and name).CS
: An array of 10 elements, each 6 bytes, likely for customer numbers.COM
: An array of 7 elements, each 40 bytes, used for error messages (defined at the end of the program).
-
Input Specifications:
SCREEN
(record formatNS
, indicators01
,09
):- Fields like
KYALCO
(ALL or CO),KYCO1
,KYCO2
,KYCO3
(company numbers),KYALCS
(ALL or SEL),CS
(customer numbers),KYJOBQ
(job queue flag),KYCOPY
(number of copies), andKYCUR
(current records flag). BICONT
:- Fields include
BCDEL
(delete flag),BCCO
(company number),BCNAME
(company name). UDS
(User Data Structure): Maps fields fromSCREEN
input to program variables (e.g.,KYALCO
,KYCO1
, etc.).Y2KCEN
andY2KCMP
: Century and company fields for Y2K compliance (likely for date handling).
-
Initialization (Lines 0035–0043):
- Clears indicators (31–35, 38–39, 81–90) to reset program state.
- Clears the
MSG
field (40 bytes) for error messages. -
If the
KG
indicator (likely a kill/go flag) is on:- Sets
U1
(user indicator) andLR
(last record) to terminate the program. - Clears indicators
01
,09
,81
and jumps to theEND
tag, effectively halting execution.
- Sets
-
One-Time Setup Subroutine (
ONETIM
) (Lines 0127–0165, triggered by indicator09
): - Clears the
DCO
array. - Initializes variables:
X
(index) to 1,BILIM
(limit) to 00. - Sets the lower limit (
SETLL
) onBICONT
usingBILIM
to position the file pointer. - Reads
BICONT
records in a loop (AGNCO
toENDCO
):- Skips records where
BCDEL = 'D'
(deleted records). - Moves
BCCO
(company number) andBCNAME
(company name) to theDCO
array at indexX
. - Increments
X
and continues untilX > 3
or end-of-file (20
indicator).
- Skips records where
- Initializes default values:
KYALCO = 'ALL'
,KYCO1/2/3 = 0
,KYALCS = 'ALL'
,CS = 0
,KYJOBQ = 'N'
,KYCOPY = 1
.
- Sets indicator
81
to display the screen. -
Ends the subroutine and jumps to
END
(program termination). -
Main Validation Subroutine (
S1
) (Lines 0055–0123, triggered by indicator01
): - Validates user input from the
SCREEN
file. - KYALCO Validation (Lines 0057–0062):
- Checks if
KYALCO
is'ALL'
or'CO'
. If true, sets indicator31
. - If
31
is on, sets indicators81
and90
, moves error messageCOM,1
(“ENTER ALL OR CO”) toMSG
, and jumps toENDS1
.
- Checks if
- Company Number Validation (Lines 0063–0096):
- If
KYALCO = 'CO'
: - Checks if
KYCO1
,KYCO2
,KYCO3
are all zero. If so, sets indicators32
,81
,90
, moves error messageCOM,5
(“ENTER COMPANY NUMBER”) toMSG
, and jumps toENDS1
. - For each non-zero
KYCO1
,KYCO2
,KYCO3
:- Chains (looks up) the company number in
BICONT
. - If not found (
32
,33
,34
) orBCDEL = 'D'
, sets indicators81
,90
, moves error messageCOM,2
(“INVALID COMPANY NUMBER ENTERED”) toMSG
, and jumps toENDS1
.
- Chains (looks up) the company number in
- If
- KYALCS Validation (Lines 0098–0110):
- Checks if
KYALCS
is'ALL'
or'SEL'
. If true, sets indicator35
. - If
35
is on, sets indicators81
,90
, moves error messageCOM,3
(“ENTER ALL OR SEL”) toMSG
, and jumps toENDS1
. - If
KYALCS = 'SEL'
: - Sums the
CS
array (customer numbers) intoCSXFT
. - If
CSXFT = 0
, sets indicators39
,81
,90
, moves error messageCOM,6
(“ENTER CUSTOMER NUMBER”) toMSG
, and jumps toENDS1
.
- Checks if
- KYCUR Validation (Lines JB01, after 0110):
- Checks if
KYCUR
is blank or'CUR'
. If true, sets indicator37
. - If
37
is on, sets indicators81
,90
, moves error messageCOM,7
(“ENTER 'CUR' OR LEAVE BLANK”) toMSG
, and jumps toENDS1
.
- Checks if
- KYJOBQ Validation (Lines 0112–0117):
- Checks if
KYJOBQ
is blank,'N'
, or'Y'
. If true, sets indicator38
. - If
38
is on, sets indicators81
,90
, moves error messageCOM,4
(“ENTER BLANK, N OR Y”) toMSG
, and jumps toENDS1
.
- Checks if
- KYCOPY Validation (Lines 0119–0121):
- If
KYCOPY = 0
, sets it to1
(ensures at least one copy is printed).
- If
-
Ends the subroutine (
ENDS1
). -
Output to Screen (Lines 0168–0179):
- If indicator
81
is on, writes to theSCREEN
file (formatD
). - Outputs fields:
KYALCO
,KYCO1
,KYCO2
,KYCO3
,DCO
(company data),KYALCS
,CS
,KYJOBQ
,KYCOPY
,MSG
, andKYCUR
. -
Includes a constant
'BI946PFM'
(likely a program or form name). -
Program Termination (Lines 0051, 0046, 0049):
- The program jumps to the
END
tag after executingONETIM
(indicator09
) orS1
(indicator01
), or ifKG
is on. - Sets
LR
(last record) to terminate the program.
Business Rules¶
The RPG program enforces the following business rules for validating user input to generate a freight table report:
- Company Selection (
KYALCO
): - Must be
'ALL'
or'CO'
. Otherwise, displays error: “ENTER ALL OR CO”. -
If
'CO'
, at least one company number (KYCO1
,KYCO2
, orKYCO3
) must be non-zero and valid (exists inBICONT
and not deleted). -
Company Numbers (
KYCO1
,KYCO2
,KYCO3
): - If
KYALCO = 'CO'
, company numbers must exist inBICONT
and not haveBCDEL = 'D'
. - If any company number is invalid or deleted, displays error: “INVALID COMPANY NUMBER ENTERED”.
-
If all company numbers are zero when
KYALCO = 'CO'
, displays error: “ENTER COMPANY NUMBER”. -
Customer Selection (
KYALCS
): - Must be
'ALL'
or'SEL'
. Otherwise, displays error: “ENTER ALL OR SEL”. -
If
'SEL'
, at least one customer number in theCS
array must be non-zero. Otherwise, displays error: “ENTER CUSTOMER NUMBER”. -
Current Records Flag (
KYCUR
): - Must be blank or
'CUR'
. Otherwise, displays error: “ENTER 'CUR' OR LEAVE BLANK”. -
'CUR'
likely filters for current (non-expired) records, as added in the 2017 update (JB01). -
Job Queue Flag (
KYJOBQ
): - Must be blank,
'N'
, or'Y'
. Otherwise, displays error: “ENTER BLANK, N OR Y”. -
Determines whether the report job is submitted to a job queue (
'Y'
) or run interactively ('N'
or blank). -
Number of Copies (
KYCOPY
): -
If zero, automatically set to
1
to ensure at least one copy is printed. -
Deleted Records:
-
Records in
BICONT
withBCDEL = 'D'
are skipped during processing. -
Data Collection:
- The program collects up to three company numbers and names from
BICONT
into theDCO
array for display or validation.
Tables/Files Used¶
- BICONT:
- A disk file (256 bytes, keyed, input mode) containing freight table data.
- Fields:
BCDEL
(1 byte): Delete flag (‘D’ indicates deleted).BCCO
(2–3 bytes): Company number.BCNAME
(30 bytes): Company name.
-
Used for validating company numbers and retrieving company names.
-
SCREEN:
- A workstation file (display file, 512 bytes) used for user input and output.
- Fields include
KYALCO
,KYCO1
,KYCO2
,KYCO3
,KYALCS
,CS
,KYJOBQ
,KYCOPY
,KYCUR
,MSG
, andDCO
. - Outputs error messages and prompts to the user.
External Programs Called¶
The RPG program does not explicitly call any external programs via CALL
operations. However:
- The output specification includes a constant 'BI946PFM'
(line 0169), which may indicate a related program or form name used in the broader process (possibly called by the OCL program).
- The OCL program (BI946P.ocl36.txt
) references BI946
, which is likely called after BI946P
validates the input parameters, suggesting BI946
is the program that generates the actual freight table report.
Summary¶
- Process Steps: The program initializes, prompts the user via
SCREEN
, validates input parameters (KYALCO
,KYCO1/2/3
,KYALCS
,CS
,KYJOBQ
,KYCOPY
,KYCUR
), retrieves company data fromBICONT
, and displays errors or validated data. It terminates after validation or if theKG
indicator is set. - Business Rules: Enforces valid values for company selection, company numbers, customer selection, current records flag, job queue flag, and number of copies. Skips deleted records and ensures at least one copy is printed.
- Tables/Files:
BICONT
(disk file for company data),SCREEN
(display file for user interaction). - External Programs: None called directly, but
'BI946PFM'
and the OCL’s reference toBI946
suggest a related program for report generation.
If you have the source code for BI946
or additional details about BICONT
or SCREEN
, I can provide further analysis of the end-to-end process.