0% found this document useful (0 votes)
61 views

Ovrdbf 1. What Exactly The OVRDBF Does?: 'HSTATUS "C" & HCUST 08177' 'HCUST 08177'

The document discusses a Level Check error that can occur when a program is run after changes have been made to a program file (PF) that the program references. Specifically: 1) A program runs successfully until the PF it references is changed and recompiled, generating a new unique code for the PF. 2) When the program is run again, it does not have the new unique code for the PF and terminates with a Level Check error. 3) The solution is to either compile the PF with the 'Level Check' parameter set to 'NO' or recompile the program to reference the new version of the PF.

Uploaded by

venkateswarlu m
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Ovrdbf 1. What Exactly The OVRDBF Does?: 'HSTATUS "C" & HCUST 08177' 'HCUST 08177'

The document discusses a Level Check error that can occur when a program is run after changes have been made to a program file (PF) that the program references. Specifically: 1) A program runs successfully until the PF it references is changed and recompiled, generating a new unique code for the PF. 2) When the program is run again, it does not have the new unique code for the PF and terminates with a Level Check error. 3) The solution is to either compile the PF with the 'Level Check' parameter set to 'NO' or recompile the program to reference the new version of the PF.

Uploaded by

venkateswarlu m
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

If we call the program, it runs successfully.

But if we change the PF and recompile the PF, the


system generates a new unique code for that PF. So, our program doesn’t have this unique code
and hence terminates abnormally with a Level Check error.
The solution of Level Check error is whenever it happens we have to either compile the PF with
Level Check parameter value *NO or we have to compile the program again.

OVRDBF

1. What exactly the OVRDBF does?

It can do a lot below are some basic examples

1) Say you have an internally defined file in your program.

OVRDBF FILE (CR311H) TOFILE (CB.CR1H)


CALL CR1H
DLTOVR FILE (CR311H)

2) Say you want to use a different file (with the same record level) in a program.

OVRDBF FILE (PAYROLL) TOFILE (MYPAYROLL)


CALL GIVERAISE
DLTOVR FILE (MYPAYROLL)

3) Say you want to use OpnQryF ( ug hate old school).

OVRDBF FILE(OCEANHDR) TOFILE(OCEANHDR) SHARE(*YES)


OPNQRYF FILE((OCEANHDR)) +
QRYSLT('HSTATUS ¬= "C" & HCUST = 08177') +
KEYFLD((HCUSTREF))
QRYSLT('HCUST = 08177') +
CALL PGM(AB010R)
CLOF OPNID(OCEANHDR)
DLTOVR FILE(*ALL)

4) Say you have a specific member that you want to use

OvrDbf File (TaRpt0103p) ToFile(TaRpt0103p) +


OvrScope(*CallLvl) Mbr(&PoMember)
CALL TaRpt0103
DltOvr FILE(*ALL) LVL(*)

To be theoretical,
The OVRDBF is used to

1) To temporarily change the attributes of a file like member, position of rrn ,sharing the Open
Data Path etc....
2) To Redirect the references made for one file to other file.

Page 84 of 228
Actually OVRDBF is used for multimember concept. A pf having multiple member and u need
to access one of the members from that, OVRDBF is used. Also, in CL u can access only 1 file at
a time. For more than 1 file also OVRDBF is used

OPNQRYF

47. What is the open query file?

It is a dynamic record selection. The OPNQRYF command acts as a filter between the
processing program and the database records. The database file can be a PF or LF. It will create
open data pathway to access (retrieve) data file.
If you want to specify any SQL operation within a CL we have to use OPNQRYF
 Functions supplied by OPNQRYF are:
 Dynamic record selection.
 Dynamic keyed sequence access path
 Dynamic keyed sequence access path over a join
 Dynamic join
 Handling missing records in secondary join files
 Unique-key processing
 Mapped field definitions
 Group processing
 Final total-only processing
 Improving performance
 Open query identifier (ID)

48. What is the different between OPNQRYF and SQLRPG?

OPNQRYF SQLRPG

OPNQRYF will come along with OS/400 We need to have SQLRPG installed in
system and no need to have any as/400 system which involves additional
additional package needed to execute it cost to the programmers
OPNQRYF is faster as compared to It is slower
SQLRPG
OPNQRYF is nothing but a dynamic SQLRPG is imbedding SQL statements
logical files will be created and the directly within SQL statement
records

