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?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to handle duplicate error handling in RPG?

1668


write an RPG program to calculate the marks of 5 students (A,B, C, D, E)in 3 different subjects (eng, math, sci) an display on the screen

824


is this a rpg channel?

669


do you use message subfiles? What are the necessary keywords required coding a message subfile?

681


1.Load an runtime array of length 99 from the pf and you want to handle all the possible errors?

2364






how can I tell when to replace the array?

692


what is the procedure and explain about real time scenario.

1471


What is the difference between copybooks and subprocedures in as400?

801


explain sflclr, sflend, sfldlt, and sflcsrrrn?

880


what is a rpg?

694


What is the diff bw PF/LF Name and their Record format name? what is restriction in record format then file name?

2513


what is file information data structure?

1355


can I touch the array during treatments?

750


what is the rpg system?

660


what are the key words you must use when using a subfile?

684