File Tofile MBR:: The File Name That Is To Be Used in Place of The Source File
File Tofile MBR:: The File Name That Is To Be Used in Place of The Source File
OVRDBF FILE(overridden-file-name) +
TOFILE(library name/database file name)+
MBR(member name) +
POSITION(file positioning option) +
SECURE(secure from previous override) +
SHARE(open data path sharing option) +
OVERSCOPE(file override scope)
File : The file name that is to be overridden.
TOFILE : The file name that is to be used in place of the source file.
MBR : The member name that overrides the opened file member. The possible values
are:
*FIRST: The first member will be used for overriding.
*LAST: The last member will be used for overriding.
*ALL: All members will be opened with the same overriding parameter and will
be processed
one by one.
POSITION : This identifies the current cursor file of the file. Generally when the file is opened
the cursor is positioned at the beginning of the file. But if we want the file cursor to point at
some other record, then we can use this attribute.
Starting position in file:
Retrieve order . . . . . . . . > *KEY *NONE, *START, *END, *RRN...
*RRN-rcd nbr *KEY-nbr key flds > 1 Number
*KEY-rec format having key . . _________ Name
*KEY-key value . . . . . . . . > X'192F'___________________________________________
__________________________________________________
We can potion the cursor based on Retrieving order which can be *START, *END, *RRN,
*KEYB, *KEYBE, *KEY, *KEYAE, *KEYA.
OVRDBF FILE(CUST) TOFILE(AMIT/CUST) POSITION(*RRN 21)
It positions the cursor at relative record number 21 of the file.
SHARE : Languages other than CL cannot make dynamic access path or in other words
cannot perform dynamic record selection. If we want other programs like RPG also to
perform dynamic record selection, we can share the access path of the file (that we create in
CL) with the RPG program.
To share the access path we create an open data path in our CL program with OPNQRYF
command and then we share this ODP with the called RPG program. This sharing is done
with the help of SHARE (*YES) in the OVRDBF command.
Example-I: RRN example
Columns . . . : 1 80 Edit
AMITCCCCC/QRPGLESRC
SEU==>
READFILEO
FMT ** ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+...
7 ...+... 8
*************** Beginning of data
***********************************************
0001.00 PGM
0002.00 DCL VAR(&VAR1) TYPE(*CHAR) LEN(20)
0003.00 DCL VAR(&REPLY) TYPE(*CHAR) LEN(1) +
0004.00 VALUE('N')
0005.00 DCLF FILE(AMIT/CUST)
0006.00 READ:
0007.00 OVRDBF FILE(CUST) TOFILE(AMIT/CUST) POSITION(*RRN
5)
0008.00
0009.00 OPNDBF FILE(AMIT/CUST) OPTION(*INP) OPNID(ID1)
0010.00 MONMSG MSGID(CPF4174) EXEC(GOTO CMDLBL(CONTINUE))
0011.00 CONTINUE:
0012.00 RCVF
0013.00 MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END1))
0014.00 CHGVAR VAR(&VAR1) VALUE(&CSNBR||' '|| +
0015.00 &CSNAME||' '||+
0016.00 ' ')
0017.00 SNDUSRMSG MSG('DO U WANT TO CONTINUE FILE READING') +
0018.00 MSGRPY(&REPLY) VALUES('Y' 'N')
0019.00
0020.00 IF (&REPLY='Y') DO
0021.00 SNDUSRMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&VAR1)
+
0022.00 MSGTYPE(*INFO)
0023.00 GOTO CMDLBL(READ)
0024.00 ENDDO
0025.00 ELSE DO
0026.00 GOTO CMDLBL(END2)
0027.00 ENDDO
0028.00 END1:
0029.00 SNDUSRMSG MSG('THE END OF FILE IS REACHED')
0030.00 END2:
0031.00 DLTOVR FILE(CUST)
0032.00 CLOF OPNID(ID1)
0033.00 ENDPGM
****************** End of data
**************************************************
Below is the PHYSICAL FILE(CUST) used in the program:
OUTPUT
F3=Exit F12=Cancel
Example-II: POSITION example
DATABASE File used in the program: ACCOUNT
OUTPUT
Display Program Messages
F3=Exit F12=Cancel
Example-III: OPNQRYF example
Below is the CL program that first of all creates one ODP and then
shares it with the called program ORG190.
DATABASE File used in the program: ACCOUNT
OUTPUT
12:59:20
F3 = EXIT
We press Enter to get the second record.
13:00:47
F3 = EXIT