Finding out the name of a tape dataset



Support for Java SE, EE & ME, JVM, JNI, JDBC, EJB, JFC, JPDA, JAAS,JCE, JAXP, XML and Java API.

Finding out the name of a tape dataset

Postby olivermf » Wed Sep 14, 2011 3:31 pm

Hello together,

I am not getting much answers in this forum regarding questions about java, but I will try another one ;-)

I want to use DFSort out of Java. I tested it with PS-Files and used the following code to resolve the DNS-name through a ZFile-Object:
ZFile file = new ZFile("//DD:SYS020", "rt");
String fileName = file.getActualFilename();
List<String> data= new ArrayList<String>();

DfSort dfSort = new DfSort();
dfSort.addAllocation("alloc fi(sortin) da('" + fileName + "') reuse shr msg(2)");
dfSort.setOutputStreamRecLen(1024);
dfSort.addControlStatement("SORT FIELDS=COPY");
dfSort.execute();
BufferedInputStream bis = new BufferedInputStream(
dfSort.getChildStdoutStream());
byte[] bytes = new byte[1024];
while (readRecord(bis, bytes)) {
   // Process data
   data.add(new String(bytes, "cp1047"));
}
bis.close();



What I want to do now is using DFSort with tapes.
I tried direct DFSort with JCL, this works.

But trying to get the filename of a tape using the getActualFileName()-method of ZFile always returns null.
Even if I code the name of the tape dsn directly in Java I get the error message "No Sortin defined".


Does someone have any ideas?

Thanks in advance,

Regards

Oliver
olivermf
 
Posts: 53
Joined: Tue Feb 08, 2011 4:28 pm
Has thanked: 3 times
Been thanked: 0 time

Re: Finding out the name of a tape dataset

 

Re: Finding out the name of a tape dataset

Postby dick scherrer » Wed Sep 14, 2011 9:40 pm

Hello,

I am not getting much answers in this forum regarding questions about java,
Because more than 99% of the Java work is not on the mainframe. . . I suspect this will change over time.

dfSort.addAllocation("alloc fi(sortin) da('" + fileName + "') reuse shr msg(2)");
How is the value of "filename" established?

What happens if you reverse the order of the single- double-quotes?

Not part of your question, but does there need to be a sortout allocated?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6269
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Finding out the name of a tape dataset

Postby Ed Goodman » Thu Sep 15, 2011 12:17 am

I'd bet the addallocation method has a return code. Can you check it?
If I were in your shoes, I would try a couple of experiments:
) Use some other file open routine to open the same file
) Try your existing code with a DASD dataset to see if it works
) check for limitations in the java manual for file.getActualFilename

Read this from the IBM Javadoc:
getActualFilename

   1. public java.lang.String getActualFilename( )
   2. throws ZFileException

Get the actual name of the opened file as returned by the fldata() C library function in the fldata_t.__dsname field.

According to the C++ Runtime library reference: If the file is a DASD data set or a memory file, the field __dsname contains the dsname. If the file is an HFS file, the field __dsname contains the pathname. For all other files, it is null.
Returns:
the actual name of the native file
Throws:
ZFileException

Ed Goodman
 
Posts: 342
Joined: Thu Feb 24, 2011 12:05 am
Has thanked: 3 times
Been thanked: 17 times

Re: Finding out the name of a tape dataset

Postby dick scherrer » Thu Sep 15, 2011 1:11 am

Hello,

Where does the mainframe actually execute your Jave?

I ask because on most systems, programmers are not permitted to allocate tape drives/files in tso or cics.

Are there any tape drives available in the environment where you are executing?

While working thru the issues with using a tape, you might test with a hard-coded DSN rather than trying to dynamically determine the dataset name.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6269
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Finding out the name of a tape dataset

Postby olivermf » Thu Sep 15, 2011 1:57 pm

Hello and thank you very much for you replies.

First Dick Sherrer's questions:
How is the value of "filename" established?


I instantiate a ZFile-Object like this:
ZFile file = new ZFile("//DD:SYS020", "rt");


And then I use the getActualFilename()-Method:

String fileName = file.getActualFilename();


With "normal" Datasets this method returns the right value for the filename, but using it with our tapes getActualFilename() returns null.

So what I need to begin with is something to resolve the filename from my JCL DD-Statement out of perhaps without using the ZFile-class.

JCL:
//SYS020 DD DSN=TAPE.NAME(0)


Where does the mainframe actually execute your Java?
I ask because on most systems, programmers are not permitted to allocate tape drives/files in tso or cics.

I execute the Java with JCL using the custom JZOS-launcher. The tapes can be accessed with my user-id if I use "normal" DFSort out of JCL...

Are there any tape drives available in the environment where you are executing?


I am not sure, what you mean with this question. We have several tapes that I can read from, so I think the "tape drives" are available. If this question aims on how our tape drives are installed in our environment, I must say that I have no idea :-)

Not part of your question, but does there need to be a sortout allocated?


I use the data in my Java program to generate PDF from it, so I use the getChildStdoutStream()-method to instantiate a BufferedInputStream and add the data to a simple list to use it later.


Now the questions of Ed Goodman:

I'd bet the addallocation method has a return code. Can you check it?

When I try to get the Return-Code of the dfSort-Object I get the following messages:

JVMJZTK1039E Child shell process received signal: 18

