unable to modify/append records in a PS file using JRIO..

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:

unable to modify/append records in a PS file using JRIO..

Post by Ashirvad Babu »

Hi all,

Its difficult to describe the problem I am facing.. Well, this is how it goes..

I am trying to modify/append few records in an already existing PS File, using JRIO. I've opened the file to be modified in "rw" mode. Each time I try to modify/append, file, it wipes away all the record in the file to be modified and writes the record.

Trying to overcome this problem, I gave a DD:INPUT, in the java program, while opening the PS Dataset. In the JCL, I modfied the DISP parameter for the DD statement as MOD; hoping that this would solve my problem. Well, the program compliles and runs well, when submitted in JZOS..Its able to find the associated Data set with the DD statement. But it is not able to find any record.. (It says "no bytes found in data set").

Can any one of yu help me?

I'll send the code snippets if necessary for better understanding.

Thanks for reply..!
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 »

Sorry again to have to remind you that we don't explicitly support JRIO (we don't use it, since the JZOS toolkit (ZFile class) does similar things...better). Perhaps some other forum member can help you with JRIO (but I assume that most of them use JZOS instead of JRIO too :-)

You would have to contact IBM Support for JRIO questions or defects.

But, if you want to try JZOS ZFile to solve your problem, we'd be happy to help. Basically, with ZFile you have access to the same APIs as a C programmer.... so using the IBM C/C++ programming guide, you can pretty easily update records in a a PS dataset.

The pertinent section in the C/C++ programming guide is titled "Using fseek() and ftell() in record files". Also see the C++ library reference for specifics on mode parameters on fopen(). Getting the first part of the open mode string is critical to getting it to work correctly, so read the library reference on fopen() carefully.

But as usual, I would assume you would like to skip all of the manual reading and see a code example. Here goes:

Code: Select all

   
   ZFile zfile = new ZFile("//DD:MYDD", "r+b,type=record");
   zfile.seek(10, ZFile.SEEK_SET);   
   zfile.write(bytes);   // update a record

   zfile.seek(0, ZFile.SEEK_END);
   zfile.write(bytes);  // append a record

Some observations about using ZFile:

o The JZOS source code and Java doc for everything in ZFile clearly states what C library routines are used. The z/OS C/C++ documentation is excellent and has all the information you need to handle all sorts of I/O models (text/ binary stream/record files; HFS/ MVS Datasets, etc).

o Exceptions are thrown which contain all of detailed return codes, reason codes, etc that you might want to use to manage recovery and error processing

o Its pretty easy to use
[/list]
Post Reply