Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Get Mainframe TSO dataset value using java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want a java program that connects to Mainframe system using TSO and fetch the values from the mainframe dataset and store it in a text file.
 
Marshal
Posts: 74627
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

We don't produce complete programs (unless you find somebody who will take payment for such a program), but please tell us what you have managed so far and we'll have a look at it.
 
ShivKumarShiv Yadav
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am new to java i want to know how to connect to mainframe TSO using java...I got this from somewhere but don't know whats happening here...explanation will highly appreciated...


public FTPClient openFTPConnection() {
   String server = [server];
   int port = [port];
   int reply;
   FTPClient ftpClient = new FTPClient();
   ftpClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
   try {
       ftpClient.connect(server, port);
       reply = ftpClient.getReplyCode();
       System.out.println(reply);
       if (!FTPReply.isPositiveCompletion(reply)) {
           System.out.println(reply);
           ftpClient.disconnect();
           throw new Exception("Exception in connecting to FTP Server");
       }
       ftpClient.login(user, pass);
       ftpClient.setFileType(FTP.EBCDIC_FILE_TYPE);
       //Previously, this was set to FTP.ASCII_FILE_TYPE
       ftpClient.enterLocalPassiveMode();
   } catch (Exception e) {
       System.out.println("Error: " + e.getMessage());
       e.printStackTrace();
   }
   return ftpClient;
}
public List ftpStoreAuthData(FTPClient ftpClient) {
   try {
       String mainframeDataSet = [dataset];
       InputStream stream = ftpClient.retrieveFileStream(mainframeDataSet);
       logger.trace("Retrieving mainframe data set...");
       BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "cp037"));
                                                  //Previously, this was set to "utf-8"
       logger.trace("Data set Retrieved!");
       String datasetText;
       while((datasetText = reader.readLine()) != null) {
            //do things with dataset records
       }
       return new ArrayList<>();
   }
 
Saloon Keeper
Posts: 24812
172
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, but it's been a long time since anyone paid me to do mainframe work, so my memory is rusty.

TSO is a text-based user interface system that effectively provides each logged-in user with their own private Virtual Machine (actually it was more like a Container, but this was long before Containers became what they are today). The original way to get data from a TSO user session was horrible, It used a program called IND$FILE that basically dumped the file out as a set of screens that a non-mainframe client could capture it (effectively screen-scraping) and store it.

However, somewhere in the mid/late 1990s, IBM started providing tcp/ip functionality standard in addition to their own proprietary network protocols, and part of that functionality was an FTP server. What you have there is something that's trying to be an FTP client program.

The original Internet was a mix of many different types of machines, with different code pages, byte orders, and so forth. So the older protocols like HTTP, MAIL, and FTP all make allowances. FTP has both a text and a binary transmission mode. When you use text mode, the data is assumed to be all characters in EBCDIC, and the FTP protocol will convert it to ASCII (or something similar) for a PC client, adding line endings (CR/LF for Windows, NL for Unix).

FTP isn't actually related to TSO. Instead, the FTP server has direct access to OS files, but since that's how TSO works, too, that's all that matters.

The important thing here is to make sure you have the appropriate settings to obtain the data in the form that's most useful. In the case of COBOL-style files, that may include some post-processing, since COMPUTATIONAL-3 data isn't a "natural" format for PCs, and it's probably the most common way for mainframes to store business numeric data.
 
ShivKumarShiv Yadav
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim for your explaination. Could you please provide me rough sample code so that i can start the program. Just to remind i want to connect to TSO mainframe and and retrieve dataset value form the mainframe.
 
Tim Holloway
Saloon Keeper
Posts: 24812
172
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have any code like that laying around. You might check the apache.org libraries, because I think that's the site that your FTPClient class came from.

When I do ETL, I'm usually using a general-purpose app like Pentaho Kettle. The FTP is built into it.

Don't forget - all the Java code is doing is automating the exact same commands you'd give if you ran the ftp command-line client application that came with your OS.
reply
    Bookmark Topic Watch Topic
  • New Topic