Ü  OVRDBF

·         This command is used to override the attribute of a physical file.

·         By using this command we can make our program to use some other file for the one actually named to be used in the program.

·         All overrides are temporary and are effective until where the override command has been in scope.

·         The format of this command is:

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(ACCOUNT) POSITION(*START)
It positions the cursor at the beginning of the file.

 

OVRDBF  FILE(CUST) TOFILE(AMIT/CUST) POSITION(*RRN 21)
It positions the cursor at relative record number 21 of the file.

 

 
OVRDBF  FILE(ACCOUNT) TOFILE(IROBO1/ACCOUNT) POSITION(*KEY 1 *N X'192F')
It positions the cursor at record number where key-field is 192 decimal value.
Here only one key-field has been used, yet we can use multiple key-fields. 
If we use 2 key fields here, then the command would be something like below:
OVRDBF  FILE(ACCOUNT) TOFILE(IROBO1/ACCOUNT) POSITION(*KEY 2 *N HEX-VALUE')

 

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.

OVRDBF     FILE(ACCOUNT) TOFILE(IROBO1/ACCOUNT) SHARE(*YES) 

 

 

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:


       CSNBR   CSNAME      CS#OPN          CS$OPN
000001 000001  MMM              0             .00
000002 000002  upi              0             .00
000003 000003  KUM              0             .00
000004 000004  RAHIN       12,256      454,654.51
000005 000005  HARISH         980      798,789.00
000006 000006  RAJESH         560      754,555.00
000007 000007  RONYSH         888      755,555.00
000008 000008  KUNINA         447      755,555.00
000009 000009  SHIUNA         222      744,444.00

 

                   


OUTPUT

              

                                               
                           Display Program Messages                            
                                                                               
 DO U WANT TO CONTINUE FILE READING                                            
 Y                                                                             
 000005       HARISH.                                                          
 DO U WANT TO CONTINUE FILE READING                                            
 Y                                                                              
 000006       RAJESH.                                                          
                                                                               
 Press Enter to continue.                                                       
                                                                               

 F3=Exit   F12=Cancel      




 

Example-II: POSITION example

 


Columns . . . :    1 100                   Edit                             IROBO1/QRPGLESRC
SEU==>                                                                            OPNQRYF_C5
FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+
*************** Beginning of data ****************************************************
0001.00 PGM
0002.00              DCL        VAR(&VAR1) TYPE(*CHAR) LEN(35)
0003.00              DCL        VAR(&CHAR1) TYPE(*CHAR) LEN(3)
0004.00              DCL        VAR(&REPLY) TYPE(*CHAR) LEN(1) +
0005.00                           VALUE('N')
0006.00              DCLF       FILE(IROBO1/ACCOUNT)
0007.00              MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(END2))
0008.00 READ:
0009.00              OVRDBF     FILE(ACCOUNT) TOFILE(IROBO1/ACCOUNT) +
0010.00                           POSITION(*KEY 1 *N X'192F')
0011.00              OPNDBF     FILE((ACCOUNT)) OPTION(*INP) OPNID(ID1)
0012.00
0013.00 CONTINUE:
0014.00              RCVF
0015.00              MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(END1))
0016.00              CHGVAR     VAR(&CHAR1) VALUE(&ORG)
0017.00              CHGVAR     VAR(&VAR1) VALUE(&CHAR1||'       '|| +
0018.00                         &ACC||'      '||+
0019.00                         &CCY||' ')
0020.00              SNDUSRMSG  MSG('DO U WANT TO CONTINUE FILE READING') +
0021.00                           MSGRPY(&REPLY)  VALUES('Y' 'N')
0022.00
0023.00              IF   (&REPLY='Y') DO
0024.00              SNDUSRMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&VAR1) +
0025.00                           MSGTYPE(*INFO)
0026.00              GOTO       CMDLBL(CONTINUE)
0027.00              ENDDO
0028.00              ELSE  DO
0029.00              GOTO       CMDLBL(END2)
0030.00              ENDDO
0031.00 END1:
0032.00              SNDUSRMSG  MSG('THE END OF FILE IS REACHED')
0033.00 END2:
0034.00              DLTOVR     FILE(ACCOUNT)
0035.00              CLOF       OPNID(ID1)
0036.00
0037.00 ENDPGM
****************** End of data *******************************************************

 