com.ibm.jzos.RcException: child process received signal RC=-2 (0xfffffffe)
at com.ibm.jzos.Spawn.waitPid(Native Method)
at com.ibm.jzos.Spawn.waitChild(Spawn.java:69)
at com.ibm.jzos.DfSort.getReturnCode(DfSort.java:342)
at myClass.getData(myClass.java:187)
at myClass.main(myClass.java:115)

) Use some other file open routine to open the same file
) Try your existing code with a DASD dataset to see if it works

First: My existing code works with DASD-datasets.
What other open routine do you mean? The IRecordFile-Class has no method to resolve the filename,
so it is useless for me here. The FileFactory-Class only returns Streams and BufferedReaders/Writers.
That does not help me, too, or do I miss something?
) check for limitations in the java manual for file.getActualFilename

The Java manual says:

According to the C++ Runtime library reference: If the file is a DASD data set or a memory file, the field __dsname contains the dsname. If the file is an HFS file, the field __dsname contains the pathname. For all other files, it is null.

Is this already the answer? Is a tape dataset not like DASD? In the manuals I always find DASD and tapes described together for the fopen()-routine, that is used here...



Thank you very much for your help, I will try to do some other experiments now. Perhaps I will find something.

Regards,

Oliver
olivermf
 
Posts: 53
Joined: Tue Feb 08, 2011 4:28 pm
Has thanked: 3 times
Been thanked: 0 time

Re: Finding out the name of a tape dataset

Postby olivermf » Thu Sep 15, 2011 3:23 pm

Hello,

I have tried another way.
I coded the fully qualified name of the tape (TAPE.NAME.G000XV00) directly into my Java Code.
Now I get the following Dump:

11.34.15 JOB18826  IEA995I SYMPTOM DUMP OUTPUT  757                             
   757               USER COMPLETION CODE=0023                                 
   757              TIME=11.34.15  SEQ=40083  CPU=0000  ASID=0190               
   757              PSW AT TIME OF ERROR  078D1000   00D23308  ILC 2  INTC 0D   
   757                ACTIVE LOAD MODULE           ADDRESS=00D14000  OFFSET=0000F308
   757                NAME=ICEMAN                                               
   757                DATA AT PSW  00D23302 - 41A0C718  0A0D9602  D3CD9180     
   757                AR/GR 0: A32A358A/00000000   1: 00000000/80000017         
   757                      2: 00000000/00000017   3: 00000000/00D232B2         
   757                      4: 00000000/00000050   5: 00000000/0000C3BF         
   757                      6: 00000000/0000F7C0   7: 00000000/40D26784         
   757                      8: 01FF000C/00D23C00   9: 00000000/40D26B04         
   757                      A: 01FF000C/00D23318   B: 00000000/00D21C00         
   757                      C: 00000000/00D22C00   D: 00000000/0000E000         
   757                      E: 00000000/00D232B0   F: 00000000/00000010         
   757              END OF SYMPTOM DUMP                                         


This completion code is documented in several systems. Could it be this?


he system catalog entry for the data set found on the designated volume has
a different volume. This copy is regarded as a disconnected data set.
olivermf
 
Posts: 53
Joined: Tue Feb 08, 2011 4:28 pm
Has thanked: 3 times
Been thanked: 0 time

Re: Finding out the name of a tape dataset

Postby NicC » Thu Sep 15, 2011 3:25 pm

Just to say - a tape is tape like your old cassette tape type thing (but vastly different) and dasd is disk as in hard drive on PCs. Completely different animals.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2867
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 126 times

Re: Finding out the name of a tape dataset

Postby olivermf » Thu Sep 15, 2011 4:38 pm

Hello NicC,

I know what tapes are and that they are different to dasd.

What I do not know is, why DFSort can use them when you use them as SORTIN in normal JCL and cannot use them when you use them as SORTIN in DFSort called out of Java...

Do I need perhaps need different parameters?

So I have two problems:

1) I cannot resolve the name of a tape dataset with the class ZFile.

JCL:
//SYS020 DD DSN=TAPE.NAME(0),DISP=SHR

JAVA:
ZFile file = new ZFile("DD:SYS020","rt"); //file.getActualFilename() returns null

2) I cannot call a tape from DFSort within Java:

dfSort.addAllocation("alloc fi(sortin) da('TAPE.NAME.G000XV00') reuse shr msg(2)");


Regards,

Oliver
olivermf
 
Posts: 53
Joined: Tue Feb 08, 2011 4:28 pm
Has thanked: 3 times
Been thanked: 0 time

Re: Finding out the name of a tape dataset

Postby Robert Sample » Thu Sep 15, 2011 4:59 pm

From the z/OS system standpoint, tape and DASD have similarities and differences. DASD files can be accessed simultaneously by different users. Tape files must be accessed by one user at a time -- the tape drive cannot be reading two different spots on the tape at the same time. Tape drives (and hence tape files) typically cannot be allocated by a TSO user, whereas DASD files can be allocated by a TSO user -- although that can be affected by site procedures.

What I do not know is, why DFSort can use them when you use them as SORTIN in normal JCL and cannot use them when you use them as SORTIN in DFSort called out of Java...
This would be a question to ask IBM.
Robert Sample
Global moderator
 
Posts: 3569
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 256 times

Re: Finding out the name of a tape dataset

Postby dick scherrer » Thu Sep 15, 2011 11:30 pm

Hello,

I suspect part of the problem is connecting the "tape" to the Java process. I also suspect this is not a DFSORT issue.

As an expirement, can you swap out DFSORT for a tiny COBOL program (or any other utility that does not invoke DFSORT) just to see if Java can read a tape this way?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6269
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Next

Return to Mainframe Java

 


  • Related topics
    Replies
    Views
    Last post