JRIO performance

General discussion on the JZOS batch launcher and toolkit
Post Reply
Ashirvad Babu
Posts: 11
Joined: Sat May 20, 2006 2:35 am
Location: Chennai, India
Contact:

JRIO performance

Post by Ashirvad Babu »

Hello,
I am trying to read and write MVS data sets. I wanted to know which one would suit me better JRIO or JZOS ZFile..? I know that JRIO is used for MVS record based read. java.io pacakge can only support HFS files.

Please let me know which is best when it comes to MVS read and write.
Is JRIO the only option available or has IBM JAVA SDK got an even better option..? Can index based read and write for MVS files be done using JRIO?
Ashirvad Babu
Tata Consultancy Services Limited
Mailto: ashirvad.babu@tcs.com
Website: http://www.tcs.com
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Either JRIO or the JZOS ZFile interface can be used to do I/O to MVS datasets. The JZOS ZFile class are basically direct wrappers for the C Runtime library I/O functions, whereas JRIO is a heavily abstracted interface for doing record I/O. I can't really say which will suit you better :-)

Refer to the JZOS User's Guide and ZFile Javadocs for more information ZOS.
Ashirvad Babu
Posts: 11
Joined: Sat May 20, 2006 2:35 am
Location: Chennai, India
Contact:

Post by Ashirvad Babu »

thanks for the prompt reply. Well, for JRIO IBM has provided source JRIO source codes. Most of them are running fine when submitted through a JCL. Even for ZFile, IBM has provided few code snippets for reading, wrting and copying into MVS datasets.

http://www-128.ibm.com/developerworks/e ... atchz.html provides the following code snippets for ZFile usage.
These codes have input and ouput MVS data sets hardcoded in the pogram.

//Reading and writing MVS datasets in record mode
ZFile inZFile = new ZFile("//DD:INPUT", "rb,type=record,noseek");
ZFile outZFile = new ZFile("//DD:OUTPUT", "wb,type=record,noseek");
try {
byte[] recBuf = new byte[inZFile.getLrecl()];
int nRead = 0;
while((nRead = inZFile.read(recBuf)) > 0) {
outZFile.write(recBuf, 0, nRead);
}
} finally {
inZFile.close();
outZFile.close();
}

//Reading and writing MVS datasets in stream mode
ZFile inZFile = new ZFile("//DD:INPUT", "rt");
ZFile outZFile = new ZFile("//DD:OUTPUT", "wt");
BufferedReader brdr;
BufferedWriter bwtr;
try {
InputStream istream = inZFile.getInputStream();
InputStreamReader rdr =
new InputStreamReader(istream, ZFile.DEFAULT_EBCDIC_CODE_PAGE);
brdr = new BufferedReader(irdr);

OutputStream ostream = outZFile.getOutputStream();
OutputStreamWriter wtr =
new OutputStreamWriter(ostream, ZFile.DEFAULT_EBCDIC_CODE_PAGE);
bwtr = new BufferedWriter(bwtr);

String line;
while ((line = brdr.readLine()) != null) {
bwtr.write(line);
bwtr.newLine();
}
} finally {
if (brdr != null) brdr.close();
if (bwtr != null) bwtr.close();
}

Could you please provide me with ZFile sample codes, which takes
MVS Data set file names as command line arguments, to read, write and append into MVS data sets.

Please Help!!!
Ashirvad Babu
Tata Consultancy Services Limited
Mailto: ashirvad.babu@tcs.com
Website: http://www.tcs.com
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Please take a look at the JZOS User's Guide and Javadoc for more examples and information on using ZFile.

The arguments to ZFile are -exactly- the same as to the C runtime library fopen() call, which is why the JZOS ZFile documentation refers to the C/C++ library documentation for complete/detailed reference information.

To open a dataset:

ZFile zfile = new ZFile("//'FULLY.QFIED.DSN'", options);

Options is the fopen() "mode" string. You have lots of choices, depending on whether you want to open a file in record mode or in binary/text stream mode. The examples that you show above show both record mode and text mode. Basically record mode is used when you want to do one read() for each record. Text mode opens a stream of data, and inserts line delimiters between the records. A text-mode ZFile is usually used via its java.io.InputStream/OutputStream and java.io wrappers for streams.
orr94
Posts: 22
Joined: Thu Feb 24, 2005 1:28 pm

Post by orr94 »

From personal experience, I can tell you that I very much prefer ZFile and the other JZOS classes to JRIO. The most important difference for me is that the JZOS classes extend the java.io classes, allowing me to treat MVS dataset input/output just like any other input/output in Java. JRIO, on the other hand, does NOT extend the java.io classes. For several years, this was a major frustration for me, and I was very glad to discover JZOS.
Ashirvad Babu
Posts: 11
Joined: Sat May 20, 2006 2:35 am
Location: Chennai, India
Contact:

Post by Ashirvad Babu »

hi orr94,

I'm sorry for the delayed reply.. Well, I am currently using JZOS for MVS reads and writes... Yu're right, JRIO has got many restrictions whn compared to JZOS..

Thanks for your reply...
Ashirvad Babu
Tata Consultancy Services Limited
Mailto: ashirvad.babu@tcs.com
Website: http://www.tcs.com
rahul_krg
Posts: 2
Joined: Mon Mar 03, 2008 10:46 am

ZFile read

Post by rahul_krg »

Hi,

Since you are using the JZOS since long time, I'm seeking some help from you. I'm aslo using it for MVS dataset access. I need to get the record count of MVS datasets. I've tried opening the ZFile in record mode and using the method "getRecordCount()". But it alwaysreturns me ZERO.
Can you please help me out, i'm stucked very badly.

The ZFile initialization code I'm using is:

Code: Select all

 ZFile zfile = new ZFile("//'INPUT.DAT'", "rb,type=record,noseek");
 count = zfile.getRecordCount();                            
Is ther eany issue with the code ?? IS there any alternative method to get the record count for the ZFile???

Thanks,

Rahul G
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

The method ZFile.getRecordCount only counts the number of records that you have read or written using the ZFile api. It doesn't give you a count of the number of records in an existing dataset.

JZOS ZFile uses the C library, and as far as I know there is not an API in the C library to get a record count of an existing dataset.
rahul_krg
Posts: 2
Joined: Mon Mar 03, 2008 10:46 am

Post by rahul_krg »

Thanks for the help. So getRecordCount() can't be used to count the number of records in the dataset.

So is there some better way of getting record count?

Thanks.

Rahul G
coz
Posts: 391
Joined: Fri Jul 30, 2004 5:29 pm

Post by coz »

Take a look at ZFile.seek() and tell()
Post Reply