DATABASE File used in the program: ACCOUNT

 

       ORG   ACC           CCY  PARTY
000001 190   A00000000001  CCY  P00000000001
000002 191   A00000000002  EUR  P00000000002
000003 192   A00000000003  USD  P00000000003
000004 192   A00000000004  TRY  P00000000004
000005 190   A00000000005  INR  P00000000005
000006 190   A00000000006  TRY  P00000000006
000007 192   A00000000007  INR  P00000000007
000008 191   A00000000008  GBP  P00000000002
000009 191   A00000000009  USD  P00000000001
000010 195   A00000000010  EUR  P00000000003
000011 193   A00000000011  TRY  P00000000005
000012 192   A00000000012  EUR  P00000000002
000013 190   A00000000013  EUR  P00000000009
000014 191   P00000000014  USD  P00000000004
000015 192   A00000000015  INR  P00000000010
000016 192   A00000000016  GBP  P00000000011
000017 192   A00000000017  AZK  P00000000017
000018 191   A00000000018  EUR  P00000000014
000019 190   P00000000019  EUR  P00000000015

 

OUTPUT


                                  Display Program Messages
 
DO U WANT TO CONTINUE FILE READING
Y
192       A00000000003      USD.
DO U WANT TO CONTINUE FILE READING
Y
192       A00000000004      TRY.
DO U WANT TO CONTINUE FILE READING
Y
192       A00000000007      INR.
DO U WANT TO CONTINUE FILE READING
Y
192       A00000000012      EUR.
DO U WANT TO CONTINUE FILE READING
Y
192       A00000000015      INR.
DO U WANT TO CONTINUE FILE READING
Y
192       A00000000016      GBP.
DO U WANT TO CONTINUE FILE READING
Y
192       A00000000017      AZK.
 
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.

 

 
Columns . . . :    1 100                    Edit                           IROBO1/QRPGLESRC
 SEU==>                                                                          OPNQRYF_C2
 FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 .
        *************** Beginning of data *************************************************
