Mainframes 360
The one stop destination for System Z professionals

Monday, April 6, 2009

JCL Pseudo-code - How to write output to Disk/Tape

Q. How do we write Output to disk/tape in JCL?
A. Unlike writing output to a dataset, disk/tape are direct Access(DASD) devices. Let us study the JCL that will write the output to the disk.


Let us recollect that all JCL statements basically have 3 broad divisions

1) All JCL statements begin with two forward slashes //.
2) NAME gives a name to the job, step or ddname.
3) OPERANDS can be positional parameters or keyword parameters.

Let us now see what the DSN(Dataset Name) is written, if you want to write the output of your program(in the JOB) to the Disk. Here the output will be written to a dataset called DISK.OUTPUT.

DISP(Disposition of the Dataset) -
Disposition of the dataset is used to tell the MVS OS, what is the current statusof the data set, what to do with the dataset if the JOB is successful, and what action to take if the JOB is unsuccessful.

Current-status: The current-status specifies, whether the data-set pre-exists, or it has to be created newly, whether the jobs have exclusive access to it,or multiple jobs can share it.

Normal-disposition : It tells what to do, upon normal execution of the job. The data-set can be saved or deleted.

Abnormal-disposition : It tells what to do, if the JOB terminates with errors(Abnormally Ends - ABENDS). Either the dataset can be saved or deleted.
NEW, CATLG and DELETE are positional sub-parameters. They must appear in the same order.

NEW : This tells the MVS OS, the status of the dataset at the start of the JOB. It indicates that the dataset DISK.OUTPUT has to be creatednewly.

CATLG : Upon successful execution of the JOB, the dataset must be added to the System Catalog.

DELETE : Upon unsuccessful execution of the JOB, the dataset must be deleted.

UNIT Parameter :
This is used to identify the physical device on which output data-set is to be placed. During OS(MVS) installation(a process called SYSGEN), the system programmers will have assigned a symbolic name to each physical device.

Parameter :

To create the output dataset, we need to first tell the MVS OS. The OS is a memory guagrd. It acts as a watchdog, guarding, protecting the memory. If you want to store the output dataset in computer memory, you must first ask the MVS OS for it. Only when the OS grants your request, then you can go ahead and store data.

The OS is a miser. Even if you want a single byte of memory, you must first ask the MVS OS for it. It does not give any bytes for free.

You must tell the MVS OS, how many bytes of memory space you need to store your data. You do this by writing the SPACE parameter.


TRK indicates that the space being requested is in Tracks. Since Primary = 1, the MVS OS will initially allocate(reserve) 1 track of disk space, to store the output Dataset. If the size of output dataset exceeds 1 track, (and you run out of space), the MVS OS will allocate 1 additional track of memory space. If your program finds this space also insufficient, it will ABEND.

After successful execution of the job, any space not utilized by the job must be successfully released.

DCB Parameter :
DCB stands for Data Control Block. DCB will tell the MVS OS, the organisation of the dataset. A data-set may have all fixed length records, or the records may be of varying length. You must tell the MVS OS, the length of each record. This should match the record length as specified in the program. Also, a set of records form a block. MVS allocates memory in Blocks. You must specify the Block Size.

Input --> COBOL Program--> Output
Dataset Dataset


It tells the MVS OS, that each record in the output data set, will be of fixed length. If the records are going to be of variable length, we must write RECFM=VB

It tells the MVS OS, that each record is of length 40 bytes. Since, records are fixed length, all records have the same length = 40 Bytes. If RECFM=VB, then it tells the MVS OS, that the average length of the records is 40 bytes.

It tells the OS, that on the disk(direct access device), the size of the block will be 400 bytes. Thus, 1 block will at most store 10 records. If RECFM=FB, then BLKSIZE must be multiple of LCRECL. e.g. Block Size 4000 = 10 times x Record Length LRECL (40)

Sunday, April 5, 2009

Basic Concepts of JCL - Tutorial 02

What is the Input/Output FILE Identification section?

The fields INPUT1 and OUTPUT1 must correspond to the name following the ASSIGN TO statement in the FILE-CONTROL section of the COBOL Program.


DD Field stands for Data Definition. Its main task is to tell the MVS OS, the input files from which data is read, and output file, to which OUTPUT information is written.


