Mainframes 360
The one stop destination for System Z professionals

Saturday, October 30, 2010

TSO/ISPF Commands

Q. What is the ISPF Text-Editor?
The ISPF Text-Editor is the free IBM Software, used to enter and store data in Mainframe Files. The ISPF Text-Editor is a power-packed word-processor with a plethora of advanced features, that save several key-strokes and time. Although there are other proprietary products such as File-Aid, ISPF Text-Editor is free, light-weight software.

ISPF Text-Editor supports Primary-Commands and In-line Commands. Primary-Commands are global, and affect the entire data-set such as FIND, CHANGE, SAVE, REPL, UNDO etc. You enter Primary-Commands on the command-line. Take a sneak-peek below, at how I entered the SAVE Primary-Command.


Line Commands apply to the current-line or Block-of-lines. You position the cursor against a Line as shown in the glimpse below, type a Line-Command like I, R, M, C, D, ( etc. and press <Enter>. Check-out, how I entered  I-Insert Command against the second-line.

Q. What Line-Commands can I enter in the ISPF Text-Editor?
If you are a Windows or Linux user, beware! There are differences between ISPF Text-Editor and its counterparts – Notepad, vi, e-macs etc. Unlike other word-processors, ISPF Text-editor doesn’t allow you to type continuous-text, which will auto-flow on to the next-line. If you want to type some more text on the Next-line, you must first insert a new blank-line manually. That's why you’ve got a whole bunch of Line-Commands. Life ain't easy on Mainframes.

You can use the following Line-Commands in the ISPF Text-Editor :
I – To insert a Blank new-line underneath(the current-line).
D – To delete the current-line.
M – To move/shift the current-line from one position to another(This is also called Cut-Paste)
C – To create a second-copy of the current-line(This is also called Copy-paste)
R – To replicate the current-line.

This short animated-clip demonstrates how to use Insert Line-Command to insert new lines.

Inserting Lines 
The next video-snip shows, how lines-of-text can be deleted, and removed using the Delete(D) Line-Command.

Deleting Lines

The Move(M) and Copy(C) Commands are the most useful commands from the lot. Accompanied with Move and Copy, you also need to tell, the position or destination, where the Line is to be Moved-to or Copied-to. Use a second-command to tell where to place the line-of-text – Before(B) or After(A) a destination line-no.

Moving and Copying Lines

Tuesday, October 26, 2010

Get your hands wet on a Mainframe

3270 Terminal Emulator
In the 1970’s, IBM introduced computer monitors or terminals to display output from the mainframe. There were several models – tlike the IBM 3278 video terminal. While the mainframe complex did all the core processing, terminals were dumb, they had no thinking power. All they were supposed to do was to display the output response from the mainframe. People coined the term dumb terminals to refer to them.

Today, mainframe staff in an enterprise use software programs on the PC called terminal emulators, that pretend to be the dumb terminal. The emulator package can be installed on a Windows/Linux/MAC box. The emulator acts like a web-browser on the mainframe. With the emulator software, you work your way around the System Z and go about day-to-day tasks like creating new files, editing files, deleting files, copying data etc. A picture of an emulator – VISTA TN3270 software is shown below.

Starting a New Session
First, launch the terminal emulator on your PC and connect to the mainframe server. This establishes a new session on the mainframe and allows you to perform tasks on a Mainframe.

Logging Off
Remember, log-off the session, when you are done with your work on the mainframe. Just closing the emulator window doesn't end you mainframe session.

Keyboard Lock
The transaction that takes place between a user (indirectly refers to terminal emulator) and the mainframe computer is conversational. When a user enters an input on the terminal emulator and presses the return key to execute, the 3270 emulator software on your PC sends out a stream of data to the mainframe computer over a network (LAN Intranet/Internet). The 3270 terminal emulator freezes and would not accept any further inputs till it receives a response from the mainframe server. The mainframe computer processes your instructions and replies back with an output. Meanwhile, there is an X in the bottom left-hand corner of the screen. Look at figure below.

Another event that frequently happens, is the Terminal-emulator may stop responding to your Key-Strokes and goes into a XMIT-Lock Mode. This happens when your cursor is incorrectly positioned at a place (field) on the Screen, where you are not supposed to type. Press the Escape Key, or try Ctrl+R to reset the emulator.

User Prompt
On the mainframe, notifications and messages such as alerts, warnings or severe errors require your acknowledgement. The 3270 console often displays three asterisk symbols * * *, prompting the user that it needs your attention. You must acknowledge by pressing any AID key (attention identifier) like the <enter> key or PF1 to PF12.

Beware of the Over-write Mode
Unlike most word-processors which operate in Insert-Mode, the normal (Default) mode of operation of a Terminal Emulator is Over-write Mode. Let's say, there's a string of Text AAAABBBBCCCC, which you want to be modified to AAAADDDDCCCC.

AAAABBBB|CCCC  Cursor is between B and C

AAAA|CCCC      Press Backspace four times, to erase BBBB


Quite the opposite of what you would expect, the CCCC gets over-written by the new text DDDD.

A terminal emulator has a keyboard map. Essentially the map shows, what actions assigned to a particular key on the keyboard. What happens when you press a certain key on the keyboard? The keyboard map of a terminal emulator is shown in the picture below.

With some terminal emulators like IBM Personal Communications, the standard carriage return function is mapped to the Ctrl key. Various other terminal emulators map the carriage return to the Enter Key. Make yourself familiar with, which key causes a newline.

On the mainframe, the function keys are known as program function keys - PF keys. We can assign TSO and ISPF commands to various PF keys in ISPF. They behave like shortcut keys.

Terminal Screen
Most emulators have five different display modes. Each mode shows a different number of lines (rows) and columns on the screen. In Mod-2 operation, the terminal emulator is capable of displaying 24 horizontal lines(rows) x 80 vertical columns.
Connecting to the mainframe server
The first step is to run the 3270 terminal emulator on your computer. What I have on my computer and would suggest to beginners, is to install a terminal emulator called Jagacy 3270. You can get a free distribution of the Jagacy 3270 emulator at the vendor website on the Internet.

Connect to the mainframe server by entering its IP address in the dialog box. For example, I have entered The port is the standard telnet port 23. Refer to the figure above.

Sunday, October 17, 2010

DB2 Fundamentals

Q. What is DB2? How does it compare with VSAM Files?
DB2 is the Data-Management System from IBM. DB2 is a newer technology, whilst VSAM is old. VSAM(which stands for Virtual Sequential Access Method) is just a Data Access-Method. You can browse a VSAM Dataset in Sequential Mode – Record-by-record. You can do random access – jump(hop), fly directly to a particular Record . Skip-Sequential is like the best of both worlds – Jump to 1st record, and then start browsing the subsequent records one-by-one. Sounds cool, ain't it, but hold on and have a look at what DB2 Software offers!

DB2 is a complete Software Package, that allows you to create, store, update and retrieve Data in a Systematic Manner.

1. Data Abstraction : It presents a Logical, Structured view of the Data to the User. The user doesn’t need to worry about the details of how the Data is Physically stored on the DASD-Disk.
2. Data Independence : DB2 provides a layer of Independence, between the application or COBOL Program and the Data. Every-time the structure of the Data changes(say you add a new field to the EMPLOYEE File), you don’t need re-write the entire COBOL Source code again.
3. Data Security : DB2 Software controls the Access to the Data. Not everybody can see all the Data. You can see it, only if you've got all the necessary privileges.
4. Transaction Management and Concurrency : DB2 Manages all the Transactions, and ensures the Data remains consistent. It provides a Locking-Mechanism, for concurrent access to the Data.
5. Data Recovery : When there are Crashes, DB2 allows you to recover swiftly, and restore the original Data.
Q. What are the DB2 Data Structures?
DB2 Software physically stores the Data in VSAM Files on the DASD Disk.

STOGROUP : The Set of DASD Volumes that will be used to house the VSAM Files containing the Data. In the example below, I've created a STOGROUP called DSN8G810 with the DASD Volume S4DB21.


The information about all the STOGROUP's(Storage Groups) is stored in the DB2 Catalog Table SYSIBM.SYSSTOGROUP. The snapshot of all the STOGROUP's is shown in the picture below.


Database : A Database is a Logical-Grouping of Database Objects, related together by application, or subsystem. A Database contains no Data of its own, but it merely groups like DB2 Objects. To create a New Database, use the CREATE DATABASE Statement. In the example below, I have created a New Database called DSN8G81A on the STOGROUP DSN8G810.


The information on all the Databases in DB2 System is stored in the DB2 Catalog Table SYSIBM.SYSDATABASE. The below picture is a snapshot of it.


: A Table-Space is a VSAM File which stores or houses the DB2 Table-Data Physically. You can create a Brand-New Table-space File, by using the CREATE TABLESPACE Statement.


In the picture above, I have created a new Table-space File called DSN8G8TS, which has a Primary-Space of 400KB and Secondary Space of 400KB. Just like the contents in a Book, the data in a Table-Space File is stored in Fixed-Size Pages. DSN8G8TS Table-Space is created under the DSN8G81A Database Umbrella. The new Table-Space File will be stored on DSN8G810 Storage-Group. A buffer-pool is the place in Main Storage, where DB2 will store Pages fetched from the Table-Space.


The information about all Table-Space Files is stored in the DB2 Catalog Table SYSIBM.SYSTABLESPACE. A snapshot of this is shown in the above picture.

Once the Table-Space File has been newly created, you can actually see it using DSLIST Utility in ISPF Menu 3.4. The VSAM Dataset-name has the format vcat.DSNDBC.dbname.tsname.*.

Q. What are Tables, Primary Keys and Foreign Keys?
A Table stores Data. Tables look like a spreadsheet, they consist of Rows and Columns, as shown in the picture below. 

  Image330    Image331
The Employee-ID Number is unique for each Employee. No two Employees have the same Employee-ID in the Company. Similarly, the Department-ID is unique for each Department. Employee-ID Column is said to be the Primary-Key or
Primary-Index in the EMPLOYEE Table. Department-ID is said to be the Primary-Key or Primary-Index in the DEPARTMENT Table.

Suppose you want to establish a Relationship, and store the information about, which Employee works for which Department? The EMPLOYEE Table should be expanded and an additional column is added to it, called FK_DEPT_ID. EMPLOYEE.FK_DEPT_ID Column refers to DEPARTMENT_ID Primary-key column of the DEPARTMENT Table. FK_DEPT_ID is called Foreign-Key. Here, is how it works. RAJ has FK_DEPT_ID=10. Look-up Department-No 10 in the DEPARTMENT Table, and it is the HR Department. It means RAM works in HR Department.

 Image332     Image331[3]
Q. How do you write the DDL to create Tables and Index Key-Columns?
As an example, let us build a toy Database-System, called New Business Tracking(NBT), which stores the information about new Insurance Policies(New Business) of an Agent for the first 90 days. This Database System will have three DB2 Tables – CONTRACT, AGENT_CONT_CNTL and INSURED. 

CONTRACT Table Schema
The CONTRACT Table stores the basic Details of the Contract, what is the Contract-No,how many Insured's does this Contract cover(ISRD_ON_CONT_CNT), is it a Life or Annuity Policy(LINE_OF_BUS_DESC), when the Application was received, when was the Policy under-written, when the Policy got Issued, what is the Face Amount(Sum-Assured) and many other details.


You write the CREATE TABLE Statement listing all the Columns followed by their SQL-types, along with whether the Column accepts NULL Values or is it NOT NULL. The List of Columns is a Comma-Separated List.


Primary Index For CONTRACT Table
Here's, how I have created  the Primary-Index on the CONTRACT_NO, CASE_NO Columns of the CONTRACT Table. I have created a UNIQUE INDEX on the CONTRACT Table.

AGENT_CONT_CNTL Table stores the basic data about the Insurance Agent, and the Insurance Policies sold by him.


The AGENT_CONT_CNTL Table stores Agent Details. How do you know, which Policy belongs to which Agent-ID? For each Agent, the Policy-No sold by him is stored in FK_CONTRACT_NO Column, and this refers to the CONTRACT_NO Column in CONTRACT Table. Similarly, FK_CASE_NO refers to the CASE_NO in the CONTRACT Table. Thus, the foreign-key(FK_CONTRACT_NO,FK_CASE_NO) refers to the
Primary-Key(CONTRACT_NO,CASE_NO) in the CONTRACT Table. One needs to understand, that you cannot create a Foreign-Key without defining a UNIQUE INDEX.


Primary Index For AGENT_CONT_CNTL Table
I have created a New Unique-Index IX_AGENT_CONT_CNTL on the columns FK_CONTRACT_NO, FK_CASE_NO and AGENT_CODE of the AGENT_CONT_CNTL Table.

INSURED Table Schema
INSURED Table stores  information  about the Insured, or Policy-Holder. In case of a Join-Policy, a Contract may have two or three Insured's. In that case, each Insured for that Policy has a different ISRD_SEQ_NO. The Insured's Name, Date-of-Birth etc. is stored in  this Table.

The CREATE TABLE Statement for the INSURED Table is shown in the picture below. How do you know, who is the Policy-Holder for a particular Contract-No? This information is stored  in the Columns FK_CONTRACT_NO and FK_CASE_NO, which is the  Foreign-Key, and refers to the corresponding columns in the CONTRACT Table.

Primary Index For INSURED Table
I have created a Primary Unique-Index on the ISRD_SEQ_NO,FK_CONTRACT_NO and FK_CASE_NO Columns of the INSURED Table.


Sunday, October 10, 2010

Introduction to CICS GUI Screens

Q. What is a CICS Map?
A CICS Map is a GUI Screen, just like an Internet Web-page. It can have a Title Header, Display-Only Constant Fields which prompt you what information to type, Input Data-Entry Fields where you can type some input with the keyboard, and Output-Fields where the result of processing may be displayed.


Have you come across an application-form, that you’ve got to fill when you take a Competitive Entrance test like the CAT, or GMAT? The Application-Form has a Title like 'SAMPLE APPLICATION FORM'. It has Display-Only Constant Fields like the 'Name of the Applicant', 'Date-of-Birth','Residential-Address' etc. Display-Only Constant Fields are used for Messages and Captions, and this data cannot be changed by the user. These fields prompt you, about what information is needed. Each of these are followed by Input Data-Entry Fields '_____'(the blank lines), where you are supposed to type the data asked. This is the anatomy of CICS GUI Screen or CICS Map.
Q. What is BMS(Basic Mapping Support)?
Writing a CICS Map, is just like designing a Web-Page in HTML. CICS Maps are coded using BMS Instructions. BMS stands for Basic Mapping Support. The three important BMS Instructions are DFHMSD, DFHMDI and DFHMDF.

The DFHMSD instruction is used to define a New Mapset. A Mapset is a list or collection of Maps. You put related Maps or CICS GUI Screens together into
1 Mapset. Generally, when you have a big system, with hundreds of CICS Screens, you group all the screens related to same functionality under one common Umbrella, under one Mapset. A Mapset is a means to gift-wrap many CICS Pages together.

The DFHMDI Instruction is used to define a New Map(within a Mapset). A Map represents a single CICS GUI Screen. You code the DFHMDI Instruction to tell, what is the size or dimensions of the CICS Page, just like your PC-Screen has a resolution of 1024x768. The DFHMDI Instruction of the Map, also tells what’s the line the Cursor should be initially positioned, when the Screen is displayed.

Every CICS GUI Screen has many Fields – Title field, constant-fields, data-entry Fields. To create a New Field on a Map, you code the DFHMDF Instruction. The DFHMDF Instruction defines the placement of the Field(where does it appear on the Screen), is it a Display-Only constant-field or a Data-Entry Field, what is the Length of the Field, does it have an initial-value and much more.
Q. What is the general format of a BMS Instruction?
Before you begin to write BMS Code, take a look at how a BMS Instruction looks like -


Every BMS Instruction can have a unique-name or Label. The name or Label assigned to a BMS Instruction begins at Column 1. I've coded the name APPFORM(Application Form) for my Mapset. This is followed by the BMS-Operation, like DFHMSD for a new mapset, or DFHMDI for a new Map in the Mapset, or DFHMDF for a new Field on the Map. Every BMS Instruction is followed by one or more Parameters. For example, DFHMSD(Mapset Definition) takes the parameters TYPE, MODE, LANG, TIOAPFX and CNTL. These parameters should always be coded on Column 16. Moreover, if a BMS Instruction doesn’t fit into one line, but spans into subsequent lines, you should code Continuation-Character 'X' on the Column 72. The Parameter-List is always separated by Comma's.
Q. Demonstrate to me, how to code a few CICS GUI Screens?
We'll start off by writing the code and designing a simple 2-Screen Toy-Application. I have created a separate Mainframe PDS or LibrarySYSADM.DEMO.MAPLIB, for storing the code for all the Maps, that I use in different Applications. Here’s my Personal Map-Library.


I am going to code an Add-Application, which will have two screens. The Input-Screen accepts two-numbers from the User. The Output-Screen displays sum of the two numbers. The Input-Screen and the Output-Screen, are the two screens under the Add Application, so I will group them under one Mapset – ADDAPP. I have created a Member ADDAPP, under the Library SYSADM.DEMO.MAPLIB, to store the BMS Code for CICS Input-Output Screens belonging to Add-Application.

Let's begin by coding the Mapset Definition Instruction – DFHMSD. I am creating a New Mapset, by the name ADDAPP. The ADDAPP takes several Parameters, such as TYPE, INOUT, STORAGE etc.


The TYPE Parameter can be assigned a value MAP, DSECT or &SYSPARM. Read about the TYPE Parameter at length, when you know what's a Symbolic-Map and
Physical-Map. LANG=COBOL is important, it means the screen's data will be processed by a Program written in COBOL. You may even have a PL/I, or an Assembler Program that processes the data on CICS-Screens. You would then end up writing LANG=PLI or LANG=ASM.

The MODE specifies, whether the Map is used for Input(IN), or Output(OUT), or both(INOUT). CTRL specifies a List of Control-Options, for each Screen. Like I have coded CTRL=FREEKB. Generally, when a new CICS Screen is displayed on the Terminal, the Keyboard goes into a Locked State(you can’t key in any Input). You need to reset(unlock) the Keyboard, by pressing the Escape-Key. To avoid this, you can code CTRL=FREEKB, which will always free the Keyboard, before the Screen is Displayed.

The MAPATTS and DSATTS tell, that the CICS GUI Screens will support some extended attributes(characteristics) such as Color.

What's next? Here is a road-map of what’s going to come? Under the ADDAPP Mapset(DFHMSD), I am going to create two Screens(Maps), called INPMAP-Input-Screen for accepting two numbers(DFHMDI) and OUTMAP-Output-Screen for displaying Output(DFHMDI). Under each Map(DFHMDI), there will fields(DFHMDF's). The below picture is general skeleton of how the Entire ADDAPP Mapset broken down into 2 Screens – INPMAP and OUTMAP will be coded.


