I am looking to read indexed file using JCL is there any possibility of doing like that? Like there is one KSDS file and we have to read that file using indices and we have to print the selected record onto the console using only JCL no usage of COBOL..
-
2JCL does not manipulate data, it does not look at data. JCL is like a memo from you to the OS requesting it to run one or more programs. The JCL specifies some, or all, of the resources required to accomplish the requested tasks. When the JCL is read the OS reads it and sets up whatever it requires to do the tasks defined in the JCL. It then DISCARDS the JCL, i.e. writes it to the output spool, never to look at it again. The OS then runs the program(s) in accordance with the info it has extracted. So you cannot get JCL to do what you want. – NicC Oct 29 '19 at 19:43
-
1If you cannot use COBOL why the COBOL tag? – NicC Oct 29 '19 at 19:45
-
@NicC already edited. – zarchasmpgmr Oct 29 '19 at 21:22
1 Answers
I believe the program you are looking to execute with your JCL is IDCAMS, and that you want to use the PRINT FROMKEY() TOKEY()
command.
That hyperlink is to the IBM Documentation, a comprehensive set of documentation for z/OS and many of its components. Other IBM products such as Enterprise COBOL, CICS, DB2, and MQ have their own Documentation sites. If you're going to be using an IBM mainframe, it's a good idea to bookmark the sites for the products you use and become familiar with them.
This will not display output on the console, but it will display output on the SYSPRINT DD. I'm not sure if there's a way to display this output on the console (which is where the interface used by mainframe operators), typically that's where messages essential to system health and continued functioning are displayed. If you displayed the output you requested on the console I suspect you'd get a request to not do that right quick.
@NicC is quite correct in saying that the JCL is not doing anything other than requesting the IDCAMS program (in this particular case) be executed. If you're a Linux person, think of it this way:
Suppose you have a shell script...
#! /bin/bash
sort < $1
...would you say the script is doing the work, or the sort program?
JCL has no looping constructs, no way to programmatically alter variables. JCL allows you to request that programs be executed by the operating system and gives you a way to specify their inputs and outputs.

- 10,237
- 1
- 28
- 39