...DSN : A file containing records in IBM Mainframes is called Dataset. Every dataset has a name ; DataSetName(DSN).
DSN = INFILE indicates that the input data will be read from the Dataset INFILE.

SYSOUT=A indicates that the output will be written to the default printer(Job Spool).

DISP=SHR says that Disposition is Shareable. This means, that the dataset INFILE is not reserved for exclusive use. Other Jobs /Users can use this dataset simultaneously.

IBM's Anti-trust Suit

Is IBM trying to kill competition?
Its been a long-standing debate, if Internation Business Machines(IBM) has survived, simply because of the lack of competition. High cost of Mainframe computers, geeky unfriendly and old to work with, are deterrent factors for the bigblue.

In the 90's IBM failed to ride the new wave of the home desktop PC, and Microsoft took the competitive advantage. The battle between Microsoft and IBM still wages on.

A mushroom company Platform Solutions, developed software that mimicked IBM Mainframes on standard servers, Big Blue tried to fight back, but in vain. Finally, they simply tried to acquire the company for $150 million in July this year. After that, Platform Solutions is nowhere to be seen, vanished in thin air.

IBM still faces stiff competition from Biggies like Microsoft and Google. T3 Technologies, a reseller of Platform's products, has filed a complaint against them to the regulators in European Commission.

IBM is now negotiating to buy Sun Microsystems for $7 billion. We can only keep our fingers crossed. IBM has always charged astronomical prices for its so-called 'innovative' products. Its surprising, that amount of Mainframe processing power sold every year is declining.

Wednesday, April 1, 2009

COBOL Tutorials

Tutorial Description
An Essay – The history of Cobol Grace Hopper, the inventor of FLOW-MATIC is the mother of the Cobol language. She built the world’s first A-0 compiler, the MATH-MATIC and FLOW-MATIC pseudo-languages, that laid the foundation for Cobol.
Introduction to Cobol Programming Learn to write simple Cobol programs, compile and link a program and run your programs.
Declaring data in Cobol Declare and use Cobol variables. The concepts of how data items are internally represented in computer-memory, and what DISPLAY and COMP usage implies are explained.
Line Sequential files Declare a Sequential file in a Cobol program. Pick up how you can read and write data from a Line Sequential file.
Working storage Variables in the working storage are used to store intermediate results of processing. They are like a rough-work sheet.
Basic Procedure Division Verbs Learn about Data Transfer or assignment of values to variables using the MOVE verb. MOVE CORRESPONDING option is also described.
Arithmetic Operators You can perform arithmetic in Cobol. There are five standard arithmetic verbs ADD, SUBTRACT, MULTIPLY,DIVIDE and COMPUTE.
Tutorial 08 – USAGE Clause
- What is USAGE Clause
Tutorial 09 – Decision Making in COBOL 
- Basic IF Statement
- IF ELSE Construct
- Nested Conditionals
- Types of Conditions – Class, Relational, Sign
- Complex Conditions – Boolean AND, OR, NOT
- 88-level Special conditionals
Tutorial 10 – Program Flow Control 
- Basic PERFORM Statement
- PERFORM multi-paragraph Procedure
- PERFORM loops
Tutorial 11 – EVALUATE Statement – I
- EVALUATE and WHEN Clause 
- Multiple Subjects and corresponding objects
Tutorial 12 – EVALUATE Statement – II
- Agreement of the subjects with the objects
- Values that subject and object can take
- Concrete example of EVALUATE Clause
Looping Constructs  
Arrays Declaring an array, storing and accessing data from an array. Learn how to create a pre-filled array. Two-dimensional arrays are an extension of 1-D arrays.
Cobol’s built-in intrinsic functions
Sorting and merging data
File processing
Variable Blocked Files in Cobol
Calling sub-programs
Compile-time Errors  
Run-time errors S0C1, S0C4 and S0C7  

Test JavaScript


Articles and Writings

IBM’s Antitrust Suit
IBM Mainframes turns 45
Storage Management System – SMS
MVS System Catalog - Finding Information about Datasets
Building your very own private (Baby) Mainframe on your Laptop/Desktop PC

CA-7 Tutorials

Tutorials Download Link
CA-7 Commands PPT

IBM Utility Software