0001.00 PGM
0002.00              DCL        VAR(&VAR1) TYPE(*CHAR) LEN(35)
0003.00              DCL        VAR(&CHAR1) TYPE(*CHAR) LEN(3)
0004.00              DCL        VAR(&REPLY) TYPE(*CHAR) LEN(1) +
0005.00                           VALUE('N')
0006.00              DCLF       FILE(IROBO1/ACCOUNT)
0007.00              MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(END2))
0008.00 READ:
0009.00              OVRDBF     FILE(ACCOUNT) TOFILE(IROBO1/ACCOUNT) SHARE(*YES)
0010.00              OPNQRYF    FILE((ACCOUNT)) OPTION(*ALL) QRYSLT('ORG *EQ +
0011.00                           190') OPNID(ID1)
0012.00 CONTINUE:
0013.00              CALL       PGM(ORG190)
0014.00              SNDUSRMSG  MSG('THE END OF FILE IS REACHED')
0015.00 END2:
0016.00              DLTOVR     FILE(ACCOUNT)
0017.00              CLOF       OPNID(ID1)
0018.00 ENDPGM
        ****************** End of data ***************************************************

 

 

 

Called Program ORG190

 

 


Columns . . . :    1 100            Browse                       IROBO1/QRPGLESRC
 SEU==>                                                                    ORG190
 FMT FX .....FFilename++IPEASF.....L.....A.Device+.Keywords+
        *************** Beginning of data ******************
0001.00      FACCOUNT   IF   E           K DISK
0002.00      FDSP2      CF   E             WORKSTN
0003.00       *
0004.00      C                   DOW       *IN03=*OFF
0005.00      C   03              LEAVE
0006.00      C                   READ      ACCOUNT
0007.00      C                   IF        %EOF(ACCOUNT)
0008.00      C                   LEAVE
0009.00      C                   ENDIF
0010.00      C                   EVAL      S_PARTY=PARTY
0011.00      C                   EVAL      S_ORG=ORG
0012.00      C                   EVAL      S_ACC=ACC
0013.00      C                   EVAL      S_CCY=CCY
0014.00      C
0015.00      C                   WRITE     HEADER
0016.00      C                   WRITE     DETAIL
0017.00      C                   WRITE     FOOTER
0018.00      C                   READ      HEADER
0019.00      C                   ENDDO
0020.00      C                   SETON                                        LR
       ****************** End of data **********************************

 

 

 

Display file used in the program ORG190 

 

 


Columns . . . :    1 100                     Edit                           IROBO1/QRPGLESRC
 SEU==>                                                                                 DSP2
 FMT A* .....A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ..
        *************** Beginning of data *************************************************
0000.30      A                                      DSPSIZ(24 80 *DS3)
0000.40      A                                      CA03(03 'EXIT')
0000.50      A          R HEADER
0000.60      A                                  3 27'ACCOUNT REALATED INFORMATION'
0000.70      A                                  3  1USER
0000.80      A                                  3 73DATE
0000.90      A                                      EDTCDE(Y)
0001.00      A                                  4 73TIME
0001.10      A          R DETAIL
0001.30      A                                      OVERLAY
0001.40      A                                  7 14'PARTY NUMBER....'
0001.50      A                                  8 14'ORG CODE........'
0001.60      A                                  9 14'ACCOUNT NUMBER..'
0001.70      A                                 10 14'CURRENCY........'
0001.80      A            S_PARTY       12A  O  7 34
0001.90      A            S_ORG          3S 0O  8 34
0002.00      A            S_ACC         12A  O  9 34
0002.10      A            S_CCY          3A  O 10 34
0002.20      A          R FOOTER
0002.30      A                                      OVERLAY
0002.40      A                                 23  2'F3 = EXIT'
        ****************** End of data ****************************************************


 

 

DATABASE File used in the program: ACCOUNT

 

       ORG   ACC           CCY  PARTY
000001 190   A00000000001  CCY  P00000000001
000002 191   A00000000002  EUR  P00000000002
000003 192   A00000000003  USD  P00000000003
000004 192   A00000000004  TRY  P00000000004
000005 190   A00000000005  INR  P00000000005
000006 190   A00000000006  TRY  P00000000006
000007 192   A00000000007  INR  P00000000007
000008 191   A00000000008  GBP  P00000000002
000009 191   A00000000009  USD  P00000000001
000010 195   A00000000010  EUR  P00000000003
000011 193   A00000000011  TRY  P00000000005
000012 192   A00000000012  EUR  P00000000002
000013 190   A00000000013  EUR  P00000000009
000014 191   P00000000014  USD  P00000000004
000015 192   A00000000015  INR  P00000000010
000016 192   A00000000016  GBP  P00000000011
000017 192   A00000000017  AZK  P00000000017
000018 191   A00000000018  EUR  P00000000014
000019 190   P00000000019  EUR  P00000000015

 

 

 

 

OUTPUT

 

 

 

                                                                             
IROBO                     ACCOUNT REALATED INFORMATION                   4/28/13
                                                                        12:59:20
                                                                               
                                                                                
             PARTY NUMBER....    P00000000001                                  
             ORG CODE........    190                                           
             ACCOUNT NUMBER..    A00000000001                                  
             CURRENCY........    CCY                                           
                                                                               
                                                                       
                                                                               
 F3 = EXIT 

 

 

We press Enter to get the second record.


IROBO                     ACCOUNT REALATED INFORMATION                   4/28/13
                                                                        13:00:47
                                                                               
                                                                               
             PARTY NUMBER....    P00000000005                                  
             ORG CODE........    190                                           
             ACCOUNT NUMBER..    A00000000005                                  
             CURRENCY........    INR                                           

                                                                               
                                                                               
                                                                                
 F3 = EXIT                         

 




 

 







User Comments:



Subscribe

.  


Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy