Reading ASA datasets

General discussion on the JZOS batch launcher and toolkit
Post Reply
bilbozos
Posts: 18
Joined: Wed Jan 18, 2006 5:53 am

Reading ASA datasets

Post by bilbozos »

Hi List!

I am trying the JZOS API before going into production with JZOS. In the production environment IBM's JRIO package is currently used. A Java batch process converts data from ASA datasets into PDF files.

My problem, for the time being, is when reading ASA datasets. The Java batch program needs to read the ASA control characters to know what to do (form feed, line feed, etc). Using a BufferedReader from FileFactory does not work because FileFactory opens the dataset as text. Since internally C/C++ routines are used, when reading ASA text files, the C/C++ routines make internal translations of those control characters and the Java program does not receive them, it reads the transformations.

I have tried to open the dataset as a ZFile("rb,type=record"), but this then reads all the content as a line.

I'm a bit stuck. Could somebody help me work this out?

Any hint or suggestion would be highly appreciated.

Aitor.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

I have tried to open the dataset as a ZFile("rb,type=record"), but this then reads all the content as a line.
If you use ZFile in record mode, then the ZFile read method will return a MVS record as a byte array. Perhaps you are trying to wrap the record-mode ZFile in a BufferedReader? This won't work, since the BufferedReader will put together records until a new line is found, which is probably never if you open in "rb" mode. As specified in the javadoc, the stream/readers for ZFiles are only for text file processing. If you want to process the file in record mode, then you need to use the ZFile read method directly.

For example:

Code: Select all

     ZFile zFile = new ZFile("//DD:INPUT", "rb,type=record,noseek");
     try {
         byte[] recBuf = new byte[zFile.getLrecl()];
         int nRead;
         while((nRead = zFile.read(recBuf)) > 0) {
            String record = new String(recBuf,0,nRead, 
                                     ZFile.getDefaultPlatformEncoding());
            // now 'record' contains a single record from the dataset
            // the first character would be the ASA control 
         };     
     } finally {
        zFile.close();
     }
bilbozos
Posts: 18
Joined: Wed Jan 18, 2006 5:53 am

Reading ASA datasets

Post by bilbozos »

I was a bit stuck, yes.

Ok, thanks for the explanation.

Regards.
Post Reply