Tutorial Name Links
IEBGENER for Sequential Files  PDF, Word
IEBCOPY for Partitioned Datasets PDF, Word
IEBCOMPR and SuperCE to compare Datasets PDF, Word
Search Utility to search through Libraries  
IEFBR14 for Side-effects  
IEBPTPCH – Print and Punch Utility  

JCL Tutorials

Tutorial Web Page and Outline Download Links
Tutorial 01 – JOB Statement Fundamentals
|| JOB Statement – Purpose || Accounting-information parameter ||
Programmer-name parameter || Keyword Parameters || CLASS Parameter || PRTY Parameter ||
Message Class MSGCLASS || MSGLEVEL Parameter ||
PDF, Word
Tutorial 02 – EXEC Statement Part I
|| EXEC Statement || Job-Step || Program || Input Dataset || Output Dataset || Program Load || ACCT Parameter || PARM Parameter || JOBLIB, STEPLIB Parameter ||
Default System defined Library – SYS1.PROCLIB || User defined private library ||
PDF, Word
Tutorial 03 – EXEC Statement Part II
|| DPRTY Parameter || PERFORM Parameter || Restarting and Checkpointing – RD Parameter ||
||Common Parameters of JOB and EXEC Statement || REGION Parameter || COND Parameter ||
PDF, Word
Tutorial 04 – DD Statement Part I
|| DD Statement : Purpose || DSN Parameter || Qualifier levels in a DATASET Name ||
DISP Disposition Parameter || Status of Dataset || Normal Disposition || Abnormal Disposition || Meaning of NEW,OLD,SHR,MOD,KEEP,DELETE,CATLG,UNCATLG,PASS ||
PDF, Word
Tutorial 05 – DD Statement Part II
|| UNIT Parameter – referring to device by its make/model || AFF Subparameter ||
VOL Parameter – referring to a particular volume of device || SER – Serial Number ||
REF – Referback to previous VOL Statement || PRIVATE subparameter || RETAIN subparameter || SEQ subparameter || LABEL parameter for Tape Datasets ||
SPACE Parameter – for storage space allocation || Max. space allocated to a PS ||
|| RLSE,CONTIG,MXIG,ROUND Subparameters || Organisation of records in Dataset ||
DCB Parameter – Data Control Block || RECFM – Record Format ||
LRECL – Logical Record Length || BLKSIZE – Block Size || DSORG – Dataset Organisation ||
Sample JCL Showing how to use DCB Parameter ||
PDF, Word
Tutorial 06 – DD Statement Part III(Instream and Cataloged Procedures)
|| What is a JCL PROC ? || Cataloged PROCEDURE || Default SYSTEM LIBRARY ||
|| Private Library || Analogy with respect to conventional Programming Languages ||
Instream PROCEDURE || Calling a PROC – Example ||
PDF, Word
Tutorial 07 - More on COND Statement(Lots of Examples)
|| COND Statement – Basic Example || EVEN Parameter || ONLY Parameter ||
COND Coded on many job-steps ||
PDF, Word
Tutorial 08 - Cataloged and Instream PROCs(Overriding Parameters)
|| Modifying contents of a JCL PROC || Modifying a parameter on EXEC Statement ||
Adding a parameter to EXEC Statement || Deleting(Nullifying) parameter on EXEC Statement ||
Adding or modifying DD Statements || Example – MODIFYING DD Statament ||
PDF, Word
Tutorial 09 - JOB Log (How to understand it and Interprete it)
|| JOB Log means... || What is JES2 JOB Log || Start and End CPU Times || User assigned to the JOB || Number of Input Cards read || COND Code || Allocation and Termination Messages ||
PDF, Word

Introduction to IBM Mainframes – Part I : Video Tutorial

Compuware File–aid How to

Q. What is File-Aid?
At home, we maintain our Bills, Receipts, Credit-Card Statements systematically in a File. Likewise, a Computer-File is systematic means of storing Data. To browse the data stored inside a Computer File, to make any additions or deletions, the software Program used is called a File Editor.

File-Aid is an advanced File Editor Program, developed by Compuware, that aids you and assists you storing and retrieving Data from Mainframe Files. File Aid can not only handle Line-Sequential Files, but also VSAM Files.
Q. How to Browse or Edit a File in File-aid?
The File-Aid Main-Menu Screen shows various options. The Browse Menu Option 1, the Edit menu 2, the Utilities Menu Option 3 and the View Menu Option 8 are needed frequently, when working with Files.


The Browse Screen or Edit Screen are used to Open and read Mainframe Files. Browse happens to be Read-Only Mode, whereas Edit allows you to modify or update the contents.

On the Browse Screen, you must enter the Mainframe File-Name. I have entered the Dataset Name VS90626.GINP10SD.DUMP2. You must also specify the Browse Mode. The Character(C) Browse Mode is used to display the Textual-Data in the File as EBCDIC Characters.


Hit Enter, and the Dataset will be opened for Browsing. The below picture shows my Dataset VS90626.GINP0SD.DUMP2. You may scroll left using the PF10 AID Key, and scrolling right is possible using the PF11 AID Key.

Q. How to use Copy-books in File-aid?
While looking at records stored in a Mainframe File, it is very difficult to interprete and understand their meaning, make out what are the Fields or columns. In the snapshot below, its hard to make out, what the text ABG means, what RQ00049R25 stands for and so on. It would be cool, if it had some headings.

Just as on an Excel Spreadsheet, Column-Headings add meaning to the data stored in the File, File-Aid allows you to browse Data, with the Column Headings turned on.

The Data-records stored in a Mainframe File have a Format, a Structure or Layout. This Data-Format or Structure is generally maintained in a Separate Copy-book File, independent from the Data. You can specify a COBOL Copy-book File, while attempting to browse the Data.

Enter the Copy-book Library and the Member name on the Browse Screen. My copy-book member is GINP10SD under the Library CP81000.PSEGMENT.COBOL. You specify either Vertical Format(VFMT) or Horizontal Format(FMT) Browse Modes.


When you press Enter, to open the File, it shows up like this.


Here, the columns are arranged one besides the other vertically. To switch over to the Horizontal Format(FMT) Mode, enter the line command FMT. The columns are now stacked horizontally.


The SHOW Line-Command comes in quite handy, when browsing files. Take a look below.

SHOW OFFSET – Displays the offset(displacement) in Bytes for each column.


SHOW NUMBER – Displays the Column Number.


DISPLAY Command – When you want to display only selected columns and hide others, you can use the DISPLAY Command. For example, if I type display 3 4 10 11 13 14 28 57 58 ONLY, it will exclusively display only these columns.

Q. How to create a new Mainframe Dataset in File-Aid?
On the Mainframe, you use ISPF Menu Option 3.2, to allocate new datasets. Likewise in File-AID, you can used File-AID Menu 3.2, to create new Files. Enter the Dataset name for example, VS90626.TEST.FILE enclosed in single quotes. Enter the Command A to Allocate the Dataset.


On the next screen, enter the Memory Space Requirements. I want my Dataset to be Sequential PS Dataset, 10 Tracks large, with a Fixed Record Length of 80 Bytes. I want them to be grouped in bunches of 10 each, so the
Block-Size = 80 Bytes x 10 = 800 Bytes.


After keying in all the necessary Parameters, hit Enter to create the new Dataset.

COND Statement – How does it work?

Q. How does the COND statement work?
The COND statement is used to bypass Job-step. 

Example 1

Consider the statement

In this example, if condition-code of STEP1 is between 0 to 3, the COND condition is satisfied. Thus, STEP02 is bypassed.

Example 2

Consider the statement,


In the above example, the system executes this step if all of the three conditions are met,
1. Return codes of Any of the previous job-steps is 17 or greater.
2. Return code of STEP1 is 89 or less.
3. Any of the previous step abnormally terminates.

Example 3

Consider the series of statements :


In the above scenario, assume the system successfully executes STEP01 with Return Code=0. The system finds that 0 is equal to return code of STEP01 i.e. 0. So, STEP02 is bypassed. When the system evaluates condition on STEP03, it finds that  8 is greater than return code of STEP01(we don’t consider the other part of the condition, since STEP02 was bypassed). Since, 8 > 0, the system executes STEP03.
Rule : Bypassing a job-step because of a return code test, is not the same as abnormally terminating the job-step.

You can now try and predict in this JCL, which job-steps the system executes, and which job-steps are bypassed...

Answer :
System executes STEP01. Return Code = 0.
(4,LT,0) false. System executes STEP02. Return Code = 0.
(16,GE,return code of any preceding step) true. System bypasses STEP03.  

Reusable JCLs

  This post is partially complete and several sections may require editing and proof-reading. The job-streams for compiling CICS applications need to be added.

Job Stream Description
Cobol Compile and Link This job stream is used to compile a source program written in Cobol and link-edit the generated object-program to produce a load module. You can tailor the JCL as per the conventions followed at your production shop.
Run a Cobol program This job stream is used to run a program written and compiled in Cobol. Supply the name of the program to run and the Disk Load Library where the load module resides.
Pre-compile, Compile and Link a Cobol-Db2 program This job stream is used to pre-compile, compile and link-edit a source program written in Cobol containing embedded SQL statements. It will produce a DBRM and a binary load module.
Db2 BIND PLAN This job stream is used to BIND a DBRM(Database Request Module) into an Application PLAN.
Run a Cobol-Db2 program This job stream is used to run a Cobol-Db2 application program along with its matching Db2 PLAN.

LINES parameter - Indicating maximum amount of output to be printed to SYSOUT



Suppose you have the above job-card, that has several job-steps with a large output. You would like to issue a message to the operator, when the job output exceeds 500,000 lines. Which parameter should you add to the job-card to achieve this?

A. When we want to indicate the maximum amount of output to be printed to SYSOUT dataset, we can use LINES parameter on the JOB card. The syntax of the LINES parameter is :

LINES=nnnn or LINES=(nnn,action-to-be-taken)

The maximum amount of output can be specified in thousands of lines. So, if you want to indicate that maximum amount of output from the Job is 500k lines, nnn should be 500. You can also specify, what action must be taken – whether you want to continue the job, cancel the Job(CANCEL), DUMP, or notify the operator(WARNING).

Correct answer – LINES(500,WARNING)

On the same lines, you can also indicate the maximum amount of output in terms of BYTES,CARDS or PAGES.

NOT CATLGD 2 JCL Error – How to avoid it?


When attempting to run the above Batch JOB/JCL, NOT CATLGD 2 JCL error occurs for the ddname OUTFILE. What is a NOT CATLGD 2 JCL Error? How to eliminate NOT CATLGD 2 JCL Error for a particular dataset?

The NOT CATLGD 2 JCL Error mostly occurs, when the dataset in question already exists. Here, OUTFILE is trying to create a new dataset OUTFILE.TEST.DATA. So, probably this dataset already pre-exists and is cataloged. To ensure such errors don’t occurs, we must purge/delete datasets using IEFBR14.

OUTPUT Statement – Changing default SYSOUT output to a remote location


What is the OUTPUT JCL Statement? How do change the default destination of the SYSOUT output messages to a remote location?
A. When we would like to do some formatting/processing, on SYSOUT output datasets, we use a JCL Statement called OUTPUT. To specify the destination of the SYSOUT output dataset, as a remote location, we must code DEST parameter on the OUTPUT JCL Statement.


In the above example, the SYSOUT dataset output will be sent to the remote location RMT. Also, this will stand as the default. 

Apart from this, we can specify various options, we can print multiple copies of the output dataset, using COPIES parameter. Moreover, we can write OUTPUT statement at the job-level or step-level. To refer back to previous OUTPUT statement, we can use refer-back.

*.OUT1          - *.outname
*.STEP01.OUT1   - *.stepname.outname

IMS Tutorials

Tutorial Links
Introduction to IMS/DB  
Creating a new IMS Database  
Preparing a COBOL-IMS Program  
ISRT CALL - Inserting Data into an IMS Database  
GN CALL – Sequential Retrieval of Data  

Mainframe Assembler

Tutorial Links
Learning Assembler Language  

VSAM Tutorials

Tutorial Link Download Links
Introduction to VSAM Files  PDF, Word
Sequential Processing of VSAM Files  PDF, Word
Random Processing of VSAM Files   
Inserting Records in VSAM File  
Updating Records in VSAM File   
Creating New KSDS File PDF, Word
Creating New ESDS File PDF, Word
Loading and Unloading VSAM File PDF, Word
LISTCAT Command PDF, Word
Alternate Indexes  

