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 |
Hi guys, anybody know How RPG/400 code can be converted to RPG IV code with a single command?
can anybody explain significance of *loval setll with example code????
What is SFLNXTCHG keyword why it has used and where? Briefly explain with Example.
two types of read performed in dataqueue?????
How do you know if a record exists without doing a READ and CHAIN?
Suppose we have 10 records with same name and we are reading using READE,after 4 record i have to use CHAIN what is the output
Suppose my file has 10 fields and I want to make the 2nd field zeros in all records. And assume I have millions of records and I dont want to read each record and update the desired field with 0. Any other way to do this in one step operation?
How can we find out whether the job is interactive or Batch through RPG program? 2) How can we find out through CL program?
How to find d key field of a pf that doesn’t have source physical file?
If my rpg program has a date field, what extra care I have to take while compiling that rpg program? If the file is keyed and I have declared the file as well as key list properly in my program. Still am getting an error message like "chain/reade operation is not allowed" what may be the case?
what is estimation? and what is the level identifier parameter in PF?
How Commitment and Roll back control is used in as400, explain with real time senario ???