Let's take one Map at a time. First the Input-Screen INPMAP. I want the Screen to be of a Size 24 Rows x 80 Columns. To specify the Size, you code the SIZE Parameter as SIZE=(24,80). The LINE Parameter and COLUMN Parameter specify the co-ordinates where the CICS Screen starts. For now, you would code LINE=1, and COLUMN=1, till you start working with Multi-Panel Maps(just like an Internet Website has Frames). This is how the DFHMDF Macro Instruction for INPMAP Looks like -


Shown below is a Wire-Frame Layout of the INPMAP Input Screen, how it should look and the various Fields on it. To aid your understanding, I’ve highlighted the various Fields on the Map. This CICS-Map has Display-Only Constant-Fields : the ones in grey, the ones in Yellow are Input Data-Entry Fields. Display-Only Fields are always fixed, they cannot be changed, you can’t modify them, or type something there. On Input Data-Entry Fields, the User can type Input, using the Keyboard.

Q. How to code DISPLAY-Only Constant Fields on the CICS-Screen?
The Fields whose Data-Value always remains Fixed or Constant, are called Display-Only Fields. The User cannot Over-type, modify the data of this Field. These Fields restrict User-Input. The Data in the Field is Protected(PROT).

To begin with, the 'ADD APPLICATION' Title is a Display-Only Field, positioned right at the center - row 1 and Column 32.