System Z's 50th birthday


Mainframe Interview Questions

Subject area Download it on your Box
JCL made Easy Revise how the //JOB, //EXEC and //DD statements work. COND Parameter turns off a step. Job-abend(s), GDGs and much more. Download the Portable Document Format(.pdf) file.
Crack the code, Cobol Assess your knowledge of the Cobol language. The difficulty of questions increases gradually. Download the Portable Document Format(.pdf) file.
CICS cheat-sheet Brush-up topics such as pseudo-conversational logic, BMS maps, writing a basic Cics program, TS and TD Queues, ATI. Download the Portable Document Format(.pdf) file.

DB2 QMF How to

Q. What is QMF?
QMF(Query Management Facility) tool used to issue SQL Queries against the IBM DB2 Database System. It is not merely a Data-extraction tool, the data-results can be formatted and presented as Reports, Charts etc. thus offering valuable insight. QMF also has Wizards that can help you to extract data, without even having to write SQL Statements.

There are three different ways, in which you can supply Input to QMF – (1) Entering SQL Query in the Query Editor (2) By using Prompted Queries (3)Query By Example(QBE).
Q. How do I enter an SQL Query?
On your Mainframe System, once you invoke QMF, the welcome screen splashes before you. On the Welcome Screen, press the Program Function Key PF6, to go to the Query Editor


Upon pressing the SQL Query Editor starts. The empty area of the screen is where you must type your SQL Statements. You can press the HOME Key on your keyboard, to reposition the cursor to the first line.


I have entered a SELECT SQL Query in the Query Editor. You must now press the RUN Program Function Key, set to PF2 to execute the SQL Query.


On execution of the SQL Query, the data-results retrieved from the DB2 Database, are displayed on the Report-Screen. The results are displayed a tabular format. The Column-Headings give detailed-information about the data-item.


What if you don't know, about the SQL Columns in the DB2 Table? The DRAW Command comes in quite handy, in such situations. Just enter the command DRAW followed by the Table-Name, on the Command-Line, and QMF generates a ready-made SELECT SQL Statement for you. I have entered DRAW SYSADM.EMPLOYEE on the command-line.


Upon executing the QMF Command, it generates a basic SELECT SQL Query, with all columns present, on your table. You can now edit the SELECT SQL Query, and tailor it to fetch your desired results.

Q. How do I use Prompted Queries?
Prompted Queries follow a step-by-step wizard-based approach to building and framing an SQL Query. The default entry method of the Query-Editor is SQL. You need to reset the Language of the Query Editor, to Prompted Queries. To do this, enter
RESET QUERY(LANG=PROMPT command on the command-line.


When you reset the Language to Prompted Query, a Prompt-Window appears. Pop-up Windows are used to collect information from the user, about the data you wish to search for and extract. In the picture below, the window alerts you to type the Table-Name. Enter your DB2 Table-Name in the pop-up box.


After the DB2 Table-Name is fixed, you must SELECT the Columns that you would like to display, in the Result.


Now, enter 2 for specifying SELECT Columns. Further, enter an 'S' against each column, you would like to be displayed on the Report.


You may specify one or more WHERE conditions, to filter out the rows. I would like to filter rows by the SALARY Column of the EMPLOYEE Table.


The Filter-Condition, I wish to apply is SALARY > 3000.


The next Pop-Up Window alerts you to enter the Value, against which the SALARY is to be compared.


The rough sketch of the entire Query is shown on the Screen.


Upon pressing the Run Program Function Key PF2, the query  is executed, and the data-results are displayed on the Screen.

To many people who are thrown to work at a mainframe computer on their first job, they feel lost. Mainframe people seem to speak a completely different language and that doesn't make life easy. What's more, the books and manuals are incredibly hard to comprehend.

"What on earth is a Mainframe?" is an absolute beginner's guide to mainframe computers. We'll introduce you to the hardware and peripherals. We'll talk about the operating system, the software installed on a mainframe. We'll also talk about the different people who work on a mainframe. In a nutshell, we'll de-mystify the mainframe.

Readers based in India, can buy the e-book for Rs. 50 only or the print book. International readers based in the US and other countries can click here to purchase the e-book.