• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Get Mainframe TSO dataset value using java  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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: 64166
215
  • Mark post as helpful
  • send pies
  • 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
  • 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: 20655
122
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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: 20655
122
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!