Like-wise, 'FIRST NUMBER  : ' is a Display-Only Protected(PROT) Field, positioned at Row 5 and Column 03. Look, how I've coded the DFHMDF for the this field. 


As an exercise, try coding the 'SECOND NUMBER : ' which sits directly  below(underneath) the 'FIRST NUMBER : ' Field on Line 7 and Column 03, by yourself. This is how I coded the 'SECOND NUMBER : ' Display-Only Field.

Q. How to code Input Data-Entry Fields on CICS Screen?
An Input Data-Entry Field, is an Area - where the User is expected to type some data-value and supply Input. The Data in this field is keyed-in by the User. Hence, the User is free to type any Input he desires in these fields. Data-Entry Fields are therefore, said to be un-protected(UNPROT).

When you run COBOL-Programs in Batch-Mode, by writing a Job, the Input-Data to these Programs is generally stored  in Mainframe-Files(Datasets). What about COBOL Programs run in Online-Interactive Mode ; have you wondered, what’s their source of the Input-Data? Bingo! Data-Entry Fields are the Primary-Source of Feeding Input-Data to the COBOL-Programs run in Online Mode under CICS. It should clear, that COBOL-Programs run in Online-Mode under CICS, read the Data from Input Data-entry Fields, process the Data, and generate Output

