285 pts.
 Multiple member
How to find the records of 5 different members of a file where age field value is 50 in each of the member in CL and RPG?

Software/Hardware used:
ASKED: January 12, 2012  5:04 AM
UPDATED: February 28, 2012  11:54 AM
  Help
 Approved Answer - Chosen by Renjithgr (Question Asker)

My qn was how to read all members one bye one.

It can depend on the version of your OS. Please provide some info on your environment.

CL can read the records from the output file that Phil mentions. You can also use the RTVMBRD command to retrieve member names one at a time. The RTVMBRD command avoids needing to read the DSPFD output file. (You could also use the List Database File Members (QUSLMBR) API to list members in a user space.)

From i 6.1 on, you can do it easier in a single program. If you need to do it in CL earlier than i 6.1, it requires at least two CL programs.

Tom

ANSWERED:  Jan 13, 2012  11:51 PM (GMT)  by Renjithgr

 
Other Answers:

Hi Satheesh,

its not possible to open and close the members one by one. suppose if file have 25 members, its inappropriate. There should be some other method which reads each members and checks.

Renjith

Last Wiki Answer Submitted:  January 12, 2012  9:30 am  by  Renjithgr   285 pts.
Latest Answer Wiki Contributors:  Renjithgr   285 pts. , pdsathishkumar   3,740 pts.
To see other answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

we can do in RPG…
just you declare your file in F spec like this…

 F pfname      if   e             disk    usropn extmbr(var1) 
D var1               s             10a   
C                       eval      var1='mbr1'  
C                       open      pfname        
****** do you operation using setll and read*******
C                       close      pfname

here find age 50 from one member… after again open another member and field age 50..

 3,740 pts.

 

you can open member one by one and read it,
And, check age=50…
eval var1=’MBR1′
open pfname
read pfname
if age=50
dsply age
endif
close pfname
eval var1=’MBR2′
open pfname
read pfname
if age=50
dsply age
endif
close pfname
do like this…….. it ll work… you check it one more time…

 3,740 pts.

 

In CL, have you tried using OVRDBF command, for overriding the Database file to Read records from particular member only.
Once, you done with the required operations, you can use ENDOVR.
And, Override with other Member(if required).

Pradeep.

 3,370 pts.

 

Hi Pradeep,

can you tell, how to access each members differently in CL.
If possible can u show mw some sample codes?

Renjith

 285 pts.

 

Please help on this

 285 pts.

 

Please help on this

What help is needed? An appropriate answer has been given by Pradeep. Use the OVRDBF command to set any member name that you want to read from.

Tom

 108,055 pts.

 

My qn was how to read all members one bye one. Hardcoding doesnot work in this case

 285 pts.

 

Have a CL create a member list using the command:
DSPFD MyLib/MyFile Type(*MBRLIST) OUTPUT(*outfile) Outfile(mylib/myOutFile)

F pfname if e disk usropn extmbr(MLNAME )
F Outfile if e disk

The rpg reads each row from outfile — MLNAME is a field in outfile
Then opens pfname and uses it
Closes pfname
loops to read another row from outfile

 44,150 pts.

 

2 CL’s yes. if one of the cl’s needs to read the outfile

If CL throws the outfile and then calls the RPG IV program
The RPG program can read the outfile and use the extmbr to get the member names and in the one call processes all the members in the file then just 1 cl.

Phil

 44,150 pts.

 

Thanks Philip and Tom

 285 pts.