49. What are the various steps in creating OPNQRYF?


Totally five steps involved in creating OPNQRYF
 OVRDBF
 FILE (file PF) TOFILE (LIB/ PF) SHARE (*Yes)

Page 85 of 228
 If a PF is having 100 records and if we want to override the PF so that
it continues only the specific number of records we are using
OVRDBF
 OPNQRYF
 FILE (LIB / PF) QRYSLT (‘EMPNO *EQ ‘ *BCAT &A)
 If you want to perform any SQL operation we have to declare in
OPNQRYF command only.
 In case of OPNQRYF we can perform expression only based on
characters but not on numeric.
 *BCAT
If you want to perform any charter expression are using *BCAT
expression which will provide a blanks in between the 2 variables.
 %WLDCRD
 It is similar to %LIKE in SQL
 QRYSLT (‘EMPNAME *EQ %WLDCRD (“S* “)’)
It will fetch all the records whose empname starts from S.
 *CT
 It will fetch all the records, which conditions the particular
charter.
 QRYSLT (‘EMPNAME *CT “S” ‘)
 %RANGE
 It will fetch the records within the specific range
 QRYSLT (‘EMPNO *Eq %RANGE (100 110)’)
 CALL PGM (LIB/NAME) PARM ()
 DLTOVR
 As we see early the main file logically overridden and after performing
the necessary operation, we have to delete the logical file so that the main
file contains the actual records for this DLTOVR will be used.
 DLTOVR FILE (OPNPF)
 CLOF
 We have to close the file, which has been opened
 CLOF OPNID (OPNPF)
You will copy overridden file records using CPYFRMQRYF
 CPYFRMQRYF
 Since OVRDBF is logical we cannot able to list the variables, which satisfy
the query condition. To see the records being selected we have to copy
from the source file to a temporary file for this CPYFRMQRYF will be
used
 CPYFRMQRYF FROMOPNID (OPNPF) TOFILE (LIB/NAME)
MBR (*REPLACE) CRTFILE (*YES) FMTOPT (*NOCHK)
 RUNQRY
 We have copied the contents satisfy the query into a temporary file using
CPYFRMQRYF. If we run the destination file we got the actual records,
which satisfy the query.
 RUNQRY QRYFILE (LIN/NAME)

Page 86 of 228
Example:
Database PF

SKANDASAMO/CLP

OPENF

*************** Beginning of data ****************************

0000.01 C UNIQUE

0001.00 C R OPNQFILE

0002.00 C OEMPNO 5S 0

0003.00 C OEMPNAME 20A

0004.00 C OADDRESS 20A

0005.00 C ODOB 8S 0

0006.00 C K OEMPNO

****************** End of data ********************************

Data file

Display Report

OEMPNO OEMPNAME OADDRESS ODOB

000001 1,001 SENTHIL SALEM1 1,232,002

000002 1,002 KUMAR TRICHY 12,123,000

000003 1,003 SHYAM SALEM 12,345,000

000004 1,004 RAMESH SALEM 1,010,100

000005 1,005 BALU SALEM 222

000006 1,007 KUMAR JJ 32,938

****** ******** End of report ********

CL program

SKANDASAMO/CLP

OPNQFILE5

*************** Beginning of data *********************************

Page 87 of 228
0001.00 PGM

0002.00 DCL VAR(&A) TYPE(*CHAR) LEN(5)

0003.00 DCLF FILE(SKANDASAMO/OPNQFILE3) RCDFMT(OPNF3)

0004.00 SNDRCVF RCDFMT(OPNF3)

0005.00 CHGVAR VAR(&A) VALUE(&OEMPNO)

0006.00 OVRDBF FILE(OPENF) SHARE(*YES)

0006.01 OPNQRYF FILE((SKANDASAMO/OPENF))


QRYSLT('OEMPNO *EQ' +

0006.02 *BCAT &A)

0006.03 CPYFRMQRYF FROMOPNID(OPENF)


TOFILE(SKANDASAMO/TEMP) +

0006.04 MBROPT(*REPLACE) CRTFILE(*YES)

0009.00 DLTOVR FILE(OPENF)

0010.00 CLOF OPNID(OPENF)

0010.01 RUNQRY QRYFILE((SKANDASAMO/TEMP))