Since COBOL Programs need to access and read the Data from Input-Fields, it is important that you assign a name or Label to your Input-Fields on the CICS Screen. The Input-Screen INPMAP has Input-Fields containing two empty Blanks '__' adjacent to 'FIRST NUMBER : ' and 'SECOND NUMBER : ' Display-Fields. I have named them NUMBER1 and NUMBER2.

How to calculate the Position or Placement of Consecutive-Fields? You employ a simple formula (start  + Length + 1 ). For example, 'FIRST NUMBER : '
display-only field starts at column 3, and is 15 bytes long. So, the '__' Input-Field next to it can start on or after (03 + 15 + 1) = Column 19. You shouldn’t be surprised, as to why I've positioned NUMBER1 and NUMBER2 Fields at (5,19) and (7,19) respectively.
Q. How to code Output-Result Fields on a CICS Screen?
Shown below is the Wire-Frame Model of the Output-Screen OUTMAP. It has an Output-Field colored in Green, used to display the Sum of the Two Input-Numbers.

Output-Fields on a CICS Screen, are used for displaying Outputs, results of processing, Messages or Warnings. The COBOL-Program running in Online-Mode, after having processed the Data, stores or populates the Output in these Fields. 

The Output-Field value is populated by the COBOL-Program,(and not the user) caution – the user should not be able to type any Input Here! To keep the users away from Output-Fields, you should lock and Protect them from User-being modified. Set the Field to be Protected(PROT).

As the COBOL-Program accesses this Destination-Field to store the Final-Output, the Field must have a meaningful name or Tag(like Tommy, Rocky, just kidding!), by which the COBOL-Program can refer to it. I’d like to call my Output-Field by the name RESULT.

Here’s the BMS Code for the Output-Screen OUTMAP. Should be easy now.


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.