I have a Physical File name 'File1', which is present in
two libraries named 'LIB1' & 'LIB2'. These 2 libraries are
listed in the library list. Would like to access data from
this file from these two libraries using RPG program. How
to do this, any idea?
Answers were Sorted based on User's Feedback
Answer / swetha p rao
1. Declare the file File1 in Useropen mode and use OVRDBF
with that library name before you open the file through
QCMDEXC
OVRDBF (LIB1/FIle1) SHARE(*YES)
Open File1
Read File1
.....
Close File1
OVRDBF (LIB2/FIle1) SHARE(*YES)
Open File1
Read File1
.....
Close File1
(or)
Use SQLRPGLE ,Declare a cursor for both files
c+ exec-sql
c+ Declare Cursor C1
c+ Select * from LIB1/File1
c+ End exec
c+ exec-sql
c+ Declare Cursor C2
c+ Select * from LIB2/File1
c+ End exec
Correct me if iam wrong
| Is This Answer Correct ? | 15 Yes | 1 No |
Answer / divakar reddy
F FILE1 IF A E K DISK ExtFile('LIB1/FILE1')
RENAME(file1:Afile1)
F FILE1 IF A E K DISK ExtFile('LIB2/FILE1')
RENAME(file1:Bfile1)
This should work...
| Is This Answer Correct ? | 9 Yes | 1 No |
Answer / manan
actually the first answer will only work in sequential
execution in CL or SQLRPG. But if we wanna to use
simultaneously in the RPG then the CL will be OVRDBF FILE 1
to LIB1 and for the file 2 Use some other file FILEXXX and
OVRDBF it to LIB2/FILE1 and in RPG use the FILEXXX so when
u refer to any operation in FILEXXX that will reflect to
FILE1 in LIB2.
Other options for RPG4 are also correct ie usinf the
EXTFILE.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / syam
In RPG use this
F FILE1 IF A E K DISK RENAME(file1:Afile1)
F FILE1 IF A E K DISK RENAME(file1:Bfile1)
In read, open and close use Afile1 and Bfile1
| Is This Answer Correct ? | 2 Yes | 18 No |
What are different ways to pass data between programs and which one is the efficient way?
1.The questions have given an array declaration and move operation then this statement is correct or not?
As Packed veriable store 2 digits in 1 byte and ZONE variable store 1 digit in 1 byte... Please tell me when we have to use Packed and Zone variable...?
How to update physical file in rpgle without using display file?
Hi, I am getting the error in RPG (All Record Formats for externally-described file ABCD ignored or dropped due to error; file ignored.) Please suggest any
In RPG program one file using as a PRIMARY file while running program some of the records reading twice any body know why its happening
I have file with data as follows data 1 2 3 4 5 I need to read 1 and 5 ,then 2 and 4 then like.. upto end of file, can any one help on this
what are the types of identifers
In a particular program one file is used where override command is applied to a file, now this program calls another program where we want to use the same file but without override.How it can be done?
1.Can any body share me about thease opcodes with example please.Im new for AS/400.Could u please tell me in real senario? 1.TESTN, 2.EVAL 3.EVALR, TIME, 4.MONITOR 5. ENDMON 6.ON-ERROR 7.COMMIT ROLLBACK?
how can an indexed file be used as arrival sequence in RPG?
What is I90(Insure 90)?