0011.00 ENDPGM

****************** End of data*********************************

OUTPUT

EMPLOYEE NUMBER: 1001

OEMPNO OEMPNAME OADDRESS ODOB

000001 1,001 SENTHIL SALEM1 1,232,002

****** ******** End of report ********

50. How the records are accessed for using OPNQRYF?


By creating open data pathway to access (retrieve) data file.
51. What is the difference between FMTDTA and OPNQRYF?

FMTDTA OPNQRY

It will sort the records sequentially based It will sort the records based on the field
on the position of the record values.

Page 88 of 228
If any change in the attribute size of a PF If there is any change in the attribute size it
then we have to change the program will not affect the program specification
specification also. also.

FMTDTA is bit faster in process than OPNQRYF is slower as compare to


OPNQRYF. FMTDTA if we are processing millions of
records.

52. List out the Differences between a LF and command OPNQRYF?

LF creates a new object in the system while that is not the case for OPNQRYF.LF creates a
permanent data access path to the physical file that will be updated as and when and add,
update and delete operation is performed on file Whereas OPNQRYF creates a temporary
access data path that is shared by high level pgm for further processing of recs in file.

I agree with Vaiv20. Just want to add that OPNQRYF is used with keyword Share (*Yes) and
that's what makes the ODP available to high level pgms.
Also the usage of OPNQRYF is for adhoc jobs that are executed once in a while whereas LF is
used in case where the ODP is going to be used pretty regularly. So LF object would be
preferred when the usage is going to be regular.
OPNQRYF would be good where the job is going to be once in a while.
LF would make the job faster compared to OPNQRYF though it depends on what kind of
maintenance option you use for LF.
The main difference is: Logical file creates permanent object on the system. OPNQRYF creates
temporary access path.

53. OPNQRYF - Short explanation with samples in CLP

CL-PROGRAM

FUNCTION.....: RETRIEVE/SELECT DATA WITH THE CL-COMMAND OPNQRYF.

ILLUSTRATED IN SAMPLES 1 - 3.

TASK.........: RETRIEVE USERINFO ON FIELDS FROM THE USRPRF-FILE.

USE THE CL-COMMAND DSPUSRPRF *ALL OUTPUT(*OUTFILE)

FILE(LIB/QRYSLTPF). LIB IS YOUR OWN TEST-LIBRARY.

THE PROGRAM ONLY USES 2 FIELDS TO AVOID CONFUSION.

IN THIS PROGRAM THE TEST-LIBRARY IS JPHLIB.

Page 89 of 228
INPUT........: DB-FILE: QRYSLTPF

FIELDS: UPUPRF 10 A

UPUID 10 P0

DISCLAIMER...: THE DATA RETRIEVED AND THE COMBINATION OF FIELDS

IS COMPLETELY NONSENSE AND INTENDED ONLY TO ILLU-

STRATE THE USE OF THIS COMMAND. CREATE BETTER EX-

AMPLES ON YOUR OWN !!

CREATE A FILE IN YOUR TESTLIBRARY CALLED BRUG. THIS IS THE FILE

THAT RECIEVES OUTPUT-DATA FROM THE OPNQRYF.

OUTPUT.......: DB-FILE: BRUG

FIELDS: UPUPRF 10 A

UPUID 10 P0

OPENID IN THE OPNQRYF-STATEMENT IS YOUR REFERENCE TO THE

INTERNAL OPNQRYF-OUTPUT. USE THIS NAME AS FROM-FILE

IN THE FINAL CPYFRMQRYF WHERE YOU RETRIEVE THE SELECTED

DATA TO A PHYSICAL FILE.

TIP..........: BE ABSOLUTELY SURE TO USE THE RIGHT NUMBER OF

