I am not getting much answers in this forum regarding questions about java, but I will try another one
![Wink ;-)](https://www.ibmmainframeforum.com/images/smilies/icon_e_wink.gif)
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();
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