QUOTES ( ' ) WHEN YOU DEFINE THE SELECT-STATEMENT.

ALL CHAR-VARIABLES IN THE OPNQRYF SELECT-LINE MUST

BE EMBEDDED IN TRIPLE-QUOTES AND *CAT:

''' *CAT &CHARVAR *CAT ''' OR

"' *CAT &CHARVAR *CAT '"

PGM

DCL VAR(&USER) TYPE(*CHAR) LEN(10)

DCL VAR(&NR) TYPE(*DEC) LEN(10 0)

DCL VAR(&EX) TYPE(*DEC) LEN(1 0)

DCL VAR(&NRALF) TYPE(*CHAR) LEN(10)

Page 90 of 228
DCL VAR(&X) TYPE(*CHAR) LEN(1) + VALUE(' ')

DCLF FILE(QRYSLTDF) RCDFMT(*ALL)

/* THE VAR X HELPS TO LEAVE THE LIBRARY-LIST UNCHANGED */

/* WHEN THE PROGRAM HAS FINISHED PROCESSING. */

ADDLIBLE LIB(JPHLIB)

MONMSG MSGID(CPF2103) EXEC(CHGVAR VAR(&X) VALUE('X'))

/* PROMPT FOR NAME OG ID AND TYPE OF EXAMPLE */

CHOISE: SNDRCVF RCDFMT(F0)

/* QRYSLT ONLY OPERATES WITH ALFA-VARIABLES. THE NUME- */

/* RIC VAR. &NR IS CONVERTED TO CHAR. &NRALF */

/* USED IN SAMPLE 3. */

CHGVAR VAR(&NRALF) VALUE(&NR)

/* F3 WAS PRESSED ON THE SCREEN */

IF COND(&IN03 = '1') THEN(GOTO CMDLBL(END))

IF COND(&EX = 1) THEN(GOTO CMDLBL(ONE))

IF COND(&EX = 2) THEN(GOTO CMDLBL(TWO))

IF COND(&EX = 3) THEN(GOTO CMDLBL(THREE))

/*****************************************************************/

/* SAMPLE ONE: CHAR CONSTANT AND NUM CONSTANT */

/*****************************************************************/

ONE:

OPNQRYF FILE((JPHLIB/QRYSLTPF)) +

QRYSLT(' +

(UPUPRF *EQ ''JPH'') +

*AND +

(UPUID *EQ 338) +

') +

Page 91 of 228
OPNID(BRUG)

GOTO CMDLBL(OUT)

/*****************************************************************/

/* SAMPLE TWO: CHAR VARIABLE AND NUM CONSTANT */

/*****************************************************************/

TWO:

OPNQRYF FILE((JPHLIB/QRYSLTPF)) +

QRYSLT(' +

(UPUPRF *EQ ''' *CAT &USER *CAT ''') +

*AND +

(UPUID *EQ 338) +

') +

OPNID(BRUG)

GOTO CMDLBL(OUT)

/*****************************************************************/

/* SAMPLE THREE: CHAR VARIABLE OG NUM VARIABLE. */

/* DIGITS IS A OPNQRYF KEYWORD THAT CONVERTS */

/* A FIELD FROM NUMERIC TO ALFA (CHAR.) */

/*****************************************************************/

THREE:

OPNQRYF FILE((JPHLIB/QRYSLTPF)) +

QRYSLT(' +

(UPUPRF *EQ ''' *CAT &USER *CAT ''') +

*AND +

(%DIGITS(UPUID) *EQ ''' *CAT &NRALF *CAT ''') +

') +

OPNID(BRUG)

Page 92 of 228
GOTO CMDLBL(OUT)

/*****************************************************************/

/* MAKE A COPY OF THE OPNQRY OUTPUTFILE TO THE PF BRUG */

/*****************************************************************/

OUT: CPYFRMQRYF FROMOPNID(BRUG) TOFILE(JPHLIB/BRUG) +

MBROPT(*ADD)

CLOF OPNID(BRUG)

DLTOVR FILE(*ALL)

GOTO CMDLBL(CHOISE)

/* LIBRARY-LIST IS RESTORED */

END: IF COND(&X = ' ') THEN(RMVLIBLE LIB(JPHLIB))

RCLRSC

RETURN

ENDPGM

DISPLAY-FILE:

A DSPSIZ(24 80 *DS3)

A R F0

A CF03(03 'Afslut')

A 1 69TIME

A 1 63'Time:'

A 1 30'Retrieve user and id'

A DSPATR(HI)

A 2 69DATE

A EDTCDE(Y)

A 2 63'Date:'

A 4 12'User name . . . . . :'

A DSPATR(HI)

Page 93 of 228
A PROMPT 1A I 24 4DSPATR(ND)

A 24 6'Enter=Run F3=Exit'

A COLOR(BLU)

A USER 10A I 4 35

A 6 12'User id . . . . . . :'

A DSPATR(HI)

A NR 10S 0I 6 35CHECK(FE)

A CHECK(RZ)

A 8 12'Sample . . . . . . :'

A DSPATR(HI)

A 10 8'1 = CHAR CONSTANT og NUM CONSTANT'

A 11 8'2 = CHAR VARIABLE og NUM CONSTANT'

A EX 1S 0I 8 35RANGE(1 3)

A 12 8'3 = CHAR VARIABLE og NUM VARIABLE'

PHYSICAL FILE BRUG:

**********************************************************************

* PHYSICAL FILE BRUG TO HOLD SELECTED RECORDS IN OPNQRYF

**********************************************************************

*_____________________________________________________________________

A R SELECT

*_____________________________________________________________________

A UPUPRF 10 TEXT('USER')

A COLHDG('USER')

A UPUID 10P 0 TEXT('ID')

A COLHDG('ID')

*_____________________________________________________________________

I hope this will help you understanding some of the basics in OPNQRYF.

Page 94 of 228
However there is a small thing usually wrapped in plastic or hidden on a CD called a manual.
This could be a great help but sometimes very hard to understand and with some stupid
examples that don't work. My samples can be typed in on your AS/400 and it works.

Don't hesitate to send a mail if you want more help or want to discuss some of the above
mentioned topics.

BR JPH and GL.

Here are some reference sites:

Database programmers guide

http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/dbp/rbafomst02.htm

http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/dbp/rbafomst199.htm#HDROPNQ
F

http://www.geocities.com/SiliconValley/Hills/6632/opnqryf.html

54. OPNQRY Example

http://publib.boulder.ibm.com/html/as400/v4r5/ic2979/info/db2/rbafomst140.htm#Header_19
9

TESTPF data:

EMPNO EMPNAME EMPPHONE

1 Agnie 1,234,567

2 Amudha 3,456,789

TESTPF1 data:

EMPNUM EMPNAM EMPADDR

1 Agnie Coimbatore

3 Varun Bangalore

Format of OPNQRYRES – Note that it contains the fields of TESTPF as well as TESTPF1

EMPNUM EMPNAM EMPPHONE EMPADDR

SHAILESH/TESTPGMS/TSTOPNQRYF – Program to test OPNQRYF command

PGM

Page 95 of 228
/* To select the records present in TESTPF & TESTPF1 and copy that to a new file (which
contains all the fields of TESTPF and TESTPF1 */

OPNQRYF FILE((SHAILESH/TESTPF) (SHAILESH/TESTPF1)) +

FORMAT(SHAILESH/OPNQRYRES) +

JFLD((TESTPF/EMPNO TESTPF1/EMPNUM *EQ)) +

JDFTVAL(*NO)

CPYFRMQRYF FROMOPNID(TESTPF) TOFILE(SHAILESH/OPNQRYRES) +

MBROPT(*REPLACE) CRTFILE(*YES) FMTOPT(*NOCHK)

CLOF OPNID(TESTPF)

/* To select the records present in TESTPF & not present in TESTPF1 */

OPNQRYF FILE((SHAILESH/TESTPF) (SHAILESH/TESTPF1)) +

FORMAT(SHAILESH/TESTPF) +

JFLD((TESTPF/EMPNO TESTPF1/EMPNUM)) +

JDFTVAL(*ONLYDFT)

CPYFRMQRYF FROMOPNID(TESTPF) TOFILE(QTEMP/RESULT) +

MBROPT(*REPLACE) CRTFILE(*YES) FMTOPT(*NOCHK)

CLOF OPNID(TESTPF)

/* To select the records present in TESTPF1 & not present in TESTPF */

OPNQRYF FILE((SHAILESH/TESTPF1) (SHAILESH/TESTPF)) +

FORMAT(SHAILESH/TESTPF1) +

JFLD((TESTPF1/EMPNUM TESTPF/EMPNO)) +

JDFTVAL(*ONLYDFT)

CPYFRMQRYF FROMOPNID(TESTPF1) TOFILE(QTEMP/RESULT1) +

MBROPT(*REPLACE) CRTFILE(*YES) FMTOPT(*NOCHK)

CLOF OPNID(TESTPF1)

ENDPGM

SQLRPGLE

Page 96 of 228

You might also like