Top Banner
An Introduction to Mainframes An Introduction to Mainframes Rijo Joseph 05-Dec-2007
246

An Introduction to Mainframes

Oct 24, 2014

Download

Documents

mbala2k4
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: An Introduction to Mainframes

An Introduction to Mainframes

An Introduction to Mainframes Rijo Joseph 05-Dec-2007

Page 2: An Introduction to Mainframes

An Introduction to Mainframes - 2 -

To

Reena Paulson Alapatt

My sister and best friend…

Page 3: An Introduction to Mainframes

An Introduction to Mainframes - 3 -

PREFACE This is a humble effort to introduce mainframes DISCLAIMER No author writes a book without enormous help from others. I have drawn insights and ideas from many sources - from the IBM manuals to The Times of India Capital Edition. This book is a best effort on my part; I tried my level best to gather correct information from reliable sources. COPYRIGHT You can make as many copies of this book as you wish. I would be happy if you share it with others. You can’t sell it, nor modify the contents of this book, nor claim the material as your own, nor replace my name with another. ABOUT THE AUTHOR Rijo Joseph holds Masters Degree in Computer Applications from University of Kerala (India) and at present working as a technical team lead with IBM India Pvt Ltd The author is IBM certified DB2 Associate, DB2 Application Developer, and Solutions Expert Your feedback is most welcome; send your comments to [email protected] ABOUT THE BOOK The book has been divided into two parts. The PART-1 contains information about computing history, computers, mainframes and mainframe OS and PART-2 contains Tips and Tricks and technical tidbits in COBOL, JCL, and DB2 etc BOOK EDITIONS Dec-05-07 – First Edition The author shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book.

Page 4: An Introduction to Mainframes

An Introduction to Mainframes - 4 -

ACKNOWLEDGEMENT It took me almost 3 years and a rigorous 2 months to complete this work. And I could say those 2 months were the toughest time in my life. The almighty chose those 2 months to teach me few tough lessons in life; however he made sure that my work is completed on time. Strange are your ways O Lord! I chose Dec 5 to publish this book as today is my sister’s birthday. This book goes as a surprise birthday gift to my sister. She is the one who ignited a change in my life that enabled me to think beyond the boundaries I express my sincere gratitude to My parents, AV Joseph and Elsamma Joseph, my brother in law and sister, Paulson Jose Alapatt and Reena Paulson Alapatt, my cousins Fr. Benny Maramparampil and Sr. Tresa John for their love, support, guidance and prayers My managers at US Technologies - Saju Mathew, Sabu Purushothaman, Rajesh Subramony, Sunil Balakrishnan, Manjith Sundaresan and my managers at IBM India - Rajiv Mittal, Pawan Wig, Gautam K Varma, Santanu Dev for an unmatched support, motivation and guidance My SMEs, Managers and Technical Staff at Duke Energy/IBM US. This book goes as a souvenir for a 2 year long association with them. The motivation and help provided by Dave Miller, Tom Susman, Jim Kanet, Don Shull, and Grant Marsh were fantastic. They are a group of wonderful people. My friends, specifically to Lismi Sundaran, Nancy George, Sooraj Puthiyadath and Sarath Babu who made me believe that I could actually complete this work and most of the time they woke me up from my dreams and put me on my writing chair Sandeep Midha for providing me with the necessary reference books and Prateek Vijayvergia for providing me with necessary software for converting my work in MS Word to a .pdf format All the ‘ghosts’ who came to interfere in my work, though you could take several days out of my schedule and you could crush me to the maximum, you couldn’t do anything else. The baton is still in my hand and I have the final laugh. I enjoyed your presence, you taught me few lessons too. Thanks for that and better luck next time! I wanted to write a complete book, but I found it would take more years for me to complete, I followed a prototype approach. I will refine this book as and when I get valuable suggestions and advices from you. You can send your valuable suggestions to [email protected] or you can post your comments at http://www.geocities.com/rijosmailbox Rijo Joseph Dec-05-2007

Page 5: An Introduction to Mainframes

An Introduction to Mainframes - 5 -

TABLE OF CONTENTS PART - 1 Chapter - 1 1. A Brief History of Computing ..................................................................................... 16

1.1. Abacus..................................................................................................................... 16 1.2. Napier’s Bones........................................................................................................ 17 1.3. Blaise Pascal and Pascaline .................................................................................... 18 1.4. Gottfried Wilhelm Leibniz and Leibniz’s calculator .............................................. 18 1.5. Joseph Marie Jacquard and Punched Cards ............................................................ 19 1.6. Charles Babbage ..................................................................................................... 20 1.7. Herman Hollerith and the Tabulating Machine ...................................................... 21 1.8. History of IBM........................................................................................................ 21 1.9. Generation of Computers........................................................................................ 22

1.9.1. Evolution of the First Generation of Modern Computers .............................. 22 1.9.2. The First Generation ...................................................................................... 23

1.9.2.1. ENIAC ....................................................................................................... 24 1.9.2.2. EDVAC...................................................................................................... 25 1.9.2.3. EDSAC ...................................................................................................... 25 1.9.2.4. UNIVAC – I .............................................................................................. 25

1.9.3. The Second Generation.................................................................................. 26 1.9.4. The Third Generation..................................................................................... 26 1.9.5. The Fourth Generation................................................................................... 28 1.9.6. The Fifth Generation...................................................................................... 30

Chapter - 2 2. Computer Classifications ............................................................................................. 32

2.1. Digital Computer .................................................................................................... 32 2.1.1. Special Purpose Computer............................................................................. 33 2.1.2. General Purpose Computer ............................................................................ 33 2.1.3. Microcomputer............................................................................................... 33 2.1.4. Minicomputer................................................................................................. 33 2.1.5. Mainframe Computer..................................................................................... 35 2.1.6. Super Computer ............................................................................................. 37

2.2. Analog Computer.................................................................................................... 40 2.3. Hybrid Computer .................................................................................................... 40

Page 6: An Introduction to Mainframes

An Introduction to Mainframes - 6 -

Chapter - 3 3. More about Mainframes............................................................................................... 42

3.1. Factors Contributing to Mainframe use .................................................................. 43 3.1.1. Reliability, Availability, and Serviceability................................................... 43 3.1.2. Security .......................................................................................................... 43 3.1.3. Scalability ...................................................................................................... 43 3.1.4. Continuing Compatibility .............................................................................. 44

3.2. Typical Mainframe Workloads ............................................................................... 45 3.2.1. Batch Processing............................................................................................ 45 3.2.2. Online Transactional Processing.................................................................... 46

3.3. A peep into the history............................................................................................ 47 3.3.1. System/360..................................................................................................... 47 3.3.2. System/370..................................................................................................... 49

3.3.2.1. Multiprocessing ......................................................................................... 52 3.3.2.2. Channels .................................................................................................... 52 3.3.2.3. PR/SM........................................................................................................ 53 3.3.2.4. LPAR ......................................................................................................... 53 3.3.2.5. I/O Devices ................................................................................................ 53

3.3.2.5.1. Unit Record Devices............................................................................ 53 3.3.2.5.2. Magnetic Tape Devices ....................................................................... 54 3.3.2.5.3. Direct Access Device........................................................................... 54

3.3.2.6. Data Communications Equipment ............................................................. 55 3.3.2.7. Characteristic Features of Mainframe OS ................................................. 56

3.3.2.7.1. Virtual Storage..................................................................................... 56 3.3.2.7.2. Multiprogramming............................................................................... 57 3.3.2.7.3. Spooling............................................................................................... 57 3.3.2.7.4. Batch Processing.................................................................................. 57 3.3.2.7.5. Time Sharing........................................................................................ 58

3.3.2.8. A small mainframe configuration.............................................................. 59 3.3.2.9. MVS Concepts........................................................................................... 60

3.3.2.9.1. Address Space...................................................................................... 60 3.3.2.9.2. Paging .................................................................................................. 61 3.3.2.9.3. Expanded Storage ................................................................................ 62 3.3.2.9.4. Swapping ............................................................................................. 62

3.3.2.10. The MVS system ................................................................................... 63 3.3.2.10.1. System Generation............................................................................. 63 3.3.2.10.2. System Initialization .......................................................................... 64

3.3.2.11. XA and 31 bit addressing ...................................................................... 64 3.3.3. System/390..................................................................................................... 65 3.3.4. eServer zSeries 900........................................................................................ 67 3.3.5. eServer zSeries 990........................................................................................ 69

Page 7: An Introduction to Mainframes

An Introduction to Mainframes - 7 -

Chapter - 4 4. z/Architecture and z/OS ............................................................................................... 73

4.1. Logical Structure of a z/Architecture system with 2 CPUs .................................... 73 4.1.1. Main Storage.................................................................................................. 73 4.1.2. Expanded Storage .......................................................................................... 74 4.1.3. CPU................................................................................................................ 74

4.1.3.1. PSW ........................................................................................................... 74 4.1.3.2. General Registers....................................................................................... 75 4.1.3.3. Floating Point Registers............................................................................. 75 4.1.3.4. Floating Point Control Register ................................................................. 75 4.1.3.5. Control Registers ....................................................................................... 75 4.1.3.6. Access Registers ........................................................................................ 75

4.1.4. Cryptographic Facility ................................................................................... 76 4.1.5. External Time Reference ............................................................................... 76 4.1.6. I/O .................................................................................................................. 76 4.1.7. Channel Subsystem........................................................................................ 76 4.1.8. Channel Paths................................................................................................. 77 4.1.9. I/O Devices and Control Units....................................................................... 77 4.1.10. Operator Facilities.......................................................................................... 77

4.2. Operating System.................................................................................................... 77 4.3. z/OS......................................................................................................................... 78

4.3.1. Hardware resources used by z/OS ................................................................. 78 4.3.2. Multiprogramming and Multiprocessing ....................................................... 79 4.3.3. Control Blocks ............................................................................................... 79 4.3.4. Physical Storage used by z/OS ...................................................................... 80 4.3.5. More about storage ........................................................................................ 80

4.3.5.1. Storage Addressing.................................................................................... 81 4.3.5.2. Information Formats .................................................................................. 81 4.3.5.3. Integral Boundaries.................................................................................... 81 4.3.5.4. Address Types ........................................................................................... 82 4.3.5.4.1. Absolute Address................................................................................... 82 4.3.5.4.2. Real Address.......................................................................................... 82 4.3.5.4.3. Prefixing ................................................................................................ 82 4.3.5.4.4. Virtual Address...................................................................................... 82 4.3.5.5. Cache Memory........................................................................................... 83 4.3.5.6. Virtual Memory ......................................................................................... 83 4.3.5.7. Virtual Memory and z/OS.......................................................................... 85

4.3.5.7.1. What does it really mean?.................................................................... 85 4.3.5.8. Address Space............................................................................................ 85 4.3.5.9. Virtual Storage Operation - Overview....................................................... 86

4.3.5.9.1. Paging .................................................................................................. 86 4.3.5.9.2. Virtual Storage Address....................................................................... 87 4.3.5.9.3. Dynamic Address Translation ............................................................. 88 4.3.5.9.4. Frames, Pages, and Slots...................................................................... 90 4.3.5.9.5. Page Stealing........................................................................................ 91 4.3.5.9.6. Swapping ............................................................................................. 91

Page 8: An Introduction to Mainframes

An Introduction to Mainframes - 8 -

4.3.6. Brief History of 64 bit addressability............................................................. 92 Chapter - 5 5. Leftover.......................................................................................................................... 96

5.1. Job roles in the mainframe world............................................................................ 96 5.1.1. System Programmer....................................................................................... 96 5.1.2. System Administrator .................................................................................... 97 5.1.3. Application Designers and Programmers ...................................................... 97 5.1.4. System Operator............................................................................................. 98 5.1.5. Production Control Analyst ........................................................................... 98

5.2. Program Products for z/OS ..................................................................................... 98 PART - 2 Chapter - 1 1. COBOL – Tips and Tricks ......................................................................................... 102

1.1. Tips and Tricks! .................................................................................................... 102 1.2. BLOCK Structure in Files (COBOL) – General Perspective ............................... 102 1.3. REDEFINES Clause ............................................................................................. 104 1.4. RENAMES Clause................................................................................................ 105 1.5. USAGE Clause ..................................................................................................... 107

1.5.1. USAGE IS DISPLAY.................................................................................. 107 1.5.2. USAGE IS COMPUTATIONAL / COMP / BINARY ............................... 107 1.5.3. USAGE IS COMP-1 .................................................................................... 108 1.5.4. USAGE IS COMP-2 .................................................................................... 108 1.5.5. USAGE IS COMP-3 .................................................................................... 108

1.6. Different forms of EVALUATE Statement .......................................................... 109 1.7. Do you know? ....................................................................................................... 110

1.7.1. Performance Considerations for Indexes VS Subscripts ............................. 110 1.7.2. Rule of the Thumb for SEARCH and SEARCH ALL................................. 110 1.7.3. Packed Decimal ........................................................................................... 111

1.8. Meaning of Device Name in SELECT Clause...................................................... 111 1.9. NEXT SENTENCE and CONTINUE .................................................................. 111 1.10. S0C7 Abend ..................................................................................................... 113 1.11. SEARCH and SEARCH ALL.......................................................................... 122 1.12. Static and Dynamic Subroutine CALLs........................................................... 122

1.12.1. Static CALLs ............................................................................................... 122 1.12.1.1. Good things about Static CALLs......................................................... 122 1.12.1.2. Bad things about Static CALLs ........................................................... 123

1.12.2. Dynamic CALLs.......................................................................................... 123 1.12.2.1. Good things about Dynamic CALLs ................................................... 124 1.12.2.2. Bad things about Dynamic CALLs ..................................................... 124

Page 9: An Introduction to Mainframes

An Introduction to Mainframes - 9 -

1.12.3. Which is Better Static or Dynamic?............................................................. 124 1.13. Why READ FILE and WRITE RECORD? ..................................................... 125 1.14. RETURN CODE of Internal SORT................................................................. 125 1.15. Efficient COBOL Coding Techniques ............................................................. 125

1.15.1. Data Types ................................................................................................... 125 1.15.1.1. BINARY (COMP OR COMP-4)......................................................... 125 1.15.1.2. PACKED DECIMAL (COMP-3)........................................................ 126

1.15.2. Comparing Data Types ................................................................................ 127 1.15.3. Data Conversions......................................................................................... 127 1.15.4. INDEXES Vs SUBSCRIPTS ...................................................................... 128

1.16. Compiler options that affect run time performance ......................................... 128 1.16.1. AWO or NOAWO ....................................................................................... 128 1.16.2. OPTIMIZE(STD), OPTIMIZE(FULL) OR NOOPTIMIZE ....................... 129 1.16.3. SSRANGE or NOSSRANGE...................................................................... 129 1.16.4. TRUNC – BIN, STD OR OPT .................................................................... 130 1.16.5. NUMPROC – NOPFD, MIG OR PFD ........................................................ 130 1.16.6. DYNAM Or NODYNAM ........................................................................... 131 1.16.7. RENT or NORENT...................................................................................... 131

1.17. Run Time Options that Affect Run Time Performance ................................... 132 1.17.1. ALL 31......................................................................................................... 132 1.17.2. CHECK........................................................................................................ 132

1.18. Dynamic Array................................................................................................. 133 Chapter - 2 2. DB2 – Tips and Tricks................................................................................................ 135

2.1. Null Indicator ........................................................................................................ 135 2.2. DBRM................................................................................................................... 135 2.3. Plan ....................................................................................................................... 135 2.4. Synonym ............................................................................................................... 135 2.5. Alias ...................................................................................................................... 136 2.6. Views .................................................................................................................... 136 2.7. How to Run a DB2 Batch Program....................................................................... 137 2.8. Why SELECT * is not preferred in embedded SQL programs?........................... 137 2.9. How does DB2 store NULL physically? .............................................................. 137 2.10. Concatenate...................................................................................................... 137 2.11. COALESCE Function in DB2 ......................................................................... 137 2.12. DCLGEN ......................................................................................................... 138 2.13. EXPLAIN......................................................................................................... 139 2.14. FETCH FIRST n ROWS ONLY...................................................................... 139 2.15. OPTIMIZE FOR n ROWS............................................................................... 140 2.16. RUNSTATS..................................................................................................... 141 2.17. IMAGECOPY.................................................................................................. 142 2.18. DECIMAL(n,m)............................................................................................... 142 2.19. Indicator Variable and -305 ABEND............................................................... 142 2.20. CASE Expressions ........................................................................................... 143

Page 10: An Introduction to Mainframes

An Introduction to Mainframes - 10 -

2.21. Query Management Facility............................................................................. 147 Chapter - 3 3. JCL – Tips and Tricks................................................................................................ 154

3.1. IEBCOPY ............................................................................................................. 154 3.1.1. Copy an entire PDS to another PDS ............................................................ 154 3.1.2. Convert a PDS to a PDSE............................................................................ 155 3.1.3. You will get error if you try the following JCL........................................... 155 3.1.4. Unloading..................................................................................................... 156 3.1.5. Loading ........................................................................................................ 156 3.1.6. Compressing ................................................................................................ 157 3.1.7. SELECT....................................................................................................... 157 3.1.8. EXCLUDE................................................................................................... 158 3.1.9. Rename ........................................................................................................ 158 3.1.10. Merging PDSs.............................................................................................. 159

3.2. IEBGENER........................................................................................................... 159 3.2.1. Create a data set from in stream data ........................................................... 160 3.2.2. Backup of a PDS/PDSE member to another PDS/PDSE............................. 160 3.2.3. Backup of a sequential data set to another sequential data set..................... 161 3.2.4. Backup of a sequential data set to a member of a PDS/PDSE..................... 161 3.2.5. Back up copy of a PDS/PDSE member to a sequential data set .................. 162 3.2.6. To produce PDSE from a PDS member ...................................................... 162 3.2.7. To change the block size.............................................................................. 163 3.2.8. You will get error if you try the following JCL........................................... 163

3.3. PDSE..................................................................................................................... 164 3.3.1. Batch Allocation .......................................................................................... 164 3.3.2. TSO/E Allocation......................................................................................... 165 3.3.3. ISPF Allocation............................................................................................ 165 3.3.4. IEBCOPY TO CONVERT A PDS TO PDSE............................................. 166 3.3.5. When to use a PDSE.................................................................................... 166

3.4. (NEW, CATLG, CATLG) and a production ABEND.......................................... 167 3.5. Another Production ABEND – JCL ERR............................................................. 168 3.6. ICETOOL ............................................................................................................. 169 3.7. ICETOOL - count the records............................................................................... 170 3.8. SORT – modify the output record......................................................................... 171

Chapter - 4 4. DFSORT – Tips and Tricks ....................................................................................... 174

4.1. DFSORT Unleashed ............................................................................................. 174 4.2. A simple JCL for SORT ....................................................................................... 175 4.3. INCLUDE Control Statement............................................................................... 176 4.4. Bit Logic Tests...................................................................................................... 187

Page 11: An Introduction to Mainframes

An Introduction to Mainframes - 11 -

Chapter - 5 5. TSO/ISPF – Tips and Tricks...................................................................................... 192

5.1. COBOL Compiler Version ................................................................................... 192 5.2. HRECALL ............................................................................................................ 192 5.3. TSO SEND/TRANSMIT ...................................................................................... 192 5.4. Information about your DS ................................................................................... 192 5.5. Save a sequence of commands.............................................................................. 192 5.6. Tape Datasets ........................................................................................................ 192 5.7. SB37 on Saving a DS............................................................................................ 193 5.8. No space in directory ............................................................................................ 193 5.9. CREATE/REPLACE ............................................................................................ 193

5.9.1. CREATE...................................................................................................... 193 5.9.2. REPLACE.................................................................................................... 194 5.9.3. Saving a DS in view mode........................................................................... 194

5.10. CUT/PASTE .................................................................................................... 194 5.11. ISPF EDITOR COMMANDS ......................................................................... 195 5.12. FLIP ................................................................................................................. 196 5.13. Auto complete .................................................................................................. 196 5.14. NRETRIEV...................................................................................................... 197

Chapter - 6 6. VSAM – Tips and Tricks............................................................................................ 199

6.1. VSAM Basics........................................................................................................ 199 6.1.1. VSAM Overview ......................................................................................... 199 6.1.2. What is VSAM?........................................................................................... 199 6.1.3. Catalog Management ................................................................................... 200 6.1.4. Record Management .................................................................................... 200 6.1.5. Logical Record & Physical Record.............................................................. 200 6.1.6. Control Interval............................................................................................ 200 6.1.7. More about VSAM ...................................................................................... 201

6.2. VSAM Data Sets................................................................................................... 202 6.2.1. KSDS ........................................................................................................... 202 6.2.2. ESDS............................................................................................................ 203 6.2.3. RRDS ........................................................................................................... 204 6.2.4. LDS.............................................................................................................. 205

6.3. Accessing & Inserting VSAM Data...................................................................... 206 6.4. Alternate Index...................................................................................................... 209 6.5. PATH and AIX ..................................................................................................... 211

Page 12: An Introduction to Mainframes

An Introduction to Mainframes - 12 -

Chapter - 7 7. General – Tips and Tricks.......................................................................................... 214

7.1. 10 Common Abends ............................................................................................. 214 7.2. Comparing 2 files of different layouts .................................................................. 215 7.3. Counting the number of records ........................................................................... 216

7.3.1. Tape Data Set............................................................................................... 216 7.3.2. DASD Data Set ............................................................................................ 216

7.4. Processing Options in IMS DB............................................................................. 217 7.4.1. DEFINING THE IMS DATABASE ........................................................... 217 7.4.2. IMS DL/I DATA BASE TYPES ................................................................. 219 7.4.3. PROCOPT.................................................................................................... 221

Chapter - 8 8. ISPF Editor Commands ............................................................................................. 225

8.1. < - Data Shift Left ................................................................................................ 225 8.2. > - Data Shift Right.............................................................................................. 225 8.3. ( - Column Shift Left............................................................................................ 225 8.4. ) - Column Shift Right ......................................................................................... 225 8.5. AUTOSAVE ......................................................................................................... 226 8.6. BOUNDS .............................................................................................................. 226 8.7. BROWSE.............................................................................................................. 227 8.8. CHANGE.............................................................................................................. 228 8.9. COMPARE ........................................................................................................... 228 8.10. CREATE/REPLACE ....................................................................................... 232

8.10.1. CREATE...................................................................................................... 232 8.10.2. REPLACE.................................................................................................... 232 8.10.3. Saving a DS in view mode........................................................................... 233

8.11. CUT/PASTE .................................................................................................... 233 8.12. DEFINE ........................................................................................................... 234 8.13. EDIT................................................................................................................. 235 8.14. EDITSET or EDSET........................................................................................ 235 8.15. F ....................................................................................................................... 235 8.16. FLIP ................................................................................................................. 236 8.17. L ....................................................................................................................... 236 8.18. LC/LCC............................................................................................................ 236 8.19. LOCATE/L ...................................................................................................... 236 8.20. O....................................................................................................................... 236 8.21. PROFILE ......................................................................................................... 239 8.22. RECOVERY .................................................................................................... 239 8.22. SETUNDO....................................................................................................... 240 8.23. SORT ............................................................................................................... 240 8.24. TS..................................................................................................................... 240

Page 13: An Introduction to Mainframes

An Introduction to Mainframes - 13 -

8.25. UC .................................................................................................................... 240 8.26. UNDO .............................................................................................................. 240

Page 14: An Introduction to Mainframes

An Introduction to Mainframes - 14 -

PART - 1

Page 15: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 15 -

Chapter 1

A Brief History of Computing

Page 16: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 16 -

1. A Brief History of Computing It has been an amazing journey… really it is. As you go through this chapter, you can see the computer takes its shape from an abacus to a lap top machine! What a transformation! The transformation took a slow and steady fashion - Abacus, Napier’s Bones, Pascaline…Vacuum Tubes, Transistors, Integrated Circuits, Micro Processors… The true brilliance is human: the genius of men and women who have found a way to translate a variety of information from the real world into the zero’s and one’s of binary code – the logical and mathematical language tailor made for a computer’s electronic circuitry - the language of the machines. Computer is not really a brain, not at least till now. Rather it is simply another tool, another piece of machinery devised to reduce labor or extend our mastery of the world Still, no other machine in history has so rapidly or so thoroughly changed the world. Computers have made possible such epic achievements as lunar landings, and planetary probes, and they account for a myriad everyday conveniences and benefits in the field of science, medicine, education, banking, communication etc. In short, computers have woven into the very fabric of modern life. Despite the head-spinning pace of modern advances, the foundations of the computer revolution were built in slow and fitful fashion

1.1. Abacus A starting point, more than 1500 years ago, and probably in the Mediterranean world – was the development of abacus. An abacus, also called a counting frame, is a calculating tool for performing arithmetical processes, often constructed as a wooden frame with beads sliding on wires. The user, called an abacist, slides counters by hand on rods or in grooves. The abacus was so efficient that it soon spread far and wide

A Chinese Abacus

Page 17: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 17 -

European thinkers of the era were fascinated by the challenge of devising aids to calculations

1.2. Napier’s Bones John Napier published his discovery of Logarithms in 1614 and in 1617 came up with an aid to multiplication called ‘Napier’s Bones’

Napier's Bones, an abacus, invented by John Napier for calculation of products and quotients of numbers The abacus consists of a board with a rim; the user places Napier's rods in the rim to conduct multiplication or division. The board's left edge is divided into 9 squares, holding the numbers 1 to 9. The Napier's rods consist of strips of wood, metal or heavy cardboard. Napier's bones are three dimensional, square in cross section, with four different rods engraved on each one. A set of such bones might be enclosed in a convenient carrying case.

John Napier A rod's surface comprises 9 squares, and each square, except for the top one, comprises two halves divided by a diagonal line. The first square of each rod holds a single-digit, and the other squares hold this number's double, triple, and quadruple and so on until the last square contains nine times the number in the top square. The digits of each product are written one to each side of the diagonal; numbers less than 10 occupy the lower triangle, with a zero in the top half.

A set consists of 9 rods corresponding to digits 1 to 9. The figure additionally shows the rod 0; although for obvious reasons it is not necessary for calculations. The rods could be arranged so that the answer to a multiplication/division problem could be found. I am not detailing the methods for multiplication/division as it is outside the scope of this book Although Napier’s theory of logarithms had an enduring impact, the ‘Napier Bones’ were soon eclipsed by the slide rule, developed

by William Oughtred, and other type of calculators – most notably a mechanical type –

Page 18: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 18 -

pioneered by a brilliant French man named Blaise Pascal. He used the principle of interlocking wheels, which remained central to the operation of most adding machines for next 300 years

1.3. Blaise Pascal and Pascaline Blaise Pascal called his machine ‘Pascaline’ which was a boxed ‘wheel-and-cog’ machine. Its most serious draw back was its convoluted method of performing any calculations other than simple addition

Blaise Pascal Pascaline

1.4. Gottfried Wilhelm Leibniz and Leibniz’s calculator The first machine that could do subtraction, multiplication, and division easily was invented by a German genius, whose imagination seemed to spawn no end to original ideas - Gottfried Wilhelm Leibniz (1646-1716). He discovered calculus independently of Newton, and his notation is the one in general use since. He also discovered the binary system, foundation of virtually all modern computer architectures In 1671, Leibniz invented a calculating machine which was a major advance in mechanical calculating. The Leibniz calculator incorporated a new mechanical feature, the stepped drum — a cylinder bearing nine teeth of different lengths which increase in equal amounts around the drum. Although the Leibniz calculator was not developed for commercial production, the stepped drum principle survived for 300 years and was used in many later calculating systems

Page 19: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 19 -

Leibniz Leibniz’s Calculator

1.5. Joseph Marie Jacquard and Punched Cards The next great advancement had nothing to do with the numbers. Throughout the 18th century, French weavers had experimented with schemes for guiding their looms by perforated tapes, punch cards or wooden drums In 1804, Joseph Marie Jacquard built a fully automated loom that could handle enormously complicated designs. The loom was programmed by a mountain of punched cards, each controlling a single throw of the shuttles. The Jacquard loom revolutionized the weaving industry, and in its essential features, is still used today Jacquard’s effort is considered as the first practical use of the binary system

Joseph Marie Jacquard Jacquard Loom

Page 20: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 20 -

1.6. Charles Babbage Charles Babbage (26 December 1791 – 18 October 1871) was an English mathematician, philosopher, and mechanical engineer who originated the idea of a programmable computer

In 1822, Charles Babbage wrote a scholarly paper describing a machine that could compute and print lengthy scientific papers. The same year he built a preliminary model of this ‘Difference engine’, made with toothed wheels on a shaft turned by a crank. For the next 10 years, Babbage wrestled with his brain-child, but the difference engine grew increasingly complex as he modified, enhanced and redesigned it

In 1833 Charles Babbage conceived an ambitious plan for a general purpose calculating machine which in many features of its design is functionally analogous to the modern computer. It was designed to contain a memory or "store," an arithmetic unit or "mill" capable of performing the four operations of arithmetic, an input/output system which used punched cards, and a printer to display the results. The engine would have been steam-driven and programmed by the punched cards. The engine was designed in great detail on paper but it was never completed, all that exists of it are reams of plans and drawings and a small portion of the mill and printer built by Babbage’s son. The difference engine fared better. It was modified and rebuilt by the Swedish Pehr George Scheutz, winning a gold medal in the exhibition at Paris

Difference Engine Analytical Engine

Page 21: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 21 -

1.7. Herman Hollerith and the Tabulating Machine Just 19 years after the death of Babbage, one aspect of the Analytical Engine – the punched cards appeared in a functioning machine. The machine was a statistical tabulator built by the American Herman Hollerith to speed up the processing of the returns of the 1890 US census The cards in Hollerith’s tabulator were the size of dollar bill. So swift was Hollerith’s machine that a simple count of the census was ready in six weeks, and a full statistical analysis in two and a half years, reducing the time required as compared to the previous census by one third. The Hollerith’s tabulating machine was a big success. He formed the Tabulating Machine Company to sell his invention

Herman Hollerith Tabulator

1.8. History of IBM IBM originated as the Computing Tabulating Recording (CTR) Company, which was incorporated on June 16, 1911 in Endicott, New York, United States of America. CTR was formed through a merger of three separate companies: Tabulating Machine Company (founded 1896 in Washington D.C.), the International Time Recording Company (founded 1900 in Endicott), and the Computing Scale Company (founded 1901 in Dayton, Ohio, USA). The key person behind the merger was financier Charles R. Flint, who brought together the founders of these companies to propose a merger and remained a member of the board of CTR until his retirement in 1930. The president of the Tabulating Machine Company at the time of the merger was Herman Hollerith, who had founded the company and was a seminal figure in the industry. His series of patents on tabulating machine technology, first applied for in 1884, drew on his work at

Page 22: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 22 -

the U.S. Census Bureau from 1879-82. Hollerith was initially trying to reduce the time and complexity needed to tabulate the 1890 Census. His transition to the use of punch cards, in 1886, laid a foundation for generations of equipment and a core component of what would become IBM.

The companies that merged to form CTR manufactured a wide range of products, including employee time-keeping systems, weighing scales, automatic meat slicers, and most importantly for the development of the computer, punched card equipment. Over time CTR came to focus purely on the punched card business, and ceased its involvement in the other activities. Thomas J. Watson Sr became General Manager of CTR in 1914 and President in 1915. In 1917, CTR entered the Canadian market under the name of International Business Machines Co., Limited and in February 14, 1924, CTR changed its name to International Business Machines Corporation. At the helm during this period, Watson played a central role in establishing what would become the IBM organization and culture.

Thomas J. Watson, Sr

1.9. Generation of Computers The term ‘computer generation’ is often used in relation to the hardware of computers. Each phase of computer development is known as a separate generation of computers. Each phase of development is characterized by the type of switching circuits it utilizes

1.9.1. Evolution of the First Generation of Modern Computers Around 1930, scientists began making significant progress towards devising machines for performing complex computations. Vannevar Bush’s Differential Analyzer ushered in the modern computer age. Alan Turing published his seminal paper ‘On computational Numbers’ in the year 1936 In the same year, in a landmark thesis, Claude Shannon showed the link between symbolic logic and electrical circuits paving the way for use of electricity in computation machines. It has been claimed that this was the most important master's thesis of all time. Shannon has been called ‘the father of information theory’

Claude Shannon

Page 23: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 23 -

1.9.2. The First Generation The first one of two first generation computers appeared. The Colossus, in 1943, went into service cracking top secret German codes during World War II Colossus was designed by engineer Tommy Flowers at the Post Office Research Station, Dollis Hill with input from mathematician Max Newman and group at Bletchley Park. The prototype, Colossus Mark I, was shown working in December 1943 and was operational at Bletchley Park by February 1944. An improved Colossus Mark II was first installed in June 1944, with input from Allen Coombs, and ten Colossi had been constructed by the end of the war.

Colossus Mark II Computer In a landmark memorandum published in 1945, Hungarian born mathematician John von Neumann, laid out in detail the five key components of what is often called the ‘von Neumann architecture’ of the modern computer. He wrote that to be both efficient and general purpose, a modern computing system, must have a central arithmetic unit (ALU), a central control unit to orchestrate operations, a memory, an input unit and an output unit. He also noted that the system should work with binary digits, operate electronically, and perform its operations one at a time The von Neumann architecture (Stored program concept) is based on three key concepts that are

1) Data and instructions (program) are stored in a single read-write memory 2) The memory contents are addressable by locations 3) Execution takes place in a sequential fashion i.e., from one instruction to the next

unless modified explicitly

Page 24: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 24 -

John von Neumann John von Neumann model The first generation computers used vacuum tubes and machine language was used for giving instructions. The first generation computers used the concept of ‘stored program’. The computers of this generation were very large in size and their programming was a difficult task. The following computers belong to the first generation

1.9.2.1. ENIAC Based on the above principles, which are a commonplace even today, the first large scale electronic digital computer, the ENIAC (Electronic Numerical Integrator And Calculator) was unveiled by J. Presper Eckert and John Mauchly in the year 1946 at the University of Pennsylvania in USA. This computer used high speed vacuum tube switching devices. It has a very small memory and it was used for calculating the trajectories of missiles. It took 200 microseconds for addition and about 2800 microseconds for multiplication. This giant machine was 30X50 feet long, weighed 30 tons, contained 17,468 vacuum tubes, 7,200 crystal diodes, 1,500 relays 70,000 resistors, 10,000 capacitors, 6000 switches, used 150,000 watts of electricity. When ENIAC was built, it was 5000 times faster than the closest competitor MARK-1

ENIAC

Page 25: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 25 -

1.9.2.2. EDVAC The binary arithmetic was used in the construction of a computer called Electronic Discrete Variable Automatic Computer (EDVAC), completed in 1950. The von Neumann concept of stored program was also applied in EDVAC. With this, the operation became faster since the computer could rapidly access both the program and data

1.9.2.3. EDSAC The EDSAC, short for Electronic Delay Storage Automatic Computer was built by M.V Wilkes at Cambridge University in 1949 and used mercury delayed lines for storage. It also used Neumann concept of ‘stored program’. This allowed easy implementation of program loops

1.9.2.4. UNIVAC – I Commercial production of stored program electronic computers began in the early 50’s. One such computer was UNIVAC – I, built by Univac division of Remington Rand and delivered in 1951. This computer also used vacuum tubes Initial applications of computers those days were in science and engineering but with the advent of UNIVAC – I, the prospect of commercial application were perceived The first generation computers suffered from some ‘big’ limitations like slow operating speed, restricted computing capacity, high power consumption, short mean time between failures, very large space requirement and limited programming capabilities. Further researches in this line aimed at removal of these limitations

UNIVAC

Page 26: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 26 -

1.9.3. The Second Generation John Bardeen, William Shockley and Walter Brattain invented the transistor in 1947 at Bell Labs. It replaced the vacuum tubes, reducing the size and increasing the speed of the computer. In 1951, the first business computer – the LEO, was introduced

Vacuum tube and the Transistor LEO

In 1952, broadcast newsman, Walter Cronkite used a UNIVAC computer to predict a presidential election The increased reliability and availability of large memories paved the way for the development of high level languages such as FORTRAN, COBOL, Algol and Snobol etc. With speedy CPUs and the advent of magnetic tape and disk storage, operating systems came into being. Batch operating systems ruled the second generation computers

1.9.4. The Third Generation The Third Generation was ushered by the invention of the integrated circuit. A single integrated circuit has many transistors, resistors and capacitors along with the associated circuitry encapsulated in a small package with many leads Jack Kilby is probably most famous for his invention of the integrated circuit, for which he received the Nobel Prize in Physics in the year 2000. After his success with the integrated circuit Kilby stayed with Texas Instruments and, among other things, he led the team that invented the hand-held calculator

Page 27: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 27 -

Integrated Circuit Robert Noyce came up with his own idea for the integrated circuit. He did it half a year later than Jack Kilby. Noyce's circuit solved several practical problems that Kilby's circuit had, mainly the problem of interconnecting all the components on the chip. This was done by adding the metal as a final layer and then removing some of it so that the wires needed to connect the components were formed. This made the integrated circuit more suitable for mass production. Besides being one of the early pioneers of the integrated circuit, Robert Noyce also was one of the co-founders of Intel. Intel is one of the largest manufacturers of integrated circuits in the world.

Jack Kilby Robert Noyce From small scale integrated (SSI) circuits which had about 10 transistors per chip, technology developed to medium scale integrated (MSI) circuits with 100 transistors per chip. The size of main memories reached about 4 megabytes. Magnetic disk technology also improved and it became feasible to have drive having capacity up to 100MBs. The CPUs became much more powerful with the capacity of carrying out 1 million instructions per second (MIPS) The third generation computers using integrated circuits proved to be highly reliable, relatively inexpensive and faster. Less human labor was required at assembly stage. Examples of some mainframe computers developed during this generation are IBM 360

Page 28: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 28 -

series, ICL -1900 series, IBM 370/168, ICL -2900, Honeywell Model 316, Honeywell -6000 series. Some mini computers developed during this phase are ICL -2903 manufactured by International Computers Limited, CDC -1700 manufactured by Control Data Corporation and PDP -11/45 (Personal Data Processor -11/45) from Digital Equipment

1.9.5. The Fourth Generation The advent of the microprocessor chip marked the beginning of the fourth generation computers. Medium Scale Integrated (MSI) circuits yielded to Large and Very Large Scale integrated (VLSI) circuits packing about 50000 transistors in a chip. Semiconductor memories replaced magnetic core memories. The emergence of the microprocessor (CPU on a single chip) led to the emergence of extremely powerful personal computers. Computer costs came down so rapidly that these found places in most offices and homes. The faster accessing and processing speeds and increased memory capacity helped in development of much powerful operating systems 1971: Ted Hoffman designed the Intel 4004 microprocessor – a single chip with all the basic parts of a central processor – triggering a series of new developments 1974: Ed Roberts of MITS built a microcomputer called Altair 1975: Students, Bill Gates and Paul Allen created the first personal computer software – a form of BASIC for the Altair 1977: Three mass-market personal computers emerged in one year: the Apple II, Radio Shack TRS-80 and the Commodore 1981: IBM, long dominated in big computers, entered the personal computer market with the IBM PC

Original IBM PC

Page 29: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 29 -

The second decade of the fourth generation observed a great increase in the speed of microprocessors and the size of main memory. The speed of microprocessors and the size of main memory and hard disk went up by a factor of 4 every 3 years. Many of the mainframe CPU features became part of the microprocessor architecture in 90s. Also RISC (Reduced Instruction Set Computers) microprocessors are preferred in powerful servers for numeric computing and file services The computer networks came of age and are one of the most popular ways of interacting with computer chains of millions of users. The computers are being applied in various areas like simulation, visualization, parallel computing, virtual reality, multimedia etc. At the time of writing, a Lenovo M series has the following configuration

Lenovo M series Processor: Up to dual-core processor Memory: Up to 8GB Hard Drive: Up to 500GB And a Lenovo Y series Home/Home office widescreen has the following configuration

Lenovo Y series Processor: Up to Intel® Core™2 Duo Processor T5450 (1.66GHz) Memory: Up to 4GB DDR2 Hard Drive: 160GB

Page 30: An Introduction to Mainframes

A Brief History of Computing

An Introduction to Mainframes - 30 -

1.9.6. The Fifth Generation The fifth generation computers are on the way! The researchers are aiming at developing a machine that can be spoken to in simple plain language and is able to converse the way we human beings do. For this the concept of Artificial Intelligence (AI) is being used (Don’t worry about the Matrix movie). The robots of science fiction will be science facts by the end of this century if these researches meet their goal. The fifth generation, it is widely believed at the time, would turn to massive numbers of CPUs for added performance.

Page 31: An Introduction to Mainframes

Computer Classifications

An Introduction to Mainframes - 31 -

Chapter 2

Computer Classifications

Page 32: An Introduction to Mainframes

Computer Classifications

An Introduction to Mainframes - 32 -

2. Computer Classifications The computers have been classified into three categories; you can see mainframes come under the classification of ‘Size and Performance Wise’

1) Digital Computers 2) Analog Computers 3) Hybrid Computers

COMPUTERS DIGITAL ANALOG HYBRID Purpose Wise Size and Performance Wise Special Purpose General Purpose Micro Mini Mainframe Super

2.1. Digital Computer Encyclopedia Britannica defines a digital computer as any of a class of devices capable of solving problems by processing information in discrete form. It operates on data, including magnitudes, letters, and symbols, that are expressed in binary form—i.e., using only the two digits 0 and 1. By counting, comparing, and manipulating these digits or their combinations according to a set of instructions held in its memory. Computers used for business and scientific applications are digital computers. Digital computers can be further classified in two ways

1) Purpose wise 2) Size and Performance Wise

Page 33: An Introduction to Mainframes

Computer Classifications

An Introduction to Mainframes - 33 -

Purpose wise digital computers are classified into two types

2.1.1. Special Purpose Computer Special Purpose Computer is the one that is designed to perform a specific task. The instructions (programs) to carry out the task are permanently stored in the machine. For the specific tasks, this type of computer works efficiently but such computers are not versatile

2.1.2. General Purpose Computer General Purpose Computer is the one that can work on different types of programs input to it and thus being used in countless applications. The programs are not permanently stored but are input at the time of execution. These computers are very versatile Size and performance wise digital computers can be classified into four types

2.1.3. Microcomputer Although there is no single definition, a microcomputer is most often taken to mean a computer with a microprocessor as its CPU. Another general characteristic of these computers is that they occupy physically small amounts of space. Although the terms are not synonymous, many microcomputers are also personal computers (in the generic sense). This category is termed micro because the CPU was created on a single chip. These are normally single micro processor, single user systems, designed for performing basic operations like educational, training, small business applications, playing games etc. These are mainly used in offices, homes, schools, shops, stores etc. Work stations, desktops, laptops, notebooks are examples of Micro computers

A Lenovo M series Desktop A Lenovo Y series Laptop

2.1.4. Minicomputer Minicomputers are more powerful computers than micro computers in terms of processing power and capabilities. Minicomputers are mainly multi user systems where many users simultaneously work on the systems. Mini computers possess greater storage capacity and

Page 34: An Introduction to Mainframes

Computer Classifications

An Introduction to Mainframes - 34 -

larger memories as compared to micro computers. These computers are capable of handling more input - output devices Mini computer lies in the middle range of the computing spectrum, in between the largest multi-user systems (mainframe computers) and the smallest single-user systems (microcomputers or personal computers). Formerly this class formed a distinct group with its own hardware and operating systems. While the distinction between mainframe computers and smaller computers remains fairly clear, contemporary middle-range computers are not well differentiated from personal computers, being typically just a more powerful but still compatible version of a personal computer. More modern terms for minicomputer-type machines include midrange systems (IBM parlance), workstations (Sun Microsystems and general UNIX/Linux parlance), and servers. The minicomputer is used when large groups need access to data simultaneously. The minicomputer can do this because the hardware is designed for plugging in more devices and the CPU and the support chips are designed for this kind of work For example, large super markets around the world need to have their cash register send sales information to the same computer (so that the data is collected at one place) Mini computers are used by medium sized business. They are also used in factories to control automated assembly lines, manufacturing, process control, etc, Popular makers of minicomputer include DEC (Digital Equipment Corporation) – that built the popular VAX minicomputer. IBM also creates a very popular mini computer range with a branding of the AS/400. HP has a popular mini computer range branded HP9000 Unlike Micro computers, most mini computers provide more than one terminal so that several people can use the system at one time. A system like this is called a multi user system We can see few examples of midrange (mini) computers IBM System i™ 515 Express

Page 35: An Introduction to Mainframes

Computer Classifications

An Introduction to Mainframes - 35 -

At the time of writing, an IBM System i™ 515 Express has the following features Software : i5/OS®, Windows Server™, Linux, AIX 5L™ Memory (Range) : Up to 16 GB Disk (Range) : Up to 560 GB Processor : POWER5+ 1.9 GHz IBM System i™ 595

At the time of writing, an IBM System i™ 595 has the following features Software : i5/OS, Linux®, Windows Server®, AIX 5L™ Memory (Range) : Up to 2 TB Disk (Range) : Up to 381 TB Processor performance : 31500 to 216000 CPW Designed for large enterprises, the System i™ 595 offers multiplatform management and maximum flexibility for customers requiring up to 64–way symmetrical multiprocessing capability CPW stands for Commercial Processing Workload - is a measure used in IBM's AS/400 and i Series line of computers to compare computer system models in terms of how efficiently each system processes a typical workload of commercial applications involving frequent database access. The CPW also represents a test of database commitment control, concurrent data access by many users, and a range of updating complexity.

2.1.5. Mainframe Computer Today, computer manufacturers don’t always use the term mainframe to refer to mainframes. Instead, most have taken to calling any commercial-use computer—large or small—a server, with the mainframe simply being the largest type of server in use today. IBM, for example, now refers to its mainframes as zSeries servers. A mainframe is the central data repository or hub in a corporation’s data processing center, linked to users through less powerful devices such as workstations or terminals. The presence

Page 36: An Introduction to Mainframes

Computer Classifications

An Introduction to Mainframes - 36 -

of a mainframe often implies a centralized form of computing, rather than a distributed form of computing. Having data centralized in a single mainframe repository saves customers from having to manage updates to more than one copy of their business data. This increases the likelihood that the data is current. This distinction, however, is rapidly blurring as smaller machines continue to gain in processing power, and mainframes become ever more flexible and multi-purpose, so a working definition can be “a mainframe is what businesses use to host the commercial databases, transaction servers, and applications that require a greater degree of security and availability than is commonly found on smaller-scale machines.” Early mainframe systems were housed in enormous, room-filling metal boxes or frames, and this is probably how the term mainframe originated. The mainframe required large amounts of electrical power and air-conditioning, and the room was occupied mostly by I/O devices. Also, a typical installation had several mainframes installed with most of the I/O devices connected to all of the mainframes. During their largest period in terms of physical size, a typical mainframe occupied 2000-10,000 square feet, with some installations being much larger than this.

Starting around 1990, mainframe processors and most of the I/O devices became physically smaller, while their functionality and capacity continued to grow. Mainframe systems today are much smaller than earlier systems--about the size of a large refrigerator. Clearly, the term “mainframe” has expanded beyond merely describing the physical characteristics of a system. Instead, the word typically applies to some combination of the following attributes:

• Compatibility with mainframe operating systems, applications, and data. • Centralized control of resources. • Hardware and operating systems that can share access to disk drives with other

systems, with automatic locking and protection against destructive simultaneous use of disk data.

• A style of operation, often involving dedicated operations staff who use detailed operations procedure books and highly organized procedures for backups, recovery, training, and disaster recovery at an alternate site.

• Hardware and operating systems that routinely work with hundreds or thousands of simultaneous I/O operations.

Page 37: An Introduction to Mainframes

Computer Classifications

An Introduction to Mainframes - 37 -

• Clustering technologies that allow the customer to operate multiple copies of the operating system as a single system. This configuration, known as Parallel Sysplex, is analogous in concept to a UNIX cluster, but allows for systems to be added or subtracted as needed while applications continue to run. This flexibility allows mainframe customers to introduce new applications, or discontinue using existing applications, in response to changes in business activity.

• Additional data and resource sharing capabilities. In a Parallel Sysplex, for example, it is possible for users across multiple systems to access the same databases concurrently, with database access controlled at the record level.

We can see few examples of mainframe computers IBM eServer zSeries 890

The IBM eServer zSeries 890 (z890) includes zSeries functionality at a lower entry capacity level than previously available on IBM z/Architecture™ hardware, as well as new granular growth options. It has one to 4 processors and the processor memory ranges from 8GB to 32 GB IBM System z9 Enterprise Class

It has one to 54 n-way processors and a processor memory range of 16 GB to 512 GB

2.1.6. Super Computer Super computers are the most powerful computers among digital computers. These consist of several processors running together thereby making them immensely faster and powerful.

Page 38: An Introduction to Mainframes

Computer Classifications

An Introduction to Mainframes - 38 -

The term "Super Computing" was first used by New York World newspaper in 1929 to refer to large custom-built tabulators IBM made for Columbia University. Supercomputers introduced in the 1960s were designed primarily by Seymour Cray at Control Data Corporation (CDC), and led the market into the 1970s until Cray left to form his own company, Cray Research. He then took over the supercomputer market with his new designs, holding the top spot in supercomputing for five years (1985–1990)

The Cray-2 was the world's fastest computer from 1985 to 1989

Columbia Supercomputer / NASA Advanced Supercomputing Facility

Page 39: An Introduction to Mainframes

Computer Classifications

An Introduction to Mainframes - 39 -

Supercomputers are mainly used in applications like weather forecasting, nuclear science research, aerodynamic modeling, seismology etc. Examples of super computers are CRAY X-MP/14, CDC -205, ETAGF – 10, FUJITSU VP – 400, NEC SX – 2, PARAM, ANURAG As of November 2006, the top ten supercomputers on the Top 500 list have the same top-level architecture. Each of them is a cluster of MIMD (Multiple Instruction stream Multiple Data stream) multiprocessors, each processor of which is SIMD (Single Instruction stream Multiple Data stream). The supercomputers vary radically with respect to the number of multiprocessors per cluster, the number of processors per multiprocessor, and the number of simultaneous instructions per SIMD processor. Within this hierarchy we have: A computer cluster is a collection of computers that are highly interconnected via a high-speed network or switching fabric. Each computer runs under a separate instance of an Operating System (OS). A multiprocessing computer is a computer, operating under a single OS and using more than one CPU, where the application-level software is indifferent to the number of processors. The processors share tasks using Symmetric multiprocessing (SMP) and Non-Uniform Memory Access (NUMA). An SIMD processor executes the same instruction on more than one set of data at the same time. The processor could be a general purpose commodity processor or special-purpose vector processor. It could also be high performance processor or a low power processor. Recently, a cluster platform at Pune’s (India) Computational Research Laboratories, a TATA subsidiary, has been ranked fourth in the widely anticipated top 500 list released at an international conference on high performance computing in Reno, Nevada and the Indian Super computer has been adjudged the fastest in Asia

Computer Site/Country Speed (Teraflops)

Maker

BlueGene/L Lawrence Livermore National Laboratory / US

478.2 IBM

BlueGene/P Jülich Research Centre / Germany

167.3 IBM

ICE 8200 New Mexico Computing Applications Center / US

126.9 SGI

HP 3000 BL460c Computational Research Laboratories / India

117.9 HP

HP 3000 BL460c Swedish National Defense Radio Establishment / Sweden

102.8 HP

Page 40: An Introduction to Mainframes

Computer Classifications

An Introduction to Mainframes - 40 -

The TATA supercomputer, named EKA after the Sanskrit term for one, is a Hewlett Packard Cluster Platform 3000 BL460c system. Computational Research Laboratories has integrated this system with its own innovative routing technology and achieved a speed of 117.9 teraflop. A teraflop is a trillion floating point operations per second The number one position has been claimed by the BlueGene/L System, a joint development of IBM and the US department of energy’s National Nuclear Security Administration and installed at DOE’s Lawrence Livermore National Laboratory, California

IBM BlueGene/L Super Computer

2.2. Analog Computer In analog computers, continuous quantities are used. Computations are carried out with physical quantities such as voltage, length, current, temperature etc. The devices that measure such quantities are analog devices e.g. voltmeter ammeter. Analog computers operate by measuring rather than counting. The main advantage of analog computers is that all calculations take place in parallel and hence these are faster. But their accuracy is poor as compared to digital counterparts. Analog computers are used mostly in engineering and scientific applications. An electronic weighting scale is an example of an analog computer

2.3. Hybrid Computer Hybrid computers utilize the best qualities of both the digital and analog computers. In these computers some calculations take place in analog manner and rest of them take place in digital manner. Hybrid computers are best used in hospital where analog part is responsible for measurement of patient’s heart beat, blood pressure, temperature and other vital signs and then the operation is carried out in digital fashion to monitor patient’s vital signs. Hybrid computers are also used in weather forecasting

Page 41: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 41 -

Chapter 3

More about Mainframes

Page 42: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 42 -

3. More about Mainframes We have seen a brief introduction about mainframes in the previous chapter, we will see more about it now The mainframe owes much of its popularity and longevity to its inherent reliability and stability, a result of careful and steady technological advances since the introduction of System/360 in 1964. No other computer architecture in existence can claim as much continuous, evolutionary improvement, while maintaining compatibility with previous releases. Because of these design strengths, the mainframe is often used by IT organizations to host the most important, mission-critical applications. These applications typically include customer order processing, financial transactions, production and inventory control, payroll, as well as many other types of work. A common impression of a mainframe user interface is the 80x24 character “green screen” terminal, named for the old CRT-based computer terminals from years ago that glowed green. However, current mainframe interfaces can look much the same as those for personal computers or UNIX systems. When a business application is accessed through a Web browser, there is often a mainframe computer providing crucial function “behind the scenes.” Many of today’s busiest Web sites store their production databases on a mainframe host. New mainframe hardware and software are ideal for Web transactions because they are designed to allow huge numbers of users and applications to rapidly and simultaneously access the same data without interfering with each other. This security, scalability, and reliability are critical to the efficient and secure operation of contemporary information processing.

IBM eServer zSeries 990 (1 to 32 Processors, Processor memory ranges from 16GB to 256GB) Businesses today rely on the mainframe to:

• Perform large-scale transaction processing (thousands of transactions per second) • Support thousands of users and application programs concurrently accessing many

resources • Manage terabytes of information in databases • Handle large-bandwidth communications

Page 43: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 43 -

3.1. Factors Contributing to Mainframe use The reasons for mainframe use are many, but most generally fall into one or more of the following categories

3.1.1. Reliability, Availability, and Serviceability Reliability: Involves the use of high quality components. In addition, hardware components have extensive self checking and self recovery. Software reliability involves extensive testing and quick updates for detected problems Availability: The ability to recover from a failed component without impacting the rest of the running system. This applies to hardware recovery (by automatically replacing failed elements with spares) and software recovery (through layers of error recovery provided by the operating system) Serviceability: Allows for the replacement of elements (hardware and software) while impacting as little of the operational system as possible. It also implies well defined units of replacement, either hardware or software Beyond Reliability, Availability, and Serviceability (known as RAS), a state of the art mainframe system might be said to provide high availability and fault tolerance. Redundant hardware components in critical paths, enhanced storage protection, a controlled maintenance process, and system software designed for unlimited availability all help to ensure a consistent, highly available environment for business applications in the event that a system component fails

3.1.2. Security In an IT environment, data security is defined as protection against unauthorized access, transfer, modification, or destruction, whether accidental or intentional. To protect data and to maintain the resources necessary to meet the security objectives, customers typically add a sophisticated security manager product to their mainframe operating system. The customer’s security administrator often bears the overall responsibility for using the available technology to transform the company’s security policy into a usable plan A secure computer system prevents users from accessing or changing any objects on the system, including user data, except through system provided interfaces that enforce authority rules. Mainframe computers can provide a very secure system for processing large numbers of heterogeneous applications that accesses critical data

3.1.3. Scalability By scalability we mean the ability of the hardware, software, or a distributed system to continue to function well as it is changed in size or volume; for example, the ability to retain

Page 44: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 44 -

performance levels when adding processors, memory, and storage. A scalable system can efficiently adapt to work, with larger or smaller networks performing tasks of varying complexity. IBM’s latest zSeries mainframes exhibit scalability characteristics in both hardware and software, with the ability to run multiple copies of the operating system software as a single entity called a system complex of Sysplex

3.1.4. Continuing Compatibility

Some of the mainframe applications have been developed and refined over decades. Some applications were written many years ago, while others may have been written “yesterday.” The need to support applications of varying ages imposes a strict compatibility demand on mainframe hardware and software, which have been upgraded many times since the first System/360 mainframe computer was shipped in 1964. Applications must continue to work properly. Thus, much of the design work for new hardware and system software revolves around this compatibility requirement. Given a brief about the mainframes, let us look into the different aspects in detail While large mainframe computers have essentially the same hardware components as all other computers, including personal computers (PCs), the terminology is totally different. The formidable-sounding “Direct Access Storage Device” (or DASD) on a mainframe becomes the more unassuming “hard disk” on a PC. Likewise, the impressive term “data set” on a mainframe turns out to be just a “file” on a PC The computer is essentially a device that reads some data, does some computing or processing and produces information. The main computer hardware that concerns you consists of

• The CPU, or Central Processing Unit • Central Storage – also called real storage or computer memory • Input and output devices, such as disks, tapes, and printers

CPU: The central processing unit executes instructions to perform computations, initiates input/output, and directs the operation of the computer. It is the part of the computer that does the processing Central Storage: The computer memory holds both the instructions and data during computations and is termed central storage or real storage I/O Devices: The input/output contains external data

Page 45: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 45 -

3.2. Typical Mainframe Workloads Most mainframe workloads fall into either of two categories: batch processing and online transactional processing, including Web based applications

3.2.1. Batch Processing One key advantage of a mainframe is its ability to process terabytes of data from high speed storage devices and produce valuable output. For example, mainframe systems make it possible for banks and other financial institutions to produce end-of-quarter processing when such reporting is necessary to customers The applications that produce these statements are batch applications; they are processed on the mainframe without user interaction. A batch job is submitted on the computer, reads and process data in bulk, and produces output, such as customer billing statements While batch processing is possible on distributed systems, it is not as commonplace as on mainframes because distributed systems often lack:

• Sufficient data storage • Available processor capacity or cycles • Sysplex-wide management of system resources and job scheduling

Mainframe operating systems are usually equipped with sophisticated job scheduling software that allows data center staff to submit, manage, and track the execution and output of batch jobs.

CPU

Central Storage

I/O Devices

Input/Output Operations Interface

Page 46: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 46 -

Batch processes have the following characteristics:

• Large amounts of input data are processed, stored records accessed, and a large volume of output is produced.

• Interactive response time is usually not the primary requirement. However, batch jobs often must complete within a “batch window,” a period of less intensive online activity prescribed by a service level agreement.

• Information is generated about large numbers of users. • A scheduled batch process can consist of the execution of hundreds or thousands of

jobs in a pre-established sequence. During batch processing, many types of work can be generated. Consolidated information such as profitability of investment funds, scheduled database back-ups, processing of daily orders and updating of inventories are typical examples of batch processing Batch Job

3.2.2. Online Transactional Processing Mainframes serve a vast number of online transaction processing (OLTP) systems. These are mission critical applications that businesses depend on for their core functions. Some industry uses of online systems Bank – ATMs, teller systems for customer service Insurance - Agent systems for policy management and claims processing Travel and Support – Airline/railway reservation systems Manufacturing – Inventory control, production scheduling Government – Tax processing, license issuance and management

Process data to perform a specific task

Input Data Application Program Output

Page 47: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 47 -

In an online interactive system, a user working at a display station interacts with the computer. On a transaction by transaction basis, the user enters data and receives output back from the system Online (real time) transaction

3.3. A peep into the history I don’t wish to write a long history log, we will see the important milestones

3.3.1. System/360 IBM introduced System/360 on April 4 -1964. It combined micro electronic technology, which made possible operating speeds measured in billionths of a second, with significant advances in the concepts of computer organization

System/360 Model 195 Launched in 1969, the Model 195 was at the time, the most powerful computer in IBM's product line.

Access shared data on behalf of on-line user

Application Program

Page 48: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 48 -

System/360 is a single system spanning the performance range of virtually all the then IBM computers - from the widely used 1401 to nearly twice that of the most powerful computer previously built by the company. It was developed to perform information handling jobs encompassing all types of applications. System/360 includes in its central processors 19 combinations of graduated speed and memory capacity. Incorporated with these are more than 40 types of peripheral equipment which store information and enter it into and retrieve it from the computer. Built-in communications capability makes System/360 available to remote terminals, regardless of distance. The equipment is supported by programs which enable System/360 to schedule its own activities for non-stop computing that makes most efficient use of system capabilities. Internal processing power of the largest System/360 configuration is approximately 50 times greater than that of the smallest. The system's machine cycle time - basic pulse beat of a computer - ranges from one millionth-of-a-second to only 200 billionths-of-a-second. System/360 core storage memory capacity ranges from 8,000 characters of information to more than 8,000,000. Information storage devices linked to the system can store additional billions of characters of data and make them available for processing at varying speeds, depending on need. It is the balancing of these factors - all available within a single system using one set of programming instructions - that will make it possible for a user to select a configuration suited to his own requirements for both commercial and scientific computing. With the same type of input/output devices, a user can expand his System/360 to any point in its performance range, without reprogramming. Some of the most significant advances represented by the new IBM System/360 include: Solid Logic Technology - Microelectronic circuits - product of IBM's Solid Logic Technology - make up the system's basic componentry. System/360 is the first commercially available data processing system whose design is based on the use of microminiaturized computer circuits. Called logic circuits because they carry and control the electrical impulses which represent information within a computer, these tiny devices operate at speeds ranging from 300 down to six billionths-of-a-second. Transistors and diodes mounted on the circuits are only 28 thousandths-of-an-inch square and are protected by a film of glass 60 millionths-of-an-inch thick. Memory power - A hierarchy of memories within System/360 makes information in core storage available at varying speeds. Small local store memories operate in as little as 200 billionths-of-a-second. Control memories operate in as little as 250 billionths-of-a-second. Powerful main memories - containing up to 524,000 characters of information - range from 2.5 millionths-of-a-second down to one millionth-of-a-second.

Page 49: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 49 -

A key development provides 8,000,000 characters in bulk core storage - each character available in eight millionths-of-a-second and each at the direct command of a computer programmer. This is over sixty times more directly addressable characters than were previously available in IBM computers. The computer's historic limitations on memory size are overcome by this development. Application versatility - The traditional distinction between computers for commercial and scientific use is eliminated in System/360. Users will be able to process both business and scientific problems, or a combination of the two, with equal effectiveness. This versatility is reinforced by the variety of peripheral equipment which is part of the system. Communications capability - Built into System/360 is the ability to respond to inquiries and messages from remote locations at any time. Hundreds of terminal devices can communicate simultaneously with a system while the computer continues to process the basic job on which it is working. More than 100,000 businessmen in 165 American cities attended meetings at which System/360 was announced! At a press conference at the company's Poughkeepsie facilities, Mr. Watson, the then IBM Board Chairman, said: "System/360 represents a sharp departure from concepts of the past in designing and building computers. It is the product of an international effort in IBM's laboratories and plants and is the first time IBM has redesigned the basic internal architecture of its computers in a decade. The result will be more computer productivity at lower cost than ever before. This is the beginning of a new generation - not only of computers - but of their application in business, science and government."

3.3.2. System/370 In 1970, a new computer system, the IBM System/370 was announced. System/370 Models 155 and 165 could provide computer users with dramatically higher performance and information storage capacity. Please see the figure in the next page

Page 50: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 50 -

System/370 Model 165 The Model 165 of 1970 was designed to handle large data bases, remote computing and high throughput multiprogramming. This "white room" design model includes (from left) eight IBM 3420 Magnetic Tape Units and a single 3803 Tape Control, three 2821 Control Units (background), four 1403 N-1 Printers (foreground left center), two 2540 Card Read Punch Units (foreground right center), 3066 System Console (center background), 2821 Control Unit (right background), 2314 Direct Access Storage Facility (right middle) and IBM 2305 Fixed Head Storage (right foreground). To help customers exploit the full throughput potential of System/370, IBM had built in many advances keyed to reliable performance, including:

• Monolithic integrated circuits, microscopic in size, that perform logical and arithmetic operations at speeds measured in nanoseconds.

• Main core memories having capacities up to 2-million bytes for the Model 155 and 3-million for the Model 165.

• Monolithic buffer storage that holds data and instructions ready before they are actually needed, streaming them into the central processing unit on demand at nanosecond speeds. The buffer effectively matches the data from the larger but slower main memory to the very high internal speed of the processor.

• Expanded channels to carry more data faster between memory and other system units. These new channels are analogous to pipelines whose width and flow pressure have been increased.

• The ability to handle up to 15 different program tasks simultaneously, including programs written for the IBM 1400 and 7000 series, as well as System/360.

Page 51: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 51 -

This image of the Model 165 provides a close-up view of the operator's console (foreground) and the IBM 2314 Direct Access Storage facility (background) Let’s take a deviation from the history and see few of the jargons in detail so that the reading will be smooth. The central components of mainframe computer system are the processors.

CPU

MAIN STORAGE

Channel 0 Channel 1 Channel 5 Channel 6

Page 52: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 52 -

The figure shows the basic arrangement of the subcomponents that make up a typical System/370 type processor. As you can see, the processor consists of 3 main parts: CPU, Main Storage and Channels. The CPU contains the circuitry needed to execute program instructions that manipulate data stored in main storage. Although the figure doesn’t show it, most System/370 processors use a special purpose high speed memory buffer called a cache that operates between the CPU and Main Memory. This relatively small amount of storage operates at speeds even faster than the storage in main memory, so the overall speed of the processor is increased Special circuitry constantly monitors access to main memory and keeps the most frequently accessed sections in the cache.

3.3.2.1. Multiprocessing To understand what a multiprocessor does, let us focus on the term single processor. A single processor or uniprocessor contains its own main storage and is controlled by a single OS. A Multiprocessor, on the other hand, can share system resources and work. For example, while one of the processors initiates an I/O operation, another processor can handle an interrupt and so on. There are two types of multiprocessing systems

• Loosely coupled multiprocessing : where processors operate under separate operating systems, yet share access to data

• Tightly coupled multiprocessing : where processors operate under the same OS

3.3.2.2. Channels The purpose of a channel is to provide a path between the processor and an I/O device. In the above figure, there are 7 channels. As a result, there are 7 different paths along which data can pass between the processor and I/O device. Each channel can connect up to 8 devices called control units that connect to I/O devices. As a result, the processor in the above figure can connect up to 56 control units. Depending on the processor and the device, a control unit may be housed within the processor’s cabinet, the I/O device’s cabinet, or in its own cabinet. The basic channel design of the System/370 requires that I/O devices to be connected to channels using heavy copper cables that can no longer than 400 feet in length. These channels use a parallel architecture which means that the cable transmits all of the bits that make up a byte simultaneously. To do that, the cable must have a separate wire for each bit – Sixteen in all (the channel sends two bytes simultaneously) - Plus additional wires for control signals. The result is that parallel channel cable is both heavy and expensive. In 1990, IBM announced a new channel architecture, called ESCON (Enterprise System Connection), which is based on fiber optic rather than copper table. Fiber optic cable is not only 80 times lighter than copper table, but also 50 times less bulky. ESCON will allow many

Page 53: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 53 -

data centers to replace literally tons of unmanageable copper cable with neatly organized fiber optic cable. Besides its reduced size and weight, ESCON provides two other advantages. First it extends the 400-feet cable limit of standard channels to 26 miles. This lets installations locate disk devices on another floor or even in another building. Second, ESCON channels are nearly 4 times as fast as standard channels, transmitting data at 17 MB per second rather than 4.5 MB per second In the new S/390 systems, a new channel architecture – S/390 Fiber Connectivity (FICON) – provides a new high performance I/O channel, optimized for efficiency at high speed.

3.3.2.3. PR/SM At one time, multiprocessor configurations were considered exotic, and the facilities for managing them were often inadequate. So many installations resorted to VM, an OS designed to emulate multiple computer systems. VM could be configured to take advantage of multiple processors, but it didn’t provide all of the controls needed to take full advantage of modern multiprocessor configurations. To address this problem, current IBM multiprocessors include a feature called Processor Resource/Systems Manager, or PR/SM. PR/SM allows an installation to divide a multi-CPU processor into several partitions, or LPARs, each of which can function as an independent system. PR/SM can be configured so that a partition is reserved as a backup for a primary partition. If the primary partition fails, the backup partition can automatically take over the work that was being processed at the time of the failure. PR/SM also allows the I/O channels assigned to the various partitions to be reconfigured without disrupting the work

3.3.2.4. LPAR A subset of the processor hardware that is defined to support an operating system - An LPAR (Logical Partition) contains resources (processors, memory, and input/output devices) and operates as an independent system. If hardware requirements are met, multiple logical partitions can exist within a system

3.3.2.5. I/O Devices I/O devices are the devices that connect to a processor to provide it with input, receive output or provide secondary storage. The common types of I/O devices found on IBM mainframes are

3.3.2.5.1. Unit Record Devices Card Devices and Printers - The name Unit record device implies that each record processed by the device is a physical unit. URDs usually have built in control units that attach directly to channels, so separate control units are not required

Page 54: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 54 -

o Card Devices

• Card Readers • Card Punches • Reader/Punches

o Printers • Impact : produce out put by striking an image of characters to be

printed against a ribbon, which in turn transfers ink to paper • Non Impact Printers: use laser technology. IBM’s 3800 printing

subsystem can print at rates of up to remarkable 20,000 lines per minute

3.3.2.5.2. Magnetic Tape Devices How much data a reel or cartridge of tape can contain depends on the length of the tape and the density used to record the data. Density is a measurement of how many bytes are recorded in one inch of tape. Tape densities for standard reel tapes are usually 1600 or 6250 bpi. Data records are normally written to tape in groups called blocks. Empty spaces called gaps are required to separate blocks from one another. The larger the block, the lesser the amount of wasted space on a tape. However there is an extra cost involved when blocking is used: a buffer is required in main storage to contain the entire block. As a result, the larger the block, the more main storage that is required to contain it

3.3.2.5.3. Direct Access Device

The official IBM term for a disk drive is DASD, because it allows direct and rapid access to large quantities of data. Data is recorded on the usable surfaces of a disk pack in concentric circles called tracks. The number of tracks per surface varies with each device type. The component that reads and writes data on the tracks of a disk pack is called the actuator. The actuator has one read/write head for each recording surface. When the actuator moves, all of its heads move together so they are all positioned at the same track of each recording surface. As a result the disk drive can access data on all of those tracks without moving the actuator. The tracks that are positioned under the heads of the actuator at one time make up a cylinder. As a result, there are as many tracks in a cylinder as there are usable surfaces on the pack, and there are as many cylinders in a pack as there are tracks on a surface. So a pack that has 19 surfaces, each with 808 tracks has 808 cylinders, each with 19 tracks. IBM manufactures two basic types of disk drives Count-Key-Data (CKD) devices and Fixed-Block-Architecture (FBA) devices. CKD devices store data in variable-length blocks. FBA devices store data in fixed-length blocks Each type of DASD devices requires two kinds of control units to attach it to a processor channel. The first is called a string controller, attaches a group of DASDs of the same type: the resulting group is called a string. The second kind of control unit, called a storage control, connects up to eight strings of DASD units to a channel

Page 55: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 55 -

Special circuitry keeps track of what disk data is accessed most frequently and tries to keep this data in the cache storage. Then, when that data is referenced, it can be read directly from cache, the DASD unit doesn’t have to be accessed at all

3.3.2.6. Data Communications Equipment An installation creates a data communications network (telecommunications network) that lets users at local terminal (terminals at the computer site) and remote terminals (terminals that are not at the computer site) access a computer system At the center of the network is the host system, a System/370 processor. The control unit that attaches to the host system’s channels is called a communications controller; it manages the communications functions necessary to connect remote terminal system via modems and telecommunications lines. Whether attached locally or remotely, the most commonly used terminal system on IBM mainframe is the 3270 Information Display system See the figure in the next page

String Controller String Controller

STORAGE CONTROL

Page 56: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 56 -

3.3.2.7. Characteristic Features of Mainframe OS We will see in detail about the mainframe OS; I give a brief here to make the understanding easier

3.3.2.7.1. Virtual Storage In most computer systems, the processor’s main storage is among the most valuable of the system’s resources. As a result, modern mainframe computer operating systems provide sophisticated services to make the best use of the available main storage. Among the most important of these services include virtual storage Virtual storage is a technique that lets a processor simulate an amount of main storage that is larger than the actual amount of real storage. To do this, the computer uses disk storage as an extension of real storage

Communication Controller

Modem Modem

Modem Modem

Telecommunication Lines

Terminal Controller

Terminal Controller

Printer Printer

T 1

T 2

T 3

T 1

T 2

T 3

Terminals Terminals

Channel Connections

Page 57: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 57 -

The key to understanding virtual storage is to realize that at any given moment, only the current program instruction and the data it refers need to be in real storage. Other data and instructions can be placed temporarily on disk storage, and recalled into main storage when needed. In other words, virtual storage Operating Systems transfer data and instructions between real storage and disk storage as and when they are needed.

3.3.2.7.2. Multiprogramming Multiprogramming means that the computer lets more than one program execute at the same time. Actually, that is misleading; at any given moment, only one program can have control of the CPU. A multiprogramming system appears to execute more than one program at the same time The key to understanding multiprogramming is to realize that some processing operations – like reading data from an input device – take much longer than others. As a result, most programs that run on mainframe computers are idle for a large percentage of the time, waiting for I/O operations to complete. If programs were run one at a time on a mainframe computer, the CPU would spend most of its time waiting. Multiprogramming simply reclaims the CPU during these idle periods and lets another program execute

3.3.2.7.3. Spooling A significant problem that must be overcome by multiprogramming systems is sharing access to input and output devices for the programs that execute together. One way to avoid this problem is to give one of the programs complete control of the printer. Unfortunately, that defeats the purpose of multiprogramming because the other program has to wait until the printer is available To provide shared access to printer devices, spooling (simultaneous peripheral operation online) is used. Spooling manages printer output for applications by intercepting printer output and directing it to a disk device instead. Then, when the program finishes, the operating system collects its spooled print output and directs it to the printer. In a multiprogramming environment, the OS stores the spooled output separately on disk so it can print each program’s output separately Another benefit of spooling is that programs can execute faster. That is because; disk devices are much faster than printers. The OS component that actually prints the spooled output is multi programmed along with the application programs, so the printer is kept as busy as possible. But the application programs themselves are not slowed down by the relatively slow operation of the printer

3.3.2.7.4. Batch Processing When you use batch processing, your work is processed in units called jobs. A job may cause one or more programs to execute in sequence. For example, one job may invoke the

Page 58: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 58 -

programs necessary to update a file of employee records, print a report listing employee information, and produce payroll checks. One of the problems that arise when batch processing is used is managing how work flows through the system. In a typical mainframe computer system, many users compete to use the system’s resources. To manage this, the Job Entry Subsystem, or JES processes each user’s job in an orderly fashion

3.3.2.7.5. Time Sharing In a time sharing system, each user has access to the system through a terminal device. Instead of submitting jobs that are scheduled for later execution, the user enters commands that are processed immediately. As a result, time sharing is sometimes called interactive processing, because it lets users interact directly with the computer. Sometimes, timesharing processing is also called foreground processing, while batch job processing is called background processing

Page 59: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 59 -

3.3.2.8. A small mainframe configuration

4381 Processor

Operator Consoles (4)

Communications Controller

Remote 3270 System

Impact Printers (2) 3490 Tape Drives (4)

3880 Storage Controller

Local 3270 System

3390 –1 Disk Drives (24)

Page 60: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 60 -

For Direct access storage, the configuration above uses three strings of 3390 model - 1 DASDs, each containing 8 drives. Since each 3390 model 1 has a capacity of 946 MB, the total DASD capacity of this system is about 22 billion bytes. 3390 are fixed-media DASDs; their disk packs can’t be removed. To provide a way to create backup copies of data on the 3390s, a string of four tape drives is used The 4 operator consoles let system operators control the operation of the system. Some of the consoles might be dedicated to specific tasks, such as managing the tape drives or controlling the 2 high speed impact printers. A local 3270 system, directly attached to the 4381 processor, provide 12 terminals and one printer. These terminals are used by the programming staffs, who are based in the same building that houses the computer. The 3725 communications controller allows remote 3270 systems to access the system via telephone lines.

3.3.2.9. MVS Concepts MVS stands for multiple virtual storage. Under MVS, the concepts of virtual storage and multiprogramming are closely related. Virtual Storage is a facility that simulates a large amount of main storage by treating DASD storage as an extension or real storage. In other words when virtual storage is used, the processor appears to have more storage than it actually does. Multiprogramming is a facility that lets two or more programs use the processor at the same time. The key to understanding multiprogramming is realizing that most programs spend most of their time waiting for I/O operations to complete. So while one program waits for an I/O operation, the CPU can execute instructions for another program.

3.3.2.9.1. Address Space Main storage consists of millions of individual storage locations, each of which can store one character, or byte, of information. To refer to a particular location, you use an address that indicates the storage location’s offset from the beginning of the memory. An Address space is simply the complete range of addresses – and as a result, the number of storage locations – that can be accessed by the computer. The maximum size of a computer’s address space is limited by the number of digits that can be used to represent an address. To illustrate, suppose a computer records its addresses using six decimal digits, such a computer could access storage with addresses from 0 to 999,999 The original System/370 processors used 24 bit binary numbers to represent addresses. Since the largest number that can be represented in 24 bits is abut 16 million (16 M), an address

Page 61: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 61 -

space on a System/370 can’t contain more than 16M bytes of storage. Because this 16 MB address space limitation severely restricted the capabilities of the System/370, IBM replaced it in the early 1980s with a new architecture known as 370-XA. 370-XA processors can operate in 370 mode using standard 24 bit addresses or in XA, or Extended Architecture, mode using 31-bit addresses, in XA mode, the largest address that can be represented – and therefore the largest address space that can be used – is about 2G. In the late 1980s and early 1990s, IBM extended this architecture even further with the introduction first of ESA/370, then ESA/390. These designs utilize the same 31 – bit addresses that 370-XA uses. MVS/370 was designed to operate on System/370 processors that utilize 24-bit addresses, and MVS/XA was designed to operate on 370-XA processors that use 31 – bit addresses. MVS/ESA also uses 31-bit addresses, but runs only on ESA/370 and ESA/390 processors. To maintain compatibility with MVS/370, MVS/XA recognizes 24-bit processing. Whether it interprets an address as 24 or 31 bit depends upon the setting of the addressing mode bit in the current PSW at the time an instruction executes. Programs running in 24-bit addressing mode can access the first 16 MB of the virtual storage. MVS allows program to switch from one mode to another during execution in order to access data or call modules running in the other mode. Thus new programs can take advantage of 31 bit addressing and still be compatible with ones written for 24 bit addresses. All MVS programs have an addressing mode (AMODE) attribute that indicates which addressing mode is to take effect when a module is given control. The AMODE attribute is assigned to MVS program module by the programmer as input to the assembler or linkage-editor. The default is 24 bit addressing mode. MVS modules have a residence mode (RMODE) attribute that indicates whether they must be loaded below the 16 MB address line or can be loaded anywhere in the virtual storage. If RMODE = 24, modules require residency below 16 MB. If RMODE = ANY, it allows the OS to load a module anywhere in virtual storage A program that must be directly addressable by 24 bit callers must reside below the 16 MB line. A program that doesn’t have 24 bit callers, or whose 24 bit callers call it indirectly, can reside anywhere. The RMODE attribute is assigned as input to the assembler or the linkage-editor, or by default. The default is 24 bit residence mode.

3.3.2.9.2. Paging To allow the parts of a program in virtual storage to move between real and auxiliary storage, MVS breaks real storage, virtual storage and auxiliary storage into blocks. The terminology the system uses is as follows

• A block of real storage is a Frame • A block of virtual storage is a Page • A block of auxiliary storage is a Slot

Page 62: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 62 -

A page, a frame and a slot are all of the same size; each consists of 4KB. An active virtual storage page resides in a real storage frame; a virtual storage page that becomes inactive resides in an auxiliary storage slot. MVS divides virtual storage into 4K sections called pages. Data is transferred between real and DASD storage one page at a time. As a result, real storage is divided into 4K sections called page frames, each of which can hold one page of virtual storage. Similarly, the DASD area used for virtual storage, called a page data set, is divided into 4K page slots, each of which holds one page of virtual storage. When a program refers to a storage location that is not in real storage, a page fault occurs. When that happens, MVS locates the page that contains the needed data on DASD and transfers it into real storage. That operation is called a page-in. In some cases, the new page can overlay data in a real storage page frame. In other cases, data in a page frame has to be moved to a page data set to make room for the new page. That is called a page-out. Either way, the process of bringing a new page into real storage is called paging.

3.3.2.9.3. Expanded Storage Most new System/370 processors include a special type of memory known as expanded storage. Expanded storage improves the efficiency of virtual storage operations by acting as a large buffer between real storage and the page data sets. Simply put, when a virtual storage page must be paged out, the processor moves the page’s contents to expanded storage. This transfer occurs at CPU speeds rather than at DASD speeds, so the operation is almost instantaneous. Pages are written to the actual page data set only when expanded storage becomes full. The amount of expanded storage on a processor varies depending on the processor model.

3.3.2.9.4. Swapping Swapping is the process of transferring all of the most recently valid pages of an address space between real storage and auxiliary storage. This has the effect of moving an entire address space into or out of real storage. It is one of several methods MVS employs to balance the system workload as well as to ensure that an adequate supply of available real storage frames is maintained. Address spaces that are swapped in are active having pages in real storage frames and pages in auxiliary storage slots. Address spaces that are swapped out are inactive; the address space resides on auxiliary storage and can’t execute until it is swapped in. Swapping is performed in response to the recommendations from the System Resource Manager (SRM). See the figure in the next page

Page 63: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 63 -

You can think of swapping as the same thing as paging, only at a higher level. Rather than move small 4K pieces of virtual storage in an out of real storage, swapping effectively moves entire address spaces in and out of virtual storage. Since paging occurs only for address spaces that are currently in virtual storage, paging doesn’t occur for address spaces that are swapped out

3.3.2.10. The MVS system

3.3.2.10.1. System Generation When an installation purchases the MVS operating system, IBM sends the basic components that make up the MVS on a series of tapes, called distribution libraries. System generation, only a part of the overall process of installing MVS from the distribution libraries, selects and assembles the various components an installation needs to create a working MVS system. To control system generation, often called sysgen, a systems programmer codes special macro instructions that specify how the MVS components from the distribution libraries should be put together. Interestingly, an installation must already have a working MVS system before it can generate a new one. This is because an existing MVS system is required to execute the sysgen macro instructions. Fortunately, most installations perform sysgen to upgrade to a newer version of MVS or to make changes to their current version. So they can use their current version of MVS to execute the sysgen

Page Data Sets

Swap Data Sets

Real Storage

CPU

Add: Space 1 (Swapped in)

Add: Space 2 (Swapped in)

Add: Space 3 (Swapped in)

Add: Space 4 (Swapped out)

Add: Space 5 (Swapped out)

Add: Space 6 (Swapped out)

Page 64: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 64 -

For installations that do not already have an MVS system, the system installation process includes setting up a small, limited function MVS system that can execute the sysgen for the complete, full function MVS system The macro instructions a systems programmer codes for a sysgen fall generally into two categories. The first category of macro instructions defines the system’s hardware configuration... They are needed because MVS must know about every I/O device that is attached to the system. As a result, whenever a new I/O device is installed, the system must be generated again. MVS lets you do a smaller, less time consuming type of sysgen called an iogen to change the I/O device configuration. The second category of macro instructions in a sysgen indicates which options of the OS should be included. Like which Job Entry Subsystem, what optional access methods and so on The output from sysgen is a series of system libraries that contain, among other things, the executable code that makes up the OS

3.3.2.10.2. System Initialization Once an MVS OS has been generated, it can be used to control the operation of the computer system. To begin a system initialization, the system operator uses the system console to start an Initial Program Load or IPL. That causes the computer system to clear its real storage and begin the process of loading MVS into storage from the system libraries. Sounds cool now? If so, you might not have read the following lines or you might have already knew it “370-XA processors can operate in 370 mode using standard 24 bit addresses or in XA, or Extended Architecture, mode using 31-bit addresses, in XA mode, the largest address that can be represented – and therefore the largest address space that can be used – is about 2G” Still confused? Didn’t you read 31 bit?! Didn’t you think why 31 and not 32? We have an answer for that

3.3.2.11. XA and 31 bit addressing The IT landscape of the early 1980s was dominated by the mainframe computer, and the mainframe marketplace was dominated by IBM, though less so than it is today. In those days there were various other manufacturers selling proprietary and mostly long forgotten systems such as Burroughs and ICL. IBM's flagship was the 370 architecture line, itself a development of IBM's earlier 360 line. Some of the largest physical boxes that IBM ever produced, big 370 systems like the 3033 and 3081 mostly ran IBM's proprietary operating

Page 65: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 65 -

system MVS/SP V1.3. The most serious limitation of this operating system, and the 370 architecture on which it ran, was that it used a 24 bit addressing scheme. Although every unit of work, known as an address space in MVS, had access to it's own virtual storage area of 16 MB (well 16 MB in theory, but after the operating system reserved areas for it's own use, in practice you were lucky to get 9 MB for your own use), this had become a severe limitation for large sites, much as the 640 KB limit in the PC operating system DOS became a limitation. The 370 architecture always used 4 byte, or 32 bit, words to store virtual memory addresses, but only the last 3 bytes or 24 bits actually represented an address, the other 8 bits were essentially available to the programmer to do as they pleased. Many programs used these bits for passing flags, which caused problems later. The 370/XA (XA stands for eXtended Architecture, why it was never just called EA is one of those nomenclature mysteries with which IBM is riddled) altered this 24 bit scheme to use the entire word for addressing, and so 31 bit addressing was born, bringing access to a 2 GB address space. But why 31 bit and not 32 bit? Well this is because of those flags often stored in the first 8 bits, in order to save their customers from the problems of rewriting huge volumes of 24 bit code, IBM ensured that XA could run it without modification. This was achieved by setting the top bit as the 24 or 31 bit mode bit. If the bit was set, the address took up the following 31 bits, if it was zero then the next 7 bits were ignored and only the last 24 bits represented the address. You should feel comfortable now! Let’s go ahead with our discussion on mainframe history

3.3.3. System/390 IBM announced System/390 on September 5, 1990. In addition to a new, enriched family of Enterprise Systems Architecture/390 operating systems, a new connection architecture and many functional enhancements, System/390 introduced the IBM Enterprise System/9000 family of 18 new processors - including the most powerful the company has ever offered. The new ESA/390 architecture and new MVS/ESA, VM/ESA and VSE/ESA operating systems, along with new technologies, facilitate the function and computing power of System/390.

Page 66: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 66 -

The System/390 line of servers was the IBM flagship mainframe family in the 1990s. Among the functional highlights are:

• Enterprise System Connection (ESCON) architecture that implements high speed fiber optic channels, allows customers to locate traditional "computer room" equipment anywhere within a 9-kilometer (5.6 miles) radius, and facilitates any-to-any connectivity

• System management and system availability enhancements that reduce planned and unplanned outages, allow reconfiguration of channels and input/output equipment without impacting the system, and provide functions that help customers move closer to the goal of 24 hours/7 days a week operation;

• Enhanced enterprise-wide security functions, with integrated cryptography at central processor speeds, that are especially suited to high-speed, high-volume transmission of sensitive information such as financial transactions;

• Very high performance supercomputing vector options for the most powerful ES/9000 models, as well as new cost-effective vector facilities on intermediate processors, making advanced scientific and technical applications affordable to many customers for the first time;

• Software enhancements that speed application development, better manage distributed data, and help move applications from one system or network to another;

• New client/server hardware and software products designed to simplify the management and coordination of an enterprise's local area network environment;

• On-line transaction processing capabilities that can improve applications linking thousands of remote terminals and huge databases, such as those in airline reservation and banking systems, and

• A unique external time reference system that connects and synchronizes separate IBM processors in a multi-system complex (sysplex) and allows customers to operate them as one system.

Page 67: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 67 -

System/390 Parallel Enterprise Server The S/390 Parallel Enterprise Servers were microprocessor-based mainframes designed for any business application. From traditional accounts payable to advanced video serving applications, the air-cooled CMOS processors introduced in 1994 extended the scalability of earlier S/390 parallel processors to meet the needs of a wide range of customers.

3.3.4. eServer zSeries 900 IBM unveiled the IBM eServer zSeries 900 on Oct 3, 2000, the first mainframe built from scratch with e-business as its primary function. It is built to handle the unpredictable demands of e-business, allowing thousands of servers to operate within one box. Along with the new design, IBM also introduced its new 64-bit operating system, z/OS The z900 and z/OS were the result of a $1 billion, two-year effort to specifically address the needs of businesses in the age of e-commerce. The first in a new class of e-business servers, the system, which works hand-in-hand with z/OS - the z900's flagship operating system - is designed for high speed connectivity to the network and to storage systems, scalability in the face of unpredictable spikes in workload or traffic, and near zero downtime when clustered. The z900 will allow customers to push performance and connectivity to the outer limits without any concessions to reliability and security. This was the comment made by Dan Colby, general manager, Enterprise Servers, IBM, while the server was introduced "The z900 knows what you need before you do”!

Page 68: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 68 -

eServer zSeries 900 The only server capable of dynamically shifting workloads in the server and the network according to priorities set by the customer, the z900 addressed one of the greatest e-business challenges facing companies - efficiently and robustly managing unpredictable resource requirements. Functioning like thousands of servers within the server, resources shift automatically to the applications that need them. On most servers these adjustments must be made manually or are limited to a single logical or even physical partition. In addition, the z900 has self-healing capabilities. It continuously monitors itself and can automatically detect and correct errors, allowing applications to run without interruption. The zSeries 900 was the first IBM mainframe built from scratch with e-business as its primary function The ability to run thousands of virtual servers within one physical box made the z900 the ideal platform for e-business-intensive operations like application service providers, Internet service providers and technology hosting companies. The heart of the z900 is the IBM multichip module (MCM) - the densest, most advanced semiconductor and packaging technology in the world. The 5" x 5" x 1/4" module contains 35 chips mounted on 101 layers of ceramic glass connected to 4,226 I/0 pins by 1 kilometer of wire. The module uses IBM's leading-edge copper technology and contains 2.5 billion transistors. Designed and manufactured by IBM's world-class chip developers, this leading-edge technology provided significant advantages in performance, power consumption and reliability. The z900 reached unprecedented levels in capacity and security, including:

• Greater than 2,500 MIPs (Million Instructions Per second) on 16 processors. Clustered, the z900 can handle up to 9 billion transactions/day (300 million transactions/day stand alone).

• 24GB/second of 110 bandwidth. The bandwidth has been tripled to accommodate applications that require huge I/O bandwidth to process the large number of transactions and inquiries driven by the Internet.

Page 69: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 69 -

• FICON enhancements - offers native FICON attachment to Magstar tape storage that enhances performance, distance and sharing capabilities for networked storage. It also features FICON directors for Magstar tape and the IBM Enterprise Storage Server.

• Enhanced Capacity on Demand capabilities - scales effortlessly from 1-way to 16-way processor capability on the fly and without disruption.

• 2,000 Secure Sockets Layer (SSL) transactions/second - the best Sun claims is 125 SSL/second. SSL transactions - those that cause the "locked" padlock icon to appear at the bottom of browsers - are crucial to e-business transactions, enabling companies to securely process orders on-line. The ability to process greater numbers of SSL transactions means businesses can serve more customers and make more sales in less time.

• New HiperSocket technology - provides high speed TCP/IP connectivity between virtual servers within a single z900, creating a network in a box.

3.3.5. eServer zSeries 990 On May 13, 2003, IBM introduced eServer zSeries 990, the new flagship of the eServer family, built on the breakthrough technology of the eServer z900, which rewrote the rules for enterprise-class computing with fortress-like security, rock-solid reliability, and extreme performance in Linux virtualization and automation The new z990 was the result of a four-year, more than $1 billion investment in the zSeries platform involving 1,200 IBM developers The z990 sets a new standard for enterprise-class computing and will feature industry leadership in:

• Virtualization - the z990 architecture can support hundreds or even thousands of virtual Linux servers in a single box. That roughly equates to an entire data center on one server the size of a refrigerator.

• Automation - the z990 features IBM's exclusive Intelligent Resource Director (IRD) technology, which dynamically moves system resources to the workloads that need them, according to priorities and objectives set by the customer.

• Scalability - a single z990 offers massive capacity and the ability to scale up and out. It can scale up to process 450 million e-business transactions/day or scale out to manage hundreds of virtual Linux servers. A clustered z990 can handle up to 13 billion transactions/day, exceeding the average weekly volume on the New York Stock Exchange. The z990 also offers the ability to turn capacity on and off, allowing customers to temporarily add server engines during peak periods.

• Security - designed from the ground up to help thwart intrusion into the system, the IBM mainframe is one of the most secure servers on the market. A 16-way z990 can securely process up to 11,000 transactions/second.

• Reliability -- mainframe reliability is measured in decades, not weeks or days, and the hardware availability rate for a clustered zSeries is up to 99.999%, or less than five minutes of downtime per year.

Page 70: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 70 -

The z990 is the most powerful and scalable IBM mainframe in the 40-year history of the product, with twice the virtualization capabilities and the ability to do nearly three times the work of the z900, a new "building block" design that allows customers to plug in new capacity without taking the system down, and a dramatically simplified product structure that reduces the number of mainframe models from 42 to 4.

eServer zSeries 990 The z990 will provide new levels of scalability, security and connectivity:

• For the first time, with On/Off Capacity on Demand, mainframe customers can power up available additional engines on demand, when they need them, and turn them off when they don't, offering the ultimate flexibility to help respond to daily or seasonal surges in demand.

• The z990 features up to 9,000 MIPS (million instructions per second) on 32 processors - twice the number of processors and almost three times the system capacity of the z900 - and allows customers the ability to scale up from 1- to 32-way, without taking the system down.

• Up to 30 logical partitions (LPARs) are supported on the z990, providing twice the LPAR capability of the z900. Running the latest version of z/VM, release 4.4, customers can quickly create and effectively manage hundreds of virtual Linux servers within one physical box. IBM's advanced virtualization technologies make the z990 an ideal consolidation platform for customers seeking to reduce the cost and management expense of server farms.

• Topping its own security record, the new 16-way z990 can handle up to 11,000 Secure Sockets Layer (SSL) transactions/second (a 57% improvement over a 16-way z900). SSL handshakes -- those that cause the "locked" padlock icon to appear at the bottom of browsers -- are crucial to e-business transactions, enabling companies to more securely process orders on-line. The ability to process greater numbers of SSL transactions helps businesses serve more customers and make more sales in less time.

• For customers seeking additional connectivity for new e-business workloads on the mainframe, the new z990 provides up to 512 I/O channels, double the number of its

Page 71: An Introduction to Mainframes

More about Mainframes

An Introduction to Mainframes - 71 -

predecessor. In addition, there are now up to 16 HiperSockets, which provide high speed TCP/IP connectivity between virtual servers within a single z990, quadruple the number in the z900. IBM has also introduced a new technology called logical channel subsystems, which can make it easier for customers to consolidate multiple mainframes into a larger z990.

• The z990 has available up to four times the memory of the z900, 256GB versus 64GB.

Page 72: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 72 -

Chapter 4

z/Architecture and z/OS

Page 73: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 73 -

4. z/Architecture and z/OS

4.1. Logical Structure of a z/Architecture system with 2 CPUs

Logically, a system consists of main storage, one or more central processing units (CPUs), operator facilities, a channel subsystem, and I/O devices. I/O devices are attached to the channel subsystem through control units. The connection between the channel subsystem and a control unit is called a channel path

4.1.1. Main Storage Main storage, which is directly addressable, provides for high speed processing of data by the CPUs and the channel subsystem. Both the data and programs must be loaded into main storage from input devices before they can be processed. The amount of main storage available in the system depends on the model, and, depending on the model, the amount in the configuration may be under control of model-dependent configuration controls. The storage is available in multiples of 4K byte blocks. At any instant, the channel subsystem and

CPU

CPU

Crypto

Main Storage

Expanded Storage

Channel Subsystem

ETR

Page 74: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 74 -

all the CPUs in the configuration have access to the same blocks of storage and refer to a particular block of main storage locations by using the same absolute address Main storage may include a faster access buffer storage, sometimes called a cache. Each CPU may have an associated cache.

4.1.2. Expanded Storage Expanded storage may be available on some models. Expanded storage, when available, can be accessed by all CPUs in the configuration by means of instructions that transfer 4K byte blocks of data from expanded storage to main storage or from main storage to expanded storage. These instruction are called PAGE IN and PAGE OUT instructions I don’t detail about these instructions… that is beyond the scope of this book Each 4K byte block of expanded storage is addressed by means of a 32 bit unsigned binary integer called an expanded-storage block number

4.1.3. CPU The Central Processing Unit (CPU) is the controlling center of the system. It contains the sequencing and processing facilities for instruction execution, interruption action, timing functions, initial program loading, and other machine related functions The CPU, in executing instructions, can process binary integers and floating point numbers (binary and hexadecimal) of fixed length, decimal integers of variable length, and logical information of either fixed or variable length. Processing may be in parallel or in series Instructions which the CPU executes fall into seven classes: general, decimal, floating-point-support (FPS), binary-floating-point (BFP), hexadecimal-floating-point (HFP), control, and I/O instructions. The general instructions are used in performing binary-integer-arithmetic operations and logical, branching, and other non-arithmetic operations. The decimal instructions operate on data in the decimal format. The BFP and HFP instructions operate on data in the BFP and HFP formats, respectively, while the FPS instructions operate on floating-point data independent of the format or convert it from one format to the other. The privileged control instructions and the I/O instructions can be executed only when the CPU is in the supervisor state; the semi privileged control instructions can be executed in the problem state, subject to the appropriate authorization mechanisms. The CPU provides registers which are available to programs but do not have addressable representations in main storage. They include

4.1.3.1. PSW The program-status word (PSW) includes the instruction address, condition code, and other information used to control instruction sequencing and to determine the state of the CPU. The

Page 75: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 75 -

active or controlling PSW is called the current PSW. It governs the program currently being executed. The CPU has an interruption capability, which permits the CPU to switch rapidly to another program in response to exceptional conditions and external stimuli. When an interruption occurs, the CPU places the current PSW in an assigned storage location, called the old-PSW location, for the particular class of interruption. The CPU fetches a new PSW from a second assigned storage location. This new PSW determines the next program to be executed. When it has finished processing the interruption, the program handling the interruption may reload the old PSW, making it again the current PSW, so that the interrupted program can continue

4.1.3.2. General Registers Instructions may designate information in one or more of 16 general registers. The general registers may be used as base-address registers and index registers in address arithmetic and as accumulators in general arithmetic and logical operations. Each register contains 64 bit positions For some operations, either bits 32-63 or bits 0-63 of two adjacent general registers are coupled, providing a 64-bit or 128-bit format, respectively. In these operations, the program must designate an even-numbered register, which contains the leftmost (high-order) 32 or 64 bits. The next higher-numbered register contains the rightmost (low-order) 32 or 64 bits.

4.1.3.3. Floating Point Registers All floating-point instructions (FPS, BFP, and HFP) use the same floating-point registers. The CPU has 16 floating-point registers. Each floating-point register is 64 bits long and can contain either a short (32-bit) or a long (64-bit) floating-point operand; pairs of floating-point registers can be used for extended (128-bit) operands. Each of the eight pairs is referred to by the number of the lower-numbered register of the pair.

4.1.3.4. Floating Point Control Register Floating Point Control (FPC) register is a 32 bit register that contains mask bits, flag bits, a data exception code, and rounding-mode bits

4.1.3.5. Control Registers The CPU has 16 control registers, each having 64 bit positions. The bit positions in the registers are assigned to particular facilities in the system, such as program-event recording, and are used either to specify that an operation can take place or to furnish special information required by the facility

4.1.3.6. Access Registers The CPU has 16 access registers numbered 0-15. An access register consists of 32 bit positions containing an indirect specification of an address-space-control element. An

Page 76: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 76 -

address-space-control element is a parameter used by the dynamic address translation (DAT, we will see this later) mechanism to translate references to a corresponding address space.

4.1.4. Cryptographic Facility Depending on the model, an integrated cryptographic facility may be provided as an extension of the CPU. When the cryptographic facility is provided on a CPU, it functions as an integral part of that CPU. The integrated cryptographic facility provides a number of instructions to protect data privacy, to support message authentication and personal identification, and to facilitate key management. The high-performance cipher capability of the facility is designed for financial transaction and bulk-encryption environments, and it complies with the Data Encryption Standard (DES).

4.1.5. External Time Reference Depending on the model an External Time Reference (ETR) may be connected to the configuration. The ETR facility provides a means to initiate and maintain the synchronization of TOD (Time of Day) clocks to an external time reference

4.1.6. I/O Input/output (I/O) operations involve the transfer of information between main storage and an I/O device. I/O devices and their control units attach to the channel subsystem, which controls this data transfer.

4.1.7. Channel Subsystem The channel subsystem directs the flow of information between I/O devices and main storage. It relieves CPUs of the task of communicating directly with I/O devices and permits data processing to proceed concurrently with I/O processing. A channel path employs either a parallel-transmission protocol or a serial-transmission protocol and, accordingly, is called either a parallel or a serial channel path. A serial channel path may connect to a control unit through a dynamic switch that is capable of providing different internal connections between the ports of the switch. The channel subsystem uses one or more channel paths as the communication link in managing the flow of information to or from I/O devices. As part of I/O processing, the channel subsystem also performs the path-management function of testing for channel-path availability, selecting an available channel path, and initiating execution of the operation with the I/O device

Page 77: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 77 -

One subchannel is provided for and dedicated to each I/O device accessible to the channel subsystem. Each subchannel contains storage for information concerning the associated I/O device and its attachment to the channel subsystem. The subchannel also provides storage for information concerning I/O operations and other functions involving the associated I/O device. Information contained in the subchannel can be accessed by CPUs using I/O instructions as well as by the channel subsystem and serves as the means of communication between any CPU and the channel subsystem concerning the associated I/O device. The actual number of subchannels provided depends on the model and the configuration.

4.1.8. Channel Paths I/O devices are attached through control units to the channel subsystem via channel paths. Control units may be attached to the channel subsystem via more than one channel path, and an I/O device may be attached to more than one control unit. In all, an individual I/O device may be accessible to a channel subsystem by as many as eight different channel paths, depending on the model and the configuration.

4.1.9. I/O Devices and Control Units I/O devices include such equipment as printers, magnetic-tape units, direct-access-storage devices, displays, keyboards, communications controllers, teleprocessing devices, and sensor based equipment. Many I/O devices function with an external medium, such as paper or magnetic tape. Other I/O devices handle only electrical signals, such as those found in displays and communications networks. In all cases, I/O-device operation is regulated by a control unit that provides the logical and buffering capabilities necessary to operate the associated I/O device. From the programming point of view, most control-unit functions merge with I/O-device functions. The control-unit function may be housed with the I/O device or in the CPU, or a separate control unit may be used.

4.1.10. Operator Facilities The operator facilities provide the functions necessary for operator control of the machine. Associated with the operator facilities may be an operator-console device, which may also be used as an I/O device for communicating with the program. The main functions provided by the operator facilities include resetting, clearing, initial program loading, start, stop, alter, and display.

4.2. Operating System In simplest terms, an operating system is a collection of programs that manage the internal workings of a computer system. Operating systems are designed to make the best use of the computer’s various resources, and ensure that the maximum amount of work is processed as efficiently as possible. Although an operating system cannot increase the speed of a

Page 78: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 78 -

computer, it can maximize its use, thereby making the computer seem faster by allowing it to do more work in a given period of time.

4.3. z/OS In most early operating systems, requests for work entered the system one at a time. The operating system processed each request or job as a unit, and did not start the next job until the one ahead of it had completed. This arrangement worked well when a job could execute continuously from start to completion. But often a job had to wait for information to be read in from, or written out to a device such as a tape drive or a printer. Input and output (I/O) take a long time compared to the electronic speed of the processor. When a job waited for I/O, the processor was idle. Finding a way to keep the processor working while a job waited would increase the total amount of work the processor could do without requiring additional hardware. z/OS gets work done by dividing it into pieces and giving portions of the job to various system components and subsystems that function interdependently. At any point in time, one component or another gets control of the processor, and makes its contribution, and then passes control along to a user program or another component

4.3.1. Hardware resources used by z/OS The z/OS operating system executes in a processor and resides in processor storage during execution. z/OS is commonly referred to as the system software. Mainframe hardware consists of processors and a multitude of peripheral devices such as disk drives (called direct access storage devices or DASD), magnetic tape drives, and various types of user consoles. Tape and DASD are used for system functions and by user programs executed by z/OS.

The figure shows a simplified view of mainframe concepts

Page 79: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 79 -

• Software - The z/OS operating system consists of load modules or executable code.

During the install process, the system programmer copies these load modules to load libraries residing on DASD volumes.

• Hardware - The system hardware consists of all the devices, controllers, and processors that constitute a mainframe environment

• Peripheral devices - These include tape drives, DASD devices, and consoles etc. • Processor Storage - Often called real or central storage (or memory), this is where the

z/OS operating system executes. Also, all user programs share the use of processor storage with the operating system.

z/OS is made up of programming instructions that control the operation of the computer system. These instructions ensure that the computer hardware is being used efficiently and allow application programs to run. z/OS includes sets of instructions that, for example, accept work, convert work to a form that the computer can recognize, keep track of work, allocate resources for work, execute work, monitor work, and handle output.

4.3.2. Multiprogramming and Multiprocessing z/OS is capable of multiprogramming, or executing many programs concurrently, on behalf of many users at once. In multiprogramming, when a job cannot use the processor, the system can suspend, or interrupt, the job, freeing the processor to work on another job z/OS makes multiprogramming possible by capturing and saving all the relevant information about the interrupted program before allowing another program to execute. When the interrupted program is ready to begin executing again, it can resume execution just where it left off. Multiprogramming allows z/OS to run hundreds of programs simultaneously for users who might be working on different projects at different physical locations around the world. z/OS can also perform multiprocessing, which is the simultaneous operation of two or more processors that share the various hardware resources, such as memory and external disk storage devices. Many users running many separate programs means that, along with large amounts of complex hardware, z/OS users need large amounts of memory to ensure suitable system performance

4.3.3. Control Blocks As instructions execute the work of a computer system, they keep track of this work in storage areas known as control blocks. Generally speaking, there are three types of z/OS control blocks:

• System-related control blocks • Resource-related control blocks • Task-related control blocks

Page 80: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 80 -

Each system-related control block represents one z/OS system and contains system-wide information, such as how many processors are in use. Each resource-related control block represents one resource, such as a processor or storage device. Each task-related control block represents one unit of work.

4.3.4. Physical Storage used by z/OS Conceptually, mainframes and all other computers have two types of physical storage.

• The physical storage located with the mainframe processor itself. This is called processor storage or real storage; think of it as memory for the mainframe.

• The physical storage external to the mainframe, including storage on direct access

devices, such as disk drives and tape drives. This storage is called auxiliary storage. The primary difference between the two kinds of storage relates to the way in which it is accessed, as follows:

• Real storage is accessed synchronously with the processor. That is, the processor must wait while data is retrieved from real storage.

• Auxiliary storage is accessed asynchronously. The processor accesses auxiliary

storage through an input/output (I/O) request, which is scheduled to run amid other work requests in the system. During an I/O request, the processor is free to execute other, unrelated work.

As with memory for a personal computer, mainframe real storage is tightly integrated with the processor itself. In contrast, mainframe auxiliary storage is located on (comparatively) slower external disk and tape drives. Because real storage is more closely integrated with the processor, it takes the processor much less time to access data from real storage than from auxiliary storage. However, the processor is free to do other work while waiting for an I/O request to be satisfied. Auxiliary storage is less expensive than real storage, so it provides the capability for many jobs to be running while keeping real storage costs down.

4.3.5. More about storage Main storage provides the system with directly addressable fast-access storage of data. Both data and programs must be loaded into main storage (from input devices) before they can be processed. Main storage may include one or more smaller faster-access buffer storages, sometimes called caches. A cache is usually physically associated with a CPU or an I/O processor. The effects, except on performance, of the physical construction and use of distinct storage media are not observable by the program. Main storage may be volatile or nonvolatile. If it is volatile, the contents of main storage are not preserved when power is turned off. If it is nonvolatile, turning power off and then back

Page 81: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 81 -

on does not affect the contents of main storage, provided all CPUs are in the stopped state and no references are made to main storage when power is being turned off.

4.3.5.1. Storage Addressing Storage is viewed as a long horizontal string of bits. For most operations, accesses to storage proceed in a left-to-right sequence. The string of bits is subdivided into units of eight bits. An eight-bit unit is called a byte, which is the basic building block of all information formats. Each byte location in storage is identified by a unique nonnegative integer, which is the address of that byte location or, simply, the byte address. Adjacent byte locations have consecutive addresses, starting with 0 on the left and proceeding in a left-to-right sequence. Addresses are unsigned binary integers and are 24, 31, or 64 bits

4.3.5.2. Information Formats Information is transmitted between storage and a CPU or the channel subsystem one byte, or a group of bytes, at a time. Unless otherwise specified, a group of bytes in storage is addressed by the leftmost byte of the group. The number of bytes in the group is either implied or explicitly specified by the operation to be performed. When used in a CPU operation, a group of bytes is called a field. Within each group of bytes, bits are numbered in a left-to-right sequence. The leftmost bits are sometimes referred to as the “high-order” bits and the rightmost bits as the “low-order” bits. Bit numbers are not storage addresses, however, only bytes can be addressed. To operate on individual bits of a byte in storage, it is necessary to access the entire byte. The bits in a byte are numbered 0 through 7, from left to right.

4.3.5.3. Integral Boundaries Certain units of information must be on an integral boundary in storage. A boundary is called integral for a unit of information when its storage address is a multiple of the length of the unit in bytes. Special names are given to fields of 2, 4, 8, and 16 bytes on an integral boundary. A halfword is a group of two consecutive bytes on a two-byte boundary and is the basic building block of instructions. A word is a group of four consecutive bytes on a four-byte boundary. A doubleword is a group of eight consecutive bytes on an eight-byte boundary. A quadword is a group of 16 consecutive bytes on a 16-byte boundary Integral boundary says, an 8-byte field must have an address exactly divisible by 8, a 4-byte field's address must be divisible by 4, and so on Instructions must be on two-byte integral boundaries, and CCWs (Channel Command Words), IDAWs (Indirect Address Words), and the storage operands of certain instructions must be on other integral boundaries. The storage operands of most instructions do not have boundary-alignment requirements.

Page 82: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 82 -

4.3.5.4. Address Types For purposes of addressing main storage, three basic types of addresses are recognized: absolute, real, and virtual.

4.3.5.4.1. Absolute Address An absolute address is the address assigned to a main-storage location. An absolute address is used for a storage access without any transformations performed on it. The channel subsystem and all CPUs in the configuration refer to a shared main-storage location by using the same absolute address. Available main storage is usually assigned contiguous absolute addresses starting at 0, and the addresses are always assigned in complete 4K-byte blocks on integral boundaries.

4.3.5.4.2. Real Address A real address identifies a location in real storage. When a real address is used for an access to main storage, it is converted, by means of prefixing, to an absolute address. At any instant there is one real-address to absolute-address mapping for each CPU in the configuration. When a real address is used by a CPU to access main storage, it is converted to an absolute address by prefixing. The particular transformation is defined by the value in the prefix register for the CPU.

4.3.5.4.3. Prefixing Prefixing provides the ability to assign the range of real addresses 0-8191 (8KB) to a different block in absolute storage for each CPU, thus permitting more than one CPU sharing main storage to operate concurrently with a minimum of interference, especially in the processing of interruptions. Prefixing causes real addresses in the range 0-8191 to correspond one-for-one to the block of 8K-byte absolute addresses (the prefix area) identified by the value in bit positions 0-50 of the prefix register for the CPU, and the block of real addresses identified by that value in the prefix register to correspond one-for-one to absolute addresses 0-8191. The remaining real addresses are the same as the corresponding absolute addresses. This transformation allows each CPU to access all of main storage, including the first 8K bytes and the locations designated by the prefix registers of other CPUs.

4.3.5.4.4. Virtual Address A virtual address identifies a location in virtual storage. When a virtual address is used for an access to main storage, it is translated by means of dynamic address translation to a real address, which is then further converted by prefixing to an absolute address.

Page 83: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 83 -

We have few more different jargons here, Cache Memory, Virtual Memory, Prefixing…, let’s see what they really mean

4.3.5.5. Cache Memory This is a small fast memory placed between the CPU and the main memory. A memory cache, sometimes called a cache store or RAM cache, is a portion of memory made of high-speed static RAM (SRAM) instead of the slower and cheaper dynamic RAM (DRAM) used for main memory. Memory caching is effective because most programs access the same data or instructions over and over. By keeping as much of this information as possible in SRAM, the computer avoids accessing the slower DRAM. Thus making the execution of the programs faster

4.3.5.6. Virtual Memory Imagine your PC has only 64MB of main memory. If you load the operating system, an e-mail program, a Web browser and word processor into RAM simultaneously, 64 megabytes is not enough to hold it all. If there were no such thing as virtual memory, then once you filled up the available RAM, your computer would have to say, "Sorry, you can not load any more applications. Please close another application to load a new one." With virtual memory, what the computer can do is look at RAM for areas that have not been used recently and copy them onto the hard disk. This frees up space in RAM to load the new application. Virtual Memory breaks a program into a number of fixed length portions called pages, or into variable length portions called segments. Each of these is very small. Only the relevant portion is loaded into the main memory, whereas the remaining other program pages are stored on a peripheral disk

CPU

Cache

Main Memory

CPU

Cache

Main Memory

Virtual Memory

Disk Storage

Page 84: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 84 -

This permits the loading of portions of two or more programs at the same time on the RAM. This is the reason why computers can run two or more programs at the same time. The computer could be playing music for the user while the user is busy using an accounting software on the same computer On your PC (Windows XP Machine), you can setup virtual memory size by selecting Control Panel/System Properties/Performance Options

Page 85: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 85 -

4.3.5.7. Virtual Memory and z/OS

In z/OS, each user has access to virtual storage, rather than physical storage. This use of virtual storage is central to the unique ability of z/OS to interact with large numbers of users concurrently, while processing the largest workloads. To make virtual storage possible, z/OS requires sufficient amounts of real storage and many billions of bytes of auxiliary storage. z/OS uses a system of tables and special settings (bit settings) to relate the location of data on disk storage and real storage, and keep track of the identity and authority of each user or program. z/OS uses a variety of storage manager components to manage virtual storage.

4.3.5.7.1. What does it really mean? Virtual storage means that each running program can assume it has access to all of the storage defined by the architecture’s addressing scheme. The only limit is the number of bits in a storage address. This ability to use a large number of storage locations is important because a program may be long and complex, and both the program’s code and the data it requires must be in real storage for the processor to access them. z/OS supports 64-bit long addresses, which allows a program to address up to 16 Exa (1 Exa is 260) of storage locations. In reality, mainframe might have much less real storage installed. How much less depends on the model of computer and the system configuration. To allow each user to act as though this much storage really exists in the computer system, z/OS keeps only the active portions of each program in real storage. z/OS keeps the rest of the code and data in files called paging data sets on auxiliary storage, which usually consists of a number of high-speed direct access storage devices (DASDs). Virtual storage, then, is this combination of real and auxiliary storage

4.3.5.8. Address Space The range of virtual addresses that the operating system assigns to a user (or separately running program) is called an address space. This is the area of contiguous virtual addresses available for executing instructions and storing data. The range of virtual addresses in an address space starts at zero and can extend to the highest address permitted by the operating system architecture. z/OS provides each user with a unique address space and maintains the distinction between the programs and data belonging to each address space. Within each address space the user can start multiple tasks, using task control blocks or TCBs that allow user multiprogramming. When a virtual address is used by a CPU to access main storage, it is first converted, by means of dynamic address translation (DAT), to a real address, and then, by means of prefixing, to an absolute address.

Page 86: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 86 -

Address spaces provide isolation of private areas in different address spaces (and this provides much of the operating system’s security), yet each address space also contains a common area that is accessible to every other address space. Because it maps all of the available addresses, an address space includes system code and data as well as user code and data. Thus, not all of the mapped addresses are available for user code and data. The ability of many users to share the same resources implies the need to protect users from one another and to protect the operating system itself. Along with such methods as “keys” for protecting real storage and code words for protecting data files and programs, separate address spaces ensure that users’ programs and data do not overlap. An active z/OS system uses many address spaces. There is at least one address space for each job in progress and one address space for each logged-on user. There are many address spaces for operating system functions, such as operator communication, automation, networking, security, and so on.

4.3.5.9. Virtual Storage Operation - Overview Recall that for the processor to execute a program instruction, both the instruction and the data it references must be in real storage. The convention of early operating systems was to have the entire program reside in real storage when its instructions were executing. However, the entire program does not really need to be in real storage when an instruction executes. Instead, by bringing pieces of the program into real storage only when the processor is ready to execute them—moving them out to auxiliary storage when it doesn’t need them, an operating system can execute more and larger programs concurrently. Let’s see how the system makes it happen Physical storage is divided into areas, each the same size and accessible by a unique address. In real storage, these areas are called frames; in auxiliary storage, they are called slots Similarly, the operating system can divide a program into pieces the size of frames or slots and assign each piece a unique address. This arrangement allows the operating system to keep track of these pieces. In z/OS, the program pieces are called pages The addresses of pages are called virtual addresses. From the time a program enters the system until it completes, the virtual address of the page remains the same, regardless of whether the page is in real storage or auxiliary storage. Each page consists of individual locations called bytes, each of which has a unique virtual address

4.3.5.9.1. Paging z/OS maintains tables to determine whether a page is in real or auxiliary storage. To find a page of a program, z/OS checks the table for the virtual address of the page, rather than searching through all of physical storage for it. z/OS then transfers the page into real storage

Page 87: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 87 -

or out to auxiliary storage as needed. This movement of pages between auxiliary storage slots and real storage frames is called paging. Paging is key to understanding the use of virtual storage in z/OS. z/OS paging is transparent to the user. During job execution, only those pieces of the application that are required are brought in, or paged in, to real storage. The pages remain in real storage until no longer needed, or another page is required by the same application or a higher priority application, and no empty real storage is available. To select pages for paging out to auxiliary storage, z/OS follows a “Least Frequently Used” algorithm. That is, z/OS assumes that a page that has not been used for some time will not be used in the near future.

4.3.5.9.2. Virtual Storage Address Each user or program gets an address space, and each address space contains the same range of storage addresses. Only those portions of the address space that are needed at any one point in time are actually loaded into real storage. z/OS keeps the inactive pieces of address spaces in auxiliary storage z/OS manages address spaces in units of various sizes, as follows: Page: Address spaces are divided into 4-kilobyte units of virtual storage called

pages Segment: Address spaces are divided into 1-megabyte units called segments. A segment

is a block of sequential virtual addresses spanning megabytes, beginning at a 1-megabyte boundary. A 2-gigabyte address space, for example, consists of 2048 segments.

Region: Address spaces are divided into 2-8 gigabyte units called regions. A region is

a block of sequential virtual addresses spanning 2-8 gigabytes, beginning at a 2-gigabytes boundary. A 2-terabyte address space, for example, consists of 2048 regions.

A virtual address, accordingly, is divided into four principal fields. Bits 0-32 are called the region index (RX), bits 33-43 are called the segment index (SX), bits 44-51 are called the page index (PX), and bits 52-63 are called the byte index (BX). A virtual address has the following format:

RX

SX

PX

BX

0 33 44 52 63

Page 88: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 88 -

As determined by its address-space-control element, a virtual address space can be a 2G-byte space consisting of one region, or it may be up to a 16-exabyte space consisting of up to 8G regions. The RX part of a virtual address applying to a 2G-byte address space must be all zeros; otherwise, an exception is recognized. The RX part of a virtual address is itself divided into three fields. Bits 0-10 are called the region first index (RFX), bits 11-21 are called the region second index (RSX), and bits 22-32 are called the region third index (RTX). Bits 0-32 of the virtual address have the following format:

RFX

RSX

RTX

0 11 22 33 A virtual address in which the RTX is the left most significant part (a 42-bit address) is capable of addressing 4T bytes (2K regions), one in which the RSX is the left most significant part (a 53-bit address) is capable of addressing 8P bytes (4M regions), and one in which the RFX is the lifetimes significant part (a 64-bit address) is capable of addressing 16E bytes (8G regions).

4.3.5.9.3. Dynamic Address Translation Dynamic address translation, or DAT, is the process of translating a virtual address during a storage reference into the corresponding real address. If the virtual address is already in central storage, the DAT process may be accelerated through the use of a translation look-aside buffer. If the virtual address is not in central storage, a page fault interrupt occurs, and z/OS is notified and brings the page in from auxiliary storage. Looking at this process more closely reveals that the machine can present any one of a number of different types of faults. A type, region, segment, or page fault will be presented depending on at which point in the DAT structure invalid entries are found. The faults repeat down the DAT structure until ultimately a page fault is presented and the virtual page is brought into central storage either for the first time (there is no copy on auxiliary storage) or by bringing the page in from auxiliary storage. DAT is implemented by both hardware and software through the use of page tables, segment tables, region tables and translation look-aside buffers. DAT allows different address spaces to share the same program or other data that is for read only. This is because virtual addresses in different address spaces can be made to translate to the same frame of central storage.

Page 89: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 89 -

Otherwise, there would have to be many copies of the program or data, one for each address space. Generally, in most processors, a direct mapping scheme is supported by the system hardware, in which a page map is maintained in physical memory. This means that each physical memory reference requires both an access to the page table and an operand fetch. In effect, all memory references are indirect Virtual address translation hardware without translation look-aside buffer This requirement would be a considerable performance penalty, so most systems which support virtual addressing have a small associative memory (called a translation look-aside buffer, or TLB) which contains the last few virtual addresses and their corresponding physical addresses, so in most cases the virtual to physical mapping does not require an additional memory access

Virtual page Number Offset

Page Map

Physical Page Number Offset Absolute Address

Base Address of Page In Physical Memory

Page 90: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 90 -

Virtual address translation hardware with translation look-aside buffer

4.3.5.9.4. Frames, Pages, and Slots When a program is selected for execution, the system brings it into virtual storage, divides it into pages of 4 kilobytes (4K), transfers the pages into real storage for execution, and transfers pages that are not needed out to auxiliary storage. To the programmer, the entire program appears to occupy contiguous space in real storage at all times. Actually, not all pages of a program are necessarily in real storage, and the pages that are in real storage do not necessarily occupy contiguous space. The pieces of a program executing in virtual storage must be moved between real and auxiliary storage. To allow this, z/OS manages storage in units, or blocks, of 4 kilobytes. The following blocks are defined:

Virtual page Number Offset

Page Map

Physical Page Number Offset Absolute Address

Base Address of Page In Physical Memory

TLB

Page miss in TLB

Page hit In TLB

Page 91: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 91 -

• A block of real storage is a frame. • A block of virtual storage is a page. • A block of auxiliary storage is a slot.

A page, a frame, and a slot are all the same size: 4096 bytes (4 kilobytes). An active virtual storage page resides in a real storage frame. A virtual storage page that becomes inactive resides in an auxiliary storage slot (in a paging data set).

Frames, Pages and Slots

4.3.5.9.5. Page Stealing z/OS tries to keep an adequate supply of available real storage frames on hand. When a program refers to a page that is not in real storage, z/OS uses a real storage page frame from a supply of available frames. When this supply becomes low, z/OS uses page stealing to replenish it, that is, it takes a frame assigned to an active user and makes it available for other work. The decision to steal a particular page is based on the activity history of each page currently residing in a real storage frame. Pages that have not been accessed for a relatively long time are good candidates for page stealing

4.3.5.9.6. Swapping Swapping is the process of transferring all of the most recently valid pages of an address space between real storage and auxiliary storage. This has the effect of moving an entire

Page 92: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 92 -

address space into, or out of, real storage. It is one of several methods that z/OS uses to balance the system workload and ensure that an adequate supply of available real storage frames is maintained. A swapped-in address space is active; having pages in real storage frames and pages in auxiliary storage slots. A swapped-out address space is inactive; the address space resides on auxiliary storage and cannot execute until it is swapped in. Swapping is performed in response to recommendations from the z/OS Workload Manager (WLM) component.

4.3.6. Brief History of 64 bit addressability

In 1970, IBM introduced System/370, the first of its architectures to use virtual storage and address spaces. Since that time, the operating system has changed in many ways. One key area of growth and change is addressability. System/370 defined storage addresses as 24 bits in length, which meant that the highest accessible address was 16,777,216 bytes (or 224 bytes). The use of 24-bit addressability allowed MVS/370, the operating system at that time, to allot to each user an address space of 16 MB. Over the years, as MVS/370 gained more functions and was asked to handle more complex applications, even access to 16 MB of virtual storage fell short of user needs. With the release of the System/370-XA architecture in 1983, IBM extended the addressability of the architecture to 31 bits. With 31-bit addressing, the operating system (now called MVS Extended Architecture or MVS/XA™) increased the addressability of virtual storage from 16 MB to 2 gigabytes (2 GB). In other words, MVS/XA provided an address space for users that was 128 times larger than the address space provided by MVS/370. The 16 MB address became the dividing point between the two architectures and is commonly called the line

The ‘Bar’

The ‘Line’ 24 bit

Addressing (MVS)

31 bit Addressing (MVS/XA)

16MB

2GB

Page 93: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 93 -

The new architecture did not require customers to change existing application programs. To maintain compatibility for existing programs, MVS/XA remained compatible for programs originally designed to run with 24-bit addressing on MVS/370, while allowing application developers to write new programs to exploit the 31-bit technology. To preserve compatibility between the different addressing schemes, MVS/XA did not use the high-order bit of the address (Bit 32) for addressing. Instead, MVS/XA reserved this bit to indicate how many bits would be used to resolve an address: 31-bit addressing (Bit 32 on) or 24-bit addressing (Bit 32 off). With the release of zSeries mainframes in 2000, IBM further extended the addressability of the architecture to 64 bits. With 64-bit addressing, the potential size of a z/OS address space expands to a size so vast that we need new terms to describe it. Each address space, called a 64-bit address space, is 16 exabytes (EB – 16 260) in size

The ‘Bar’

The ‘Line’ 24 bit

Addressing (MVS)

31 bit Addressing (MVS/XA)

16MB

2GB

16 EB

64 bit Addressing (z/OS)

Page 94: An Introduction to Mainframes

z/Architecture and z/OS

An Introduction to Mainframes - 94 -

We say that the potential size is 16 exabytes because z/OS, by default, continues to create address spaces with a size of 2 GB. The address space exceeds this limit only if a program running in it allocates virtual storage above the 2 GB address. If so, the z/OS operating system increases the storage available to the user from 2 GB to 16 EB. Programs running on z/OS and zSeries mainframes can run with 24-, 31-, or 64-bit addressing (and can switch among these if needed). Programs can use a mixture of instructions with 64-bit operands or 32-bit operands or other operands.

Page 95: An Introduction to Mainframes

Leftover

An Introduction to Mainframes - 95 -

Chapter 5

Leftover

Page 96: An Introduction to Mainframes

Leftover

An Introduction to Mainframes - 96 -

5. Leftover

5.1. Job roles in the mainframe world It would be better to present the job roles in the mainframe world as it is entirely different from the normal scenarios Mainframe systems are designed to be used by large numbers of people. Most of those who interact with mainframes are end users – the people who use the applications hosted on the system. However, because of the large number of end users, applications running on the system, and the sophistication and complexity of the system software that supports the users and applications, a variety of roles are needed to support and operate the system.

5.1.1. System Programmer In a mainframe IT organization, the system programmer (or systems programmer) plays a central role. The system programmer installs, customizes, and maintains the operating system, and also installs or upgrades products that run on the system. The system programmer might be presented with the latest version of the operating system to upgrade the existing systems. Or, the installation might be as simple as upgrading a single program, such as a sort. In any case, the system programmer must perform tasks like the following:

• Planning software and hardware system upgrades and changes in configuration • Training system operators and application programmers • Automating operations • Capacity planning • Running installation jobs and scripts • Performing installation-specific customization tasks • Integration-testing the new products with existing applications and user procedures • System-wide performance tuning to meet required levels of service

The system programmer must be skilled at debugging problems with system software. These problems are often manifested by software system images, sometimes known as dumps that have been produced by the software products or in user jobs or transactions System programmers are needed to install and maintain the middleware on the mainframe, such as database management systems, online transaction processing systems, Web servers, and so forth. Middleware is a software “layer” between the operating system and the end user or end-user application. It supplies major functions not provided by the operating system. Major Middleware products such as DB2, CICS, and IMS™ can be as complex, if not more so, than the operating system itself.

Page 97: An Introduction to Mainframes

Leftover

An Introduction to Mainframes - 97 -

There are a wide variety of system configuration options to be maintained, in addition to the daily monitoring and debugging of the system. And, on the database side, the database administrator (DBA) is also present to ensure the integrity and smooth operation of the data that is stored in the database management systems. These roles are not necessarily unique to the mainframe environment, but they are key to its smooth operation nonetheless.

5.1.2. System Administrator The distinction between “system programmer” and “system administrator” varies widely among mainframe sites. In many smaller IT organizations, where one person might be called upon to perform several roles, the terms may be used interchangeably. In larger IT organizations with multiple departments, the job responsibilities tend to be more clearly separated. System administrators perform more of the day-to-day tasks related to maintaining the critical business data that resides on the mainframe, while the system programmer focuses on maintaining the system itself. One reason for the separation of duties is to comply with auditing procedures, which often require that no one person in the IT organization be allowed to have unlimited access to sensitive data or resources. Examples of system administrators include database administrators and security administrators. While system programmer expertise lies mainly in the mainframe hardware and software areas, system administrators are more likely to have experience with the applications. They often interface directly with the application programmers and end users to ensure that the administration aspects of the applications are met. In larger IT organizations, the system administrator maintains the system software environment for business purposes, including the day-to-day maintenance of systems to keep them running smoothly. Other examples of common system administrator tasks can include:

• Installing software • Adding and deleting users and maintaining user profiles • Maintaining security resource access lists • Managing storage devices and printers • Managing networks and connectivity • Monitoring system performance

In matters of problem determination, the system administrator generally relies on the software vendor support center personnel to diagnose problems, read dumps, and identify corrections for cases in which these tasks aren’t performed by the system programmer

5.1.3. Application Designers and Programmers The application designer and application programmer (or developer) design, build, test, and deliver mainframe applications for the company’s end users and customers. Based on requirements gathered from business analysts and end users, the designer creates a design

Page 98: An Introduction to Mainframes

Leftover

An Introduction to Mainframes - 98 -

specification from which the programmer constructs an application. The process includes many iterations of code changes and compiles, application builds, and unit testing During the application development process, the designer and programmer must interact with other roles in the enterprise. For example, the programmer often works on a team of other programmers who are building code for related application program modules. When completed, each module is passed through a testing process that can include function, integration, and system-wide tests. Following the tests, the application programs must be acceptance tested by the user community to determine whether the code actually satisfies the original user requirement. Besides creating new application code, the programmer is responsible for maintaining and enhancing the company’s existing mainframe applications. In fact, this is frequently the primary job for many application programmers on the mainframe today. While many mainframe installations still create new programs with COBOL or PL/I, languages such as Java™ have become popular for building new applications on the mainframe, just as on distributed platforms.

5.1.4. System Operator The system operator monitors and controls the operation of the mainframe hardware and software. The operator starts and stops system tasks, monitors the system consoles for unusual conditions, and works with the system programming and production control staff to ensure the health and normal operation of the systems. The operator is also responsible for starting and stopping the major subsystems, such as transaction processing systems, database systems, and the operating system itself. In case of a failure or an unusual situation, the operator communicates with system programmers, who assist the operator in determining the proper course of action, and with the production control analyst, who works with the operator to ensure that production workloads are completing properly.

5.1.5. Production Control Analyst The production control analyst is responsible for ensuring that batch workloads run to completion--without error or delay. Many mainframe installations run interactive workloads for online users, followed by batch updates that run after the prime shift when the online systems are not running.

5.2. Program Products for z/OS A z/OS system usually contains additional program products (priced products) that are needed to create a practical working system, such as a security manager product and a database manager product.

Page 99: An Introduction to Mainframes

Leftover

An Introduction to Mainframes - 99 -

Some common choices include: A security system

z/OS provides a framework for customers to add security through the addition of a security management product (IBM’s program product is Resource Access Control Facility or RACF®). Non-IBM security system program products are also available.

Compilers

z/OS includes an assembler and a C compiler. Other compilers, such as the COBOL compiler, are offered as separate products.

A relational database, such as DB2

Other types of database products, such as hierarchical databases, are also available. Transaction processing facilities

IBM offers several, including:

– Customer Information Control System (CICS) – Information Management System (IMS) – WebSphere Application Server (WAS)

A sort program

Fast, efficient sorting of large amounts of data is highly desirable in batch processing. IBM and other vendors offer sophisticated sorting products.

A large variety of utility programs

For example, the System Display and Search Facility (SDSF) A large number of other products are available from various independent software vendors (commonly called ISVs in the industry).

Page 100: An Introduction to Mainframes

An Introduction to Mainframes - 100 -

PART - 2

Page 101: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 101 -

Chapter 1

COBOL – Tips and Tricks

Page 102: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 102 -

1. COBOL – Tips and Tricks

1.1. Tips and Tricks! I still remember the day the Tips and Tricks took its birth. I could say I started sending Tips and Tricks few months after I started my IT career. The beginning was like this. We had a confusion regarding the internal representation of numbers inside mainframe. We did a bit of research and came up with a write – up and shared it with the team. The response was quite surprising. It fuelled my wish to send it continuously. I think so far I had sent more than 75 such documents. A consolidation of all the Tips and Tricks were published already. This is the updated version of that. I hope it would help you in your daily work. Let there be Light!

1.2. BLOCK Structure in Files (COBOL) – General Perspective While handling a tape or disk file, normally a single record is not read or written. Instead, the usual practice is to group a number of consecutive records to form what is known as a block or physical record. For example, block can consist of 10 records. This means that the first 10 consecutive records will form the first block of the file, the next 10 records will form the next block of the file, and so on. The number of records in a block is often called the ‘blocking factor’ The actual handling of the blocks is transparent to the programmer. The Input Output Control System (IOCS) takes care of blocking. The programmer should only specify the number of records that should be contained in a block. When a file is blocked, a physical read or write operation on the file is only applicable to the entire block and not to the individual records in the block. However, the programmer would like to read or write only one record at a time. This requirement of the programmer is fulfilled by the IOCS in the following manner. The IOCS reserves a memory space equal to the size of a block of the file. This memory space s is known as the buffer. When the programmer wants to read the first record from the file, the IOCS reads the first block into the buffer but releases only the first record to the program. The next time the programmer wants to read a record, IOCS releases the second record from the buffer. In this way only when all the records in the block has been released to the program and the programmer wants to read the next record, the IOCS reads another block. In this respect the function of the IOCS in the case of writing on a file is just the reverse of reading. However, it is important to note that every read or write statement doesn’t require the physical reading or writing of the file. Thus the read/write statements in the program are

Page 103: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 103 -

logical operations; the physical reading or writing is done by the IOCS at the block level. The records as defined in the program are sometimes called logical records and the blocks which are records as stored on the file medium are called physical records. The advantage of blocking is two fold.

• Firstly, blocking results in saving in terms of input – output time required to handle a file.

• The other advantage of blocking is that a substantial amount of storage space on the tap of disk can be saved.

We know that in the case of tape files, an inter-record gap is generated between any two consecutive records. The total space occupied by these inter record gaps is quite substantial. Blocking helps to get the number of such gaps reduced thereby decreasing the wastage of storage spaces o n account of these gaps We specify blocking in FD file name BLOCK CONTAINS <INTEGER1> RECORDS/CHARACTERS Magnetic tape of disk files can contain variable length records. In this case the file can have records with different fixed lengths or one or more records can contain variable number of table elements. In the latter case, the table elements are defined with the occurs … depending on clause Each record in a file with variable length records carries a data item that contains the length of the record. The COBOL features for variable length records are only limited to the file description and record description entries in the file section. BLOCK CONTAINS INTEGER-1 TO INTEGER-2 RECORDS/CHARACTERS RECORD CONTAINS INTEGER-3 TO INTEGER-4 CHARACTERS The above forms for the BLOCK CONTAINS and RECORD CONTAINS clauses are quite sufficient to indicate that the said file is a file with variable length records. However, these clauses being optional in some computers, a non standard clause is also required. The clause is as follows RECORDING MODE IS F/V Where, V indicates variable length records while F indicates fixed length records. JCL: Declaration for a fixed block data set, having LRECL = 80

Page 104: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 104 -

// DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS) For a variable block file, you have to take 4 more bytes into consideration while specifying LRECL in JCL (this 4 bytes is used for marking the length of the record) // DCB=(RECFM=VB,LRECL=84,BLKSIZE=840,DSORG=PS)

1.3. REDEFINES Clause Sometimes, it may be found that two or more storage areas defined in the DATA DIVISION are not in use simultaneously. In such cases only one storage area can serve the purpose of two or more areas if the area is redefined. The REDEFINES clause allows the same area to be referred to by more than one data name with different sizes and pictures. For example, 01 SALES-RECORD. 05 SALES-TYPE PIC X(01). 05 SALES-BY-UNIT. 10 QTY PIC 9(04). 10 UNIT-PRICE PIC 9(08)V99. 05 TOTAL-SALES REDEFINES SALES-BY-UNIT. 10 AMOUNT PIC 9(10)V99. 10 FILLER PIC X(02). This example describes a sales record which may either contain the total amount of sales (TOTAL-SALES) or the QTY & UNIT-PRICE The purpose of such description may be to have two types of records and their types may be determined from the data item named SALES-TYPE Depending on some predetermined values of SALES-TYPE the record will be interpreted in one of the two forms. Note that SALES-BY-UNIT & TOTAL-SALES refer to the same storage space. They really represent two different mappings of this same storage area Advantage: Conservation of Storage space Syntax: Level-number data-name-1 REDEFINES data-name-2

Page 105: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 105 -

Rules

1) The level-number of data-name-1 and data-name-2 must be identical.

2) Except when the REDEFINES clause is used to 01 level, data-name-1 and data-name-2 must be of same size

3) When the 01 level is used, the size of data-name-1 must not exceed that of data-

name-2

4) Multiple redefinitions are allowed. The entries giving the new descriptions must immediately follow the REDEFINES entry.

5) In the case of multiple redefinitions, the data-name-2 must be the data name of the

entry that originally defined the area.

6) The REDEFINES clause must immediately follow the data-name-1

7) Entries giving new descriptions can't have the value clauses (except in the case of condition-names(88))

8) The REDEFINES clause must not be used for records (01 level) described in the

FILE SECTION. The appearance of multiple 01 entry in the record description is implicitly assumed to be the redefinition of the first 01 level record.

9) This clause must not be used for level-number 66 or 88

(COBOL 77 Standard) According to COBOL - 85, a redefined data item can be equal or smaller in size than that of the data item it redefines. Note that in COBOL - 74, the two must be equal. For example 05 DATA-A PIC X(12) 05 DATA-B REDEFINES DATA-A. 10 FIELD-A PIC 9(03)V99. 10 FIELD-B PIC 9(02).

1.4. RENAMES Clause Sometimes a re-grouping of elementary data items in a record may be necessary so that they can belong to the original as well as to the new group.

Page 106: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 106 -

01 PAY-REC.

05 FIXED-PAY. 10 BASIC-PAY PIC 9(6)V99. 10 DEARNESS-ALLOWANCE PIC 9(6)V99.

05 ADDITIONAL-PAY. 10 HOUSE-RENT PIC 9(4)V99. 10 MNTHLY-INCENTIVE PIC 9(3)V99.

05 DEDUCTIONS. 10 PF-DEDUCT PIC 9(3)V99. 10 IT-DEDUCT PIC 9(4)V99. 10 OTHER-DEDUCT PIC 9(3)V99.

66 PAY-OTHER-THAN-BASIC RENAMES DEARNESS-ALLOWANCE THRU MNTHLY-INCENTIVE 66 IT-AND-PF-DEDUCTIONS RENAMES PF-DEDUCT THRU IT-DEDUCT. In the above example, PAY-OTHER-THAN-BASIC will become a new group consisting of DEARNESS-ALLOWANCE, HOUSE-RENT and MNTHLY-INCENTIVE. Note that the new group overlaps on two original groups, namely, part of FIXED-PAY and the entire ADDITIONAL-PAY. Such overlapping is allowed provided the elementary items are all contiguous. In a similar way IT-AND-PF-DEDUCTIONS has two elementary items PF-DEDUCT and IT-DEDUCT. This new group is formed out of the original group DEDUCTIONS. Alternatively, the same thing can also be done in the original group description by placing like this . . .

05 DEDUCTIONS. 10 IT-AND-PF-DEDUCTIONS.

15 PF-DEDUCT PIC 9(3)V99. 15 IT-DEDUCT PIC 9(4)V99.

10 OTHER-DEDUCT PIC 9(3)V99. Syntax 66 data-name-1 RENAMES data-name-2 THRU data-name-3 Rules

1) All RENAMES entries must be written only after the last record description entry 2) The RENAMES clause must be used only with the special level number 66 3) Data-name-2 and data-name-3 can be the names of elementary items or group items.

They however can’t be items of levels 01,66,77 or 88 4) Neither data-name-2 nor data-name-3 can have an OCCURS clause in its description

entry, nor can they be subordinate to an item that has an occurs clause in its data description entry

Page 107: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 107 -

5) Data-name-3, if mentioned, must follow data-name-2, in the record and must not be one of its sub fields.

1.5. USAGE Clause Normally, a computer can store data in more than one internal form. In COBOL, a programmer is allowed to specify the internal form of the data item so as to facilitate the use of the data item more efficiently. Broadly, there are only two general forms of internal representation – computational and display. Only numeric data items can be displayed as computational, and as the name suggests, an item specified as computational can take part in arithmetic operations more efficiently. On the other hand, any data item can be specified as display. This form is suitable for input/output and character manipulations. Whether a data item is computational or display, it can be specified with a usage clause in addition to the PIC clause

1.5.1. USAGE IS DISPLAY This is the most common form of internal data. Each character of the data is represented in one byte and a data item is stored in a couple of contiguous bytes. The number of bytes required is equal to the size of the data item. One can specify the usage as DISPLAY. However, it is also the default.

1.5.2. USAGE IS COMPUTATIONAL / COMP / BINARY This usage stores data in the form in which the computer actually does its computation. Usually this form is binary. Thus defining WORKING-STORAGE SECTION entries in binary format is desirable when many repetitive arithmetic computations must be performed. The item must be an integer (no assumed decimal point is allowed). COBOL 85 permits the USAGE IS BINARY clause as well to specifically represent data in binary form A few notes to remember: while allocating the space, for COMP fields, the compiler will allocate space in multiples of word, that is, it can be half word (2 bytes), full word or word (4 bytes), double word (8 bytes) like that So if the PIC specified is 9(1) COMP, 9(2) COMP, 9(3) COMP OR 9(4) COMP, the space allocated by the compiler will be half word (2 bytes). This allocation depends on the length of the maximum number that you can represent with this specification. That is if you specify 9(4), the max number that you can represent is 9999. This number can be easily represented by 2 bytes. With 2 bytes you can represent up to 65535

Page 108: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 108 -

If you specify 9(5) COMP, 9(6) COMP, 9(7) COMP OR 9(8) COMP, the space allocated by the compiler will be one word (4 bytes). That is with 9(8), you can represent a maximum of 99999999, this is possible with a word, and a word can represent up to 4294967295 If you specify a PIC more than 9(8), it will allocate a double word (8 bytes). Points to keep in mind while you declare an item as COMP 1) Don’t use COMP if the data item is

a) Properly DISPLAY b) Nonnumeric or edited c) A field associated with a unit record device or terminal (this means, you can’t

accept from user, an item that is declared as COMP)

2) Use COMP if the data item is a

a) A numeric field in a record input from a tape or disk file whether it was already COMP

b) Numeric, is used in calculations, and is a field in a record to be output to a tape or disk file from which it will later be input and used in further computation

c) In WORKING-STORAGE, and is numeric and not edited and used in calculations

1.5.3. USAGE IS COMP-1 If the usage of a numeric data item is specified as COMP-1, it will be represented in one word (4 bytes) in the floating point form (single precision floating point form). Such representation is suitable for arithmetic operations. The number is actually represented in hexadecimal. The PIC clause can’t be specified for COMP-1 items

1.5.4. USAGE IS COMP-2 This usage is the same as COMP-1 except that the data is represented internally in two words (8 bytes). The advantage is that this increases the precision of the data (double precision) which means that more significant digits can be available for the item. The PIC clause can’t be specified for COMP-2 items

1.5.5. USAGE IS COMP-3 COMP-3 enables the computer to store two digits in each storage position, except for the rightmost position, which holds the sign. The sign is stored separately as the rightmost half-a-byte regardless of whether S is specified in the PIC or not.

Page 109: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 109 -

The hexadecimal number C or F denotes a positive sign and the hexadecimal number D denotes a negative sign. Suppose if you move 1234567 into a field defined 9(7). In DISPLAY mode, which is default, this field will use 7 storage positions. If you define the field with PIC 9(7) COMP-3, it will however use only four positions

12 34 56 7+ We can save a significant amount of storage by using the USAGE-COMP-3

1.6. Different forms of EVALUATE Statement Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no ‘break’ is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is made. Different forms of EVALUATE statements are a) EVALUATE WHEN A=B AND C=D Imperative stmt WHEN (D+X)/Y = Imperative stmt WHEN OTHER Imperative stmt END-EVALUATE b) EVALUATE SQLCODE ALSO FILE-STATUS WHEN 100 ALSO ‘00’ Imperative stmt WHEN -305 ALSO ‘32’ Imperative stmt WHEN OTHER Imperative stmt END-EVALUATE c) EVALUATE SQLCODE ALSO A=B WHEN 100 ALSO TRUE Imperative stmt WHEN -305 ALSO FALSE Imperative stmt END-EVALUATE

Page 110: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 110 -

d) EVALUATE SQLCODE ALSO TRUE WHEN 100 ALSO A=B Imperative stmt WHEN -305 ALSO (A/C=4) Imperative stmt END-EVALUATE During the execution of an EVALUATE statement, the values denoted by the list of subjects (items in the EVALUATE statement) are compared with the values denoted by the list of objects in a WHEN phrase to establish a “match” between the two.

• The value of a subject is compared with the value/range of values of the object in the corresponding ordinal position

• In the case of a single valued (numeric/non numeric) object, the subject – object comparison is done in the usual way

• When a range of values is specified for the object, the subject – object comparison results in TRUE, if the value of the subject falls within the range

• In the case of conditional values, the subject – object comparison results in TRUE, if both evaluate to the same value (that is if both are TRUE or both are FALSE).

• If ANY is specified for an object, the subject-object comparison always results in TRUE

• The list of subjects is said to “match” with the list of object, if all the corresponding subject – object comparisons result in true

• Note that the values of the subjects need not be of the same class. For example one can be numeric and the other can be alpha numeric

After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the EVALUATE statement. There is no need of any extra code.

1.7. Do you know?

1.7.1. Performance Considerations for Indexes VS Subscripts

• Using COMP to address a table is 30% slower than using indexes! • Using COMP-3 to address a table is 300% slower than using indexes!! • Using DISPLAY data item to address a table is 450% slower than using indexes!!!

1.7.2. Rule of the Thumb for SEARCH and SEARCH ALL

• For a table with less than 50 entries, go for SEARCH (Sequential Search) • For a table with more than 50 entries go for SEARCH ALL (Binary Search)

Page 111: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 111 -

1.7.3. Packed Decimal Using an odd number of digits for PACKED DECIMAL (COMP-3) is 5% to 20% faster than using an even number of digits!

1.8. Meaning of Device Name in SELECT Clause SELECT INFILE ASSIGN TO UT-S-INFILE OR SELECT INFILE ASSIGN TO DA-S-INFILE What they mean actually is First Part in DDNAME: Device Class UT stands for utility (Tape or sequential disk) DA stands for direct access (Disk) Second Part in DDNAMAE: Method of Organization S – Sequential (Printer, Terminal, Disk or Tape) I, R, D – Disk files to be accessed randomly

1.9. NEXT SENTENCE and CONTINUE There is a big difference between NEXT SENTENCE & CONTINUE. Please refer the test program given below WORKING-STORAGE SECTION. 01 SAMPLE PIC X(2) VALUE 'AB'. 01 SAMPLE2 PIC X(2) VALUE 'CD'. PROCEDURE DIVISION. PARA1. PERFORM PARA2. STOP RUN. PARA2. IF SAMPLE = 'AB' NEXT SENTENCE ELSE DISPLAY 'SAMPLE IS NOT AB' END-IF IF SAMPLE2 = 'CD' DISPLAY 'SAMPLE 2 IS CD' ELSE NEXT SENTENCE END-IF .

Page 112: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 112 -

In this case, we may assume that ‘SAMPLE 2 IS CD’ will get displayed but since SAMPLE is ‘AB’, NEXT SENTENCE will get executed and this will transfer control to the statement following the period so the program will move to STOP RUN. END-IF won’t act here as a statement terminator. SYSOUT will be empty in this case. It doesn’t matter whether NEXT SENTENCE is nested inside an IF statement. SYSOUT will be empty in the following program also. WORKING-STORAGE SECTION. 01 SAMPLE PIC X(2) VALUE 'AB'. 01 SAMPLE2 PIC X(2) VALUE 'CD'. 01 SAMPLE3 PIC X(2) VALUE 'EF'. PROCEDURE DIVISION. PARA1. PERFORM PARA2. STOP RUN. PARA2. IF SAMPLE = 'AB' IF SAMPLE3 = 'EF' NEXT SENTENCE END-IF ELSE DISPLAY 'SAMPLE IS NOT AB' END-IF IF SAMPLE2 = 'CD' DISPLAY 'SAMPLE 2 IS CD' ELSE NEXT SENTENCE END-IF . CONTINUE will transfer control to the end of the statement that contains ‘CONTINUE’ (remember, end of the statement may not be a period). So, for the following program 'SAMPLE 2 IS CD' will be printed in SYSOUT WORKING-STORAGE SECTION. 01 SAMPLE PIC X(2) VALUE 'AB'. 01 SAMPLE2 PIC X(2) VALUE 'CD'. PROCEDURE DIVISION. PARA1. PERFORM PARA2. STOP RUN. PARA2. IF SAMPLE = 'AB' CONTINUE ELSE DISPLAY 'SAMPLE IS NOT AB' END-IF IF SAMPLE2 = 'CD' DISPLAY 'SAMPLE 2 IS CD' ELSE CONTINUE END-IF .

Page 113: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 113 -

1.10. S0C7 Abend S0C7 abend occurs when an invalid character is present in COMP/COMP-3 /numeric field and you tried to manipulate that field by some arithmetic expressions. Let us look into the internal details. The representation scheme that we use is EBCDIC. This is an 8 byte extension to the ASCII representation. The following is the EBCDIC representation. Dec Hex ASCII EBCDIC

0 00 NUL Null NUL Null

1 01 SOH Start of Heading (CC) SOH Start of Heading

2 02 STX Start of Text (CC) STX Start of Text

3 03 ETX End of Text (CC) ETX End of Text

4 04 EOT End of Transmission (CC) PF Punch Off

5 05 ENQ Enquiry (CC) HT Horizontal Tab

6 06 ACK Acknowledge (CC) LC Lower Case

7 07 BEL Bell DEL Delete

8 08 BS Backspace (FE)

9 09 HT Horizontal Tabulation (FE)

10 0A LF Line Feed (FE) SMM Start of Manual Message

11 0B VT Vertical Tabulation (FE) VT Vertical Tab

12 0C FF Form Feed (FE) FF Form Feed

13 0D CR Carriage Return (FE) CR Carriage Return

14 0E SO Shift Out SO Shift Out

15 0F SI Shift In SI Shift In

16 10 DLE Data Link Escape (CC) DLE Data Link Escape

17 11 DC1 Device Control 1 DC1 Device Control 1

18 12 DC2 Device Control 2 DC2 Device Control 2

19 13 DC3 Device Control 3 TM Tape Mark

20 14 DC4 Device Control 4 RES Restore

21 15 NAK Negative Acknowledge (CC) NL New Line

22 16 SYN Synchronous Idle (CC) BS Backspace

23 17 ETB End of Transmission Block (CC) IL Idle

Page 114: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 114 -

24 18 CAN Cancel CAN Cancel

25 19 EM End of Medium EM End of Medium

26 1A SUB Substitute CC Cursor Control

27 1B ESC Escape CU1 Customer Use 1

28 1C FS File Separator (IS) IFS Interchange File Separator

29 1D GS Group Separator (IS) IGS Interchange Group Separator

30 1E RS Record Separator (IS) IRS Interchange Record Separator

31 1F US Unit Separator (IS) IUS Interchange Unit Separator

32 20 SP Space DS Digit Select

33 21 ! Exclamation Point SOS Start of Significance

34 22 " Quotation Mark FS Field Separator

35 23 # Number Sign, Octothorpe, "pound"

36 24 $ Dollar Sign BYP Bypass

37 25 % Percent LF Line Feed

38 26 & Ampersand ETB End of Transmission Block

39 27 ' Apostrophe, Prime ESC Escape

40 28 ( Left Parenthesis

41 29 ) Right Parenthesis

42 2A * Asterisk, "star" SM Set Mode

43 2B + Plus Sign CU2 Customer Use 2

44 2C , Comma

45 2D - Hyphen, Minus Sign ENQ Enquiry

46 2E . Period, Decimal Point, "dot" ACK Acknowledge

47 2F / Slash, Virgule BEL Bell

48 30 0 0

49 31 1 1

50 32 2 2 SYN Synchronous Idle

51 33 3 3

52 34 4 4 PN Punch On

53 35 5 5 RS Reader Stop

54 36 6 6 UC Upper Case

55 37 7 7 EOT End of Transmission

56 38 8 8

Page 115: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 115 -

57 39 9 9

58 3A : Colon

59 3B ; Semicolon CU3 Customer Use 3

60 3C < Less-than Sign DC4 Device Control 4

61 3D = Equal Sign NAK Negative Acknowledge

62 3E > Greater-than Sign

63 3F ? Question Mark SUB Substitute

64 40 @ At Sign SP Space

65 41 A A

66 42 B B

67 43 C C

68 44 D D

69 45 E E

70 46 F F

71 47 G G

72 48 H H

73 49 I I

74 4A J J ¢ Cent Sign

75 4B K K . Period, Decimal Point, "dot"

76 4C L L < Less-than Sign

77 4D M M ( Left Parenthesis

78 4E N N + Plus Sign

79 4F O O | Logical OR

80 50 P P & Ampersand

81 51 Q Q

82 52 R R

83 53 S S

84 54 T T

85 55 U U

86 56 V V

87 57 W W

88 58 X X

89 59 Y Y

90 5A Z Z ! Exclamation Point

Page 116: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 116 -

91 5B [ Opening Bracket $ Dollar Sign

92 5C \ Reverse Slant * Asterisk, "star"

93 5D ] Closing Bracket ) Right Parenthesis

94 5E ^ Circumflex, Caret ; Semicolon

95 5F _ Underline, Underscore ¬ Logical NOT

96 60 ` Grave Accent - Hyphen, Minus Sign

97 61 a a / Slash, Virgule

98 62 b b

99 63 c c

100 64 d d

101 65 e e

102 66 f f

103 67 g g

104 68 h h

105 69 i i

106 6A j j

107 6B k k , Comma

108 6C l l % Percent

109 6D m m _ Underline, Underscore

110 6E n n > Greater-than Sign

111 6F o o ? Question Mark

112 70 p p

113 71 q q

114 72 r r

115 73 s s

116 74 t t

117 75 u u

118 76 v v

119 77 w w

120 78 x x

121 79 y y

122 7A z z : Colon

123 7B { Opening Brace # Number Sign, Octothorp, "pound"

Page 117: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 117 -

124 7C | Vertical Line @ At Sign

125 7D } Closing Brace ' Apostrophe, Prime

126 7E ~ Tilde = Equal Sign

127 7F DEL Delete " Quotation Mark

128 80 Reserved

129 81 Reserved a a

130 82 Reserved b b

131 83 Reserved c c

132 84 IND Index (FE) d d

133 85 NEL Next Line (FE) e e

134 86 SSA Start of Selected Area f f

135 87 ESA End of Selected Area g g

136 88 HTS Horizontal Tabulation Set (FE) h h

137 89 HTJ Horizontal Tabulation with Justification (FE) i i

138 8A VTS Vertical Tabulation Set (FE)

139 8B PLD Partial Line Down (FE)

140 8C PLU Partial Line Up (FE)

141 8D RI Reverse Index (FE)

142 8E SS2 Single Shift Two (1)

143 8F SS3 Single Shift Three (1)

144 90 DCS Device Control String (2)

145 91 PU1 Private Use One j j

146 92 PU2 Private Use Two k k

147 93 STS Set Transmit State l l

148 94 CCH Cancel Character m m

149 95 MW Message Waiting n n

150 96 SPA Start of Protected Area o o

151 97 EPA End of Protected Area p p

152 98 Reserved q q

153 99 Reserved r r

154 9A Reserved

155 9B CSI Control Sequence Introducer (1)

156 9C ST String Terminator (2)

Page 118: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 118 -

157 9D OSC Operating System Command (2)

158 9E PM Privacy Message (2)

159 9F APC Application Program Command (2)

160 A0

161 A1

162 A2 s s

163 A3 t t

164 A4 u u

165 A5 v v

166 A6 w w

167 A7 x x

168 A8 y y

169 A9 z z

170 AA

171 AB

172 AC

173 AD

174 AE

175 AF

176 B0

177 B1

178 B2

179 B3

180 B4

181 B5

182 B6

183 B7

184 B8

185 B9 ` Grave Accent

186 BA

187 BB

188 BC

189 BD

190 BE

Page 119: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 119 -

191 BF

192 C0

193 C1 A A

194 C2 B B

195 C3 C C

196 C4 D D

197 C5 E E

198 C6 F F

199 C7 G G

200 C8 H H

201 C9 I I

202 CA

203 CB

204 CC

205 CD

206 CE

207 CF

208 D0

209 D1 J J

210 D2 K K

211 D3 L L

212 D4 M M

213 D5 N N

214 D6 O O

215 D7 P P

216 D8 Q Q

217 D9 R R

218 DA

219 DB

220 DC

221 DD

222 DE

223 DF

224 E0

Page 120: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 120 -

225 E1

226 E2 S S

227 E3 T T

228 E4 U U

229 E5 V V

230 E6 W W

231 E7 X X

232 E8 Y Y

233 E9 Z Z

234 EA

235 EB

236 EC

237 ED

238 EE

239 EF

240 F0 0 0

241 F1 1 1

242 F2 2 2

243 F3 3 3

244 F4 4 4

245 F5 5 5

246 F6 6 6

247 F7 7 7

248 F8 8 8

249 F9 9 9

250 FA

251 FB

252 FC

253 FD

254 FE

255 FF

Look into the HEX column, where numeric 1 is represented as F1 where F is actually the sequence used to represent the series. For calculation, the system will take only the lower order nibbles. In this case, it is 1. So, S0C7 will occur only when an invalid value is present

Page 121: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 121 -

in the lower order nibble. Where invalid value means not simply alphabetic characters stored in numeric field. This is because, if you try to move 1A to a numeric field, the COBOL compiler will do an automatic data conversion. 1A will be represented internally as 1A FC 11 Here the lower order nibbles contain numeric 11 so if you move 1A to a numeric filed and try to manipulate that filed, it won’t cause a S0C7 , because it contains 11. Suppose you are moving 9* to a numeric field. That will be represented internally as 9* F5 9C Now, the lower order nibbles contain an invalid character C, if you try to manipulate this field, it would cause a S0C7 abend. Look at the following program and its output DATA DIVISION. WORKING-STORAGE SECTION. 01 SAMPLE PIC X(2) VALUE '9*'. 01 SAMPLE1 PIC 9(2) COMP-3. 01 SAMPLE2 PIC 9(2). PROCEDURE DIVISION. MOVE SAMPLE TO SAMPLE1 DISPLAY SAMPLE1 ' IS SAMPLE 1:COMP-3:BEFORE COMPUTATION' MOVE SAMPLE1 TO SAMPLE2 DISPLAY SAMPLE2 ' IS SAMPLE 2:9(2):MOVED FROM COMP-3' *********THIS LINE WILL CAUSE A S0C7 ABEND************ ADD 1 TO SAMPLE1 ****************************************************** DISPLAY SAMPLE1 ' IS SAMPLE 1:COMP-3:AFTER COMPUTATION' DISPLAY SAMPLE ' IS SAMPLE: PIC X' STOP RUN This program will cause a S0C7 abend. Its output is 9Ü IS SAMPLE 1:COMP-3:BEFORE COMPUTATION 9Ü IS SAMPLE 2:9(2):MOVED FROM COMP-3 Note that DISPLAY SAMPLE1 ' IS SAMPLE 1:COMP-3:AFTER COMPUTATION' and DISPLAY SAMPLE ' IS SAMPLE: PIC X' Are not executed because just before that the program abended. This is a possible cause of S0C7 error. For more information on the causes of this error, see the description of S0C7 in QW.

Page 122: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 122 -

1.11. SEARCH and SEARCH ALL SEARCH is a serial search SEARCH ALL is a binary search and the table must be sorted before using SEARCH ALL. (ASCENDING/DESCEDING KEY clause is to be used and the data must be loaded in this order) Binary Search is search on a sorted array. Compare the item to be searched with the item at the center. If it matches, it stops the search else repeat the process with the left half or the right half depending on where the item lies. Searching order in the SEARCH ALL can be either ASCENDING or DESCENDING. ASCENDING is default. If you want the search to be done on an array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You must load the table in the specified order).

1.12. Static and Dynamic Subroutine CALLs Keep in mind as you read this that some compilers let you set options that will override the calling mechanisms shown below. Therefore, even if your program is coded to call a program statically, the compiler can convert it to the dynamic form of CALL if you set (or don't set) the correct compiler options. Such compiler options are discussed at the end of this document.

1.12.1. Static CALLs In COBOL, you normally call a subroutine like this: CALL 'A' USING arguments The static form of the CALL statement specifies the name of the subroutine as a literal; e.g., it is in quotes. This is the static form of a subroutine call. The compiler generates object code for this which will cause the linker to copy the object module a.obj into your executable when it is linked. So, if you modify "A" and recompile it, you must also relink all of the executables that call "A", because the each of the executables contains its own copy of "A".

1.12.1.1. Good things about Static CALLs

• Fewer files are needed to distribute your application because your application can be built into a single EXE file, or perhaps an EXE for your main, and a couple of DLLs

Page 123: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 123 -

for subordinate modules. This generally makes it simpler to distribute and/or upgrade your end users.

Note: A dynamic-link library (DLL) is a module that contains functions and data that can be used by another module (application or DLL).

• No risk of mixing/matching different versions of your called subroutines, because

they are bundled into your main program.

1.12.1.2. Bad things about Static CALLs

• You must relink all of the EXE and DLL files in your application that use a statically linked subroutine in order to use the newer version of the subroutine.

• If your application contains DLLs that call a subroutine statically, each DLL will

have its own copy of the subroutine, including the storage defined in the subroutine. As a result, your application uses more storage than necessary.

• If your application has multiple DLLs that use the same statically named subroutine,

each DLL has its own copy of that subroutine and its storage. Therefore, if you set a value in the subroutine in one of the DLLs, it's local to that DLL. The copy linked to the other DLLs will not know about this. This can be either a Good Thing or a Bad Thing, of course, but it's definitely a trap for the unwary.

1.12.2. Dynamic CALLs In COBOL, the dynamic form of a subroutine call is coded like this: SUBROUTINE-A PIC X(8) VALUE 'A'. . . . CALL SUBROUTINE-A USING arguments The dynamic form of the CALL statement specifies the name of the subroutine using a variable; the variable contains the name of the subroutine to be invoked. The difference is that the name of the subroutine is found in the variable SUBROUTINE-A. The compiled code will cause the operating system to load the subroutine when it is required instead of incorporating it into the executable.

Page 124: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 124 -

Note that you can also load a module dynamically by including it in a DLL and then linking it using the import library for that DLL!

1.12.2.1. Good things about Dynamic CALLs

• You don't need to relink your application if you change something in your subroutine; only the subroutine DLL needs to be relinked.

• All executables that call this subroutine will share the same DLL; both the code and

data. Since your application only loads one copy of a dynamically called subroutine, it uses less memory.

• Changes in values contained within the dynamically called subroutine are available to

all the DLLs that use it, because they all share the same copy of the subroutine.

1.12.2.2. Bad things about Dynamic CALLs

• Every dynamically called subroutine must be linked as a DLL (unless you use an import library to expose other entry points in a DLL). Therefore, if you application consists of hundreds of subroutines and they're all called dynamically, you will need to distribute hundreds of DLLs.

• It's possible to mix versions of your DLLs. This can be a problem both with

distributing your application and with end-users installing updates improperly.

• If one of your DLLs is missing, you may not know about it until the user exercises some facility that tries to call that DLL. At that point, your application will terminate abnormally unless you handle this situation.

• If you CALL a DLL, CANCEL it, then CALL it again, you incur more I/O because

the routine needs to be reloaded if you CANCEL it. This can slow down an application because it requires more disk activity

• If you mix and match static and dynamic calls to the same subroutine, your software

might have several different versions in memory at once. Guess how much fun it will be trying to debug THAT mess?

1.12.3. Which is Better Static or Dynamic? The answer is, it depends. Static subroutines are nice, because your application can be built into a single EXE file, or perhaps an EXE for your main, and a couple of DLLs for subordinate modules.

Page 125: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 125 -

Dynamic subroutines are nice because you can manage memory differently and you can update a portion of your application by shipping a newer DLL instead of the entire application. You choose static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC call). A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state.

1.13. Why READ FILE and WRITE RECORD? You READ FILE because you don’t know in advance

• Whether there actually a record to read or not • For variable or undefined length files, how long the next record will be if there is one.

You WRITE RECORD because you know in advance the answer to both of the above questions.

1.14. RETURN CODE of Internal SORT (Internal – In a COBOL Program) The return code or completion code is stored in a SORT-RETURN special register. IF SORT-RETURN = 0 (Successful completion of SORT/MERGE) IF SORT-RETURN = 16 (Unsuccessful completion of SORT/MERGE)

1.15. Efficient COBOL Coding Techniques

1.15.1. Data Types Using the proper data types is an important factor in determining the performance characteristic of an application. Some of these are discussed below

1.15.1.1. BINARY (COMP OR COMP-4) When using binary (COMP) data items, the use of the SYNCHRONIZED clause specifies that the binary data items will be properly aligned on half word, full word or double word boundaries. This may enhance the performance of certain operations on some machines.

Page 126: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 126 -

Additionally, using signed data items with eight or fewer digits produces the best code for binary items. The following shows the performance considerations (from most efficient to least efficient) for the number of digits of precision for signed binary data items (using PICTURE S9(n) COMP) n is from 1 to 8

For n from 1 to 4, arithmetic is done half word instructions where possible For n from 5 to 8, arithmetic is done in full word instructions where possible

n is from 10 to 17

Arithmetic is done in double word format

n is 9

Full word values are converted to double word format and then double word arithmetic is used (this is slower than any of the above)

n is 18

Double word values are converted to a higher precision format and then arithmetic is done using this higher precision (this is the slowest of all four binary data items)

Note: using 9 digits is slower than using 10 digits. Performance considerations for BINARY Using 1 to 8 digits is the fastest Using 10 to 17 digits is 20% to 30% slower than using 1 to 8 digits Using 9 digits is 50% slower than using 1 to 8 digits Using 18 digits is 1150% slower than using 1 to 8 digits

1.15.1.2. PACKED DECIMAL (COMP-3) When using PACKED DECIMAL (COMP-3) data items in computations use 15 or fewer digits in the picture specification to avoid the use of library routines for multiplication and division. A call to the library routine is expensive compared to the calculation in-line. Additionally, using a signed data item with an odd number of digits produces more efficient code since this uses an integral multiple of bytes in storage for the data item (Please refer the Tips and Tricks doc on COMP-3). Performance Considerations for PACKED DECIMAL Using an odd number of digits is 6% faster than using the next lower even number of digits.

Page 127: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 127 -

Using the fewest odd number of digits as possible may result in an additional 5% to 15% savings compared to using the next larger number of odd digits. When selecting your data types, it is important to understand the performance characteristics of them before you use them. Shown below are some performance considerations of doing several ADDs and SUBTRACTs on the various data types of the specified precision.

1.15.2. Comparing Data Types Performance Considerations for comparing Data Types Packed decimal (COMP-3) compared to Binary (COMP or COMP-4)

• Using 1 to 5 digits: packed decimal is 150% to 210% slower than binary • Using 6 to 8 digits: packed decimal is 220% to 260% slower than binary • Using 9 to 17 digits: packed decimal is 100% to 240% slower than binary • Using 18 digits: packed decimal is 65% faster than binary

DISPLAY compared to Packed Decimal

• Using 1 to 9 digits: DISPLAY is 60% to 95% slower than packed decimal • Using 10 to 18 digits: DISPLAY is 100% to 180% slower than packed decimal

DISPLAY compared to Binary

• Using 1 to 5 digits: DISPLAY is 350% to 480% slower than binary • Using 6 to 8 digits: DISPLAY is 500% to 570% slower than binary • Using 9 to 17 digits: DISPLAY is 300% to 725% slower than binary • Using 18 digits: DISPLAY is 10% faster than binary

1.15.3. Data Conversions Conversion to a common format is necessary for certain types of numeric operations when mixed data types are involved in the computation. This results in additional processing time and storage for these conversions. In order to minimize this overhead, it is recommended that the following guidelines should be followed. DISPLAY Avoid using USAGE DISPLAY data items for computations (especially in areas that are heavily used for computation). When a USAGE DISPLAY data item is used, additional overhead is required to convert the data item to the proper type both before and after the computation. In some cases, the conversion is done by a call to a library routine, which can be expensive compared to using the proper data type that does not require any conversion

Page 128: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 128 -

Performance considerations for DISPLAY Using 1 to 5 digits is the fastest Using 6 to 9 digits is 15% slower than using 1 to 5 digits Using 10 to 13 digits is 50% slower than using 1 to 5 digits Using 14 to 16 digits is 65% slower than using 1 to 5 digits Using 17 to 18 digits is 120% slower than using 1 to 5 digits.

1.15.4. INDEXES Vs SUBSCRIPTS Using indexes to address a table is more efficient than using subscripts since the index already contains the displacement from the start of the table and does not have to be calculated at run time. Subscripts on the other hand contain an occurrence number that must be converted to a displacement value at run time before it can be used. When using subscripts to address a table, use a binary signed data item with eight or fewer digits (for example, using PICTURE S9(8) COMP) for the data item). This will allow full word arithmetic to be used during the calculations. Additionally in some cases, using four or fewer digits for the data item may also offer some added reduction in CPU time since half word arithmetic can be used Performance Considerations for Indexes Vs Subscripts (PIC S9(8)) Using binary data items (COMP) to address a table is 56% slower than using indexes Using decimal data items (COMP-3) to address a table is 426% slower than using indexes Using DISPLAY data items to address a table is 680% slower than using indexes

1.16. Compiler options that affect run time performance

1.16.1. AWO or NOAWO The AWO compiler option causes the APPLY WRITE ONLY clause to be in effect for all physical sequential, variable length, blocked files, even if the APPLY WRITE ONLY clause is not specified in the program. With APPLY WRITE ONLY in effect, the file buffer is written to the output device when there is not enough space in the buffer for the next record. Without APPLY WRITE ONLY, the file buffer is written to the output device when there is not enough space in the buffer for the maximum size record. If the application has a large variation in the size of records to be written, using APPLY WRITE ONLY can result in a performance savings since this will generally result in fewer calls to Data Management Services to handle the I/Os. Performance Consideration using AWO One program using variable length files and AWO was 10% faster than NOAWO

Page 129: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 129 -

1.16.2. OPTIMIZE(STD), OPTIMIZE(FULL) OR NOOPTIMIZE To assist in the optimization of the code, you should use the OPTIMIZE compiler option. With the OPTIMIZE(STD) or OPTIMIZE(FULL) options in effect, you may receive optimizations that include

• Eliminating unnecessary branches • Simplifying inefficient branches • Simplifying the code for the out-of-line PERFORM statement , moving the

performed paragraphs in-line, where possible • Simplifying the code for a CALL to a contained (nested) program, moving the called

statements in-line, where possible • Eliminating duplicate computations • Eliminating constant computations • Aggregating moves of contiguous, equal sized items into a single move • Deleting unreachable code

Additionally with the OPTIMIZE(FULL) option in effect, you may also receive these optimizations

• Deleting unreferenced data items and the associated code to initialize their VALUE clauses

NOOPTIMIZE is generally used while a program is being developed when frequent compiles are necessary. NOOPTIMIZE also makes it easier to debug a program since code is not moved. NOOPTIMIZE is required when using the TEST compiler option with a value other than TEST(NONE). OPTIMIZE requires more CPU times for compiles than NOOPTIMIZE, but generally produces more efficient run time code. For production runs, OPTIMIZE is recommended. Performance Considerations using OPTIMIZE

• On the average, OPTIMIZE(STD) was 4% faster than NOOPTIMIZE, with a range of 17% faster to equivalent.

• On the average, OPTIMIZE(FULL) was equivalent to OPTIMIZE(STD)

1.16.3. SSRANGE or NOSSRANGE Using SSRANGE generates additional code, to verify that all subscripts, indexes and reference modification expressions are within the proper bounds. This inline code occurs at every reference to a subscripted or variable length data item, as well as every reference modification expression, and it can result in some degradation at run time. In general if you need to verify the subscripts only a few times in the application instead of at every reference, coding your own checks may be faster than using the SSRANGE option. For performance sensitive applications, NOSSRANGE is recommended.

Page 130: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 130 -

Performance Considerations using SSRANGE with CHECK(ON) On the average, SSRANGE was 4% slower than NOSSRANGE

1.16.4. TRUNC – BIN, STD OR OPT When using the TRUNC(BIN) compiler option, all binary (COMP) sending fields are treated as half word, full word or double word values, depending on the PICTURE clause, and code is generated to truncate all binary receiving fields to the corresponding half word, full word or double word boundary (base 2 truncation). This can add significant amount of degradation since typically some data conversion must be done, which may require the use of some library routines. BIN is usually the slowest of the three sub options for TRUNC. When using the TRUNC(STD) compiler option, the final or intermediate result of an arithmetic expression, or the sending field in the MOVE statement, is truncated to the number of digits in the PICTURE clause of the binary (COMP) receiving field (base 10 truncation). This too can add significant amount of degradation since typically the number is divided by some power of 10 (depending on the number of digits in the PICTURE clause) and the remainder is used. A divide instruction is one of the most expensive instructions. With TRUNC(OPT), the compiler assumes that the data conforms to the PICTURE and USAGE specifications and manipulates the result based on the size of the field in storage (half word, full word or double word) Performance Considerations for TRUNC

• On the average, TRUNC(OPT) was 27% faster than TRUNC(BIN) • On the average, TRUNC(STD) was 26% faster than TRUNC(BIN) • On the average, TRUNC(OPT) was 5% faster than TRUNC(STD)

1.16.5. NUMPROC – NOPFD, MIG OR PFD Using the NUMPROC(PFD) compiler option generates significantly more efficient code for numeric comparisons. It also avoids the generation of extra code that NUMPROC(NOPFD) or NUMPROC(MIG) generates for most references to COMP-3 and DISPLAY numeric data items to ensure a correct sign is being used. With NUMPROC(NOPFD), sign fix-up processing is done for all references to these numeric data items. With NUMPROC(MIG), sign fix-up processing is done only for receiving fields (and not for sending fields) of arithmetic and move statements With NUMPROC(PFD), the compiler assumes that the data has the correct sign and bypasses the sign fix-up processing

Page 131: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 131 -

Using NUMPROC(NOPFD) or NUMPROC(MIG) may also inhibit some other types of optimization. However not all external data files contain the proper sign for COMP-3 or DISPLAY signed numeric data, and hence using NUMPROC(PFD) may not be applicable for all application programs. For performance sensitive applications, NUMPROC(PFD) is recommended when possible. Performance Considerations using NUMPROC On the average, NUMPROC(PFD) was 1% faster than NUMPROC(NOPFD) On the average, NUMPROC(PFD) was 1% faster than NUMPROC(MIG) On the average, NUMPROC(MIG) was equivalent to NUMPROC(NOPFD)

1.16.6. DYNAM Or NODYNAM The DYNAM compiler option specifies that all subprograms invoked through the CALL literal statement will be loaded dynamically at run time. This allows you to share common subprograms among several different applications, allowing for easier maintenance of these subprograms since the application will not have to be re-link-edited if the subprogram is changed. DYNAM also allows you to control the use of virtual storage by giving you the ability to use a CANCEL statement to free the virtual storage used by a subprogram when the subprogram is no longer needed. However when using the DYNAM option, you pay a performance penalty since the call must go through a library routine, whereas with the NODYNAM option, the call goes directly to the subprogram. Hence the path length is longer with DYNAM than with NODYNAM. Performance Considerations Using DYNAM with CALL (Measuring CALL overhead only) On the average, for a CALL intensive application, the overhead associated with the CALL using DYNAM ranged from 80% slower to 350% slower than NODYNAM

1.16.7. RENT or NORENT Using the RENT compiler option causes the compiler to generate some additional code to ensure that the program is reentrant. Reentrant programs can be placed in shared storage like Link Pack Area (LPA) or the Extended Link Pack Area (ELPA) on MVS. Also the RENT option will allow the program to run above the 16 MB line on MVS. Producing the reentrant code may increase the execution time path length slightly. Performance considerations using RENT On the average RENT was equivalent to NORENT with a range of equivalent to 1% slower.

Page 132: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 132 -

1.17. Run Time Options that Affect Run Time Performance Selecting the proper run time options is another factor that affects the performance of a COBOL application.

1.17.1. ALL 31 The ALL31 option allows LE to take advantage of knowing that there are no AMODE(24) routines in the application. It specifies that the entire application will run in AMODE(31). This can help to improve the performance for an all AMODE(31) application because Linkage Editor can minimize the amount of mode switching across calls to common run time library routines. Performance Considerations using ALL31 (Measuring CALL overhead only) On the average, ALL31(ON) was 1% faster than ALL31(OFF)

1.17.2. CHECK The CHECK option activates the additional code generated by the SSRANGE compiler option, which requires more CPU time resources for the verification of the subscripts, indexes and reference modification expressions. Using the CHECK(OFF) run time option deactivates this code but still requires some additional CPU time resources at every use of a subscript, index or reference modification expression to determine that this check is not desired during the particular run of the program. This options has an effect only on a program that has been compiled with the SSRANGE compiler option Performance Considerations using CHECK On the average, CHECK(ON) with SSRANGE was 2% slower than CHECK(OFF) with SSRANGE

Page 133: An Introduction to Mainframes

COBL – Tips and Tricks

An Introduction to Mainframes - 133 -

1.18. Dynamic Array When a table of variable size is required, the OCCURS DEPENDING ON clause may be used Example 01 WS4-T-TABLE-FIELDS. 03 WS4-T-TABLE OCCURS 1 TO 5000 TIMES DEPENING ON Q-MAX-ENTRY INDEXED BY WS4-Y-INDX. 05 I-RATE-SHT PIC S9(03). 05 C-CALC-DEM-USGE PIC X (02). Here, depending on the value of the data name Q-MAX-ENTRY, the size of WS4-T-TABLE will be decided. It can be anything between 1 and 5000 This saves space, instead of reserving 5000 entries, it reserves only the required storage space as specified by Q-MAX-ENTRY at the run time

Page 134: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 134 -

Chapter 2

DB2 – Tips and Tricks

Page 135: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 135 -

2. DB2 – Tips and Tricks

2.1. Null Indicator To retrieve data from a nullable column, use null indicators. Syntax:

INTO :HOSTVAR:NULLIND The picture clause that should be used for the null indicator is S9(4) COMP

Meaning:

-1 : the field is null 0 : the field is not null -2 : the field value is truncated

Inserting a record with a nullable column

To insert a NULL, move -1 to the null indicator To insert a valid value, move 0 to the null indicator

2.2. DBRM Data Base Request Module, has the SQL statements extracted from the host language program by the SQL pre-compiler.

2.3. Plan A result of the BIND process - It has the executable code for the SQL statements in the DBRM. Plan is marked as invalid if the index used by it is dropped. The next time the plan is invoked, it is recreated.

2.4. Synonym Synonym is an alternate, private name for a table or view. A synonym is accessible only by the creator. Synonym is dropped when the table or tablespace is dropped

Page 136: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 136 -

2.5. Alias Alias is a locally defined name for a table or view in the same local DB2 subsystem or in a remote DB2 subsystem. Aliases give DB2 location independence because an alias can be created for a table at a remote site, thereby freeing the user from specifying the site that contains the data. Aliases can be used also as a type of global synonym. This is so because they can be accessed by anyone, not only by their creator (as is the case with synonyms)

2.6. Views View is nothing but a stored query. Views are not supported by their own, physically separate, distinguishable stored data. Instead, their definition in terms of other tables is stored in the catalog table (SYSVIEWS). For example CREATE VIEW GOOD_SUPPLIERES AS SELECT S#, STATUS, CITY FROM S WHERE STATUS > 15; When this CREATE VIEW is executed, the sub query following the AS is not executed; instead it is simply saved in the catalog, under the specified view name (GOOD-SUPPLIERS) GOOD_SUPPLIERS is in effect a “window” into the real table S. Furthermore that window is dynamic: changes to S will be automatically and instantaneously visible through that window. Likewise, changes to GOOD_SUPPLIERS will automatically and instantaneously be applied to the real table S. Consider a retrieval operation. SELECT * FROM GOOD_SUPPLIERS WHERE CITY = ‘LONDON’ ; The system handles such an operation by converting it into an equivalent operation on the underlying base table(s). In this example, the equivalent operation is SELECT S#, STATUS, CITY FROM S WHERE CITY = ‘LONDON’ AND STATUS > 15; ARE THE VIEWS UPDATABLE ? Not all of them. Some views are updatable e.g. single table view with all the fields or mandatory fields. Examples of non-updatable views are views which are joins, views that contain aggregate functions(such as MIN this is obvious).

Page 137: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 137 -

2.7. How to Run a DB2 Batch Program Use DSN utility to run a DB2 batch program. An example is shown: DSN SYSTEM(DSP3) RUN PROGRAM(EDD470BD) PLAN(EDD470BD) LIB('EDGS01T.OBJ.LOADLIB') END Use IKJEFT01 utility program to run this command in a JCL.

2.8. Why SELECT * is not preferred in embedded SQL programs? For three reasons:

• If the table structure is changed ( a field is added ), the program will have to be modified

• Program might retrieve the columns which it might not use, leading on I/O over head. • The chance of an index only scan is lost.

2.9. How does DB2 store NULL physically? High Values

2.10. Concatenate To concatenate the FIRSTNAME and LASTNAME from EMP table to give a complete name, we can use the following syntax SELECT FIRSTNAME || ‘ ‘ || LASTNAME FROM EMP;

2.11. COALESCE Function in DB2 The COALESCE function avoids the use of nulls in the result column of OUTER JOIN statements. Consider the following query SELECT EMP.EMPNO, EMP.WORKDEPT, DEPT.DEPTNAME FROM EMP FULL OUTER JOIN DEPT ON EMP.WORKDEPT = DEPT.DEPTNO;

Page 138: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 138 -

Let us say the result of this query looks as follows: EMPNO WORKDEPT DEPTNAME 3089 S12 SOFTWARE QUALITY 7654 A09 CORPORATE ADMIN .... ... TRAINING DEPT It can be seen that the TRAINING DEPT's WORKDEPT is not shown in the table because the query selects WORKDEPT from EMP, not the DEPTNO column from DEPT. This can be rectified using the COALESCE function. The COALESCE function notifies DB2 to look for a value in the listed columns, one from each table in the outer join. If this value is found in either of the table it can be returned as a result. The following example depicts the use of COALESCE SELECT EMP.EMPNO COALESCE(EMP.WORKDEPT, DEPT.DEPTNO) AS DEPTNUM, DEPT.DEPTNAME FROM EMP FULL OUTER JOIN DEPT ON EMP.WORKDEPT = DEPT.DEPTNO; The O/P for the above query would be now shown as follows... EMPNO DEPTNUM DEPTNAME 3089 S12 SOFTWARE QUALITY 7654 A09 CORPORATE ADMIN .... T01 TRAINING DEPT We can see that the COALESCE function determines that the department code is stored in the DEPT.DEPTNO column and returns that value instead of the null because there is no corresponding WORKDEPT number.

2.12. DCLGEN DeCLarations GENerator: used to create the host language copy books for the table definitions. Also creates the DECLARE table. It is not mandatory to use DCLGEN. Using DCLGEN, helps detect wrongly spelt column names etc. during the precompile stage itself (because of the DECLARE TABLE). DCLGEN being a tool would generate accurate host variable definitions for the table reducing chances of error. It not necessary to have DECLARE TABLE statement in DCLGEN - This is used by the pre-compiler to validate the table-name, view-name, column name etc.

Page 139: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 139 -

2.13. EXPLAIN EXPLAIN allows the user to obtain information regarding the optimizer’s choice of access strategy for a specified SQL statement. The information provided includes the indexes used, details of any sorts that will be needed, and (if the specified statement involves any joins) the order in which tables will be joined and the methods by which the individual joins will be performed. Such information can be useful for tuning existing applications, also for determining how projected applications will perform... Syntax EXPLAIN type FOR statement Here type is PLAN or ALL, and statement is the SQL statement to be EXPLAINEd. The output from the execution of the EXPLAIN statement is placed into a table called xyz.PLAN_TABLE, which must already exist (xyz here is the authorization ID of the user issuing the EXPLAIN). Here is an example. EXPLAIN PLAN FOR SELECT S.S#, P.P# FROM S, P WHERE S.CITY = P.CITY; When the EXPLAIN is executed, DB2 will place information regarding its implementation of the specified SELECT statement into the PLAN_TABLE of the user issuing the EXPLAIN. The user can then interrogate that table by means of ordinary select statements in order to discover, for example whether a particular index is being used or whether creating a new index might obviate the need for a sort. Before you can use EXPLAIN, a PLAN_TABLE must be created to hold the results of EXPLAIN

2.14. FETCH FIRST n ROWS ONLY Fetching a limited number of rows: FETCH FIRST n ROWS ONLY In some applications, you execute queries that can return a large number of rows, but you need only a small subset of those rows. Retrieving the entire result table from the query can be inefficient. You can specify the FETCH FIRST n ROWS ONLY clause in a SELECT statement to limit the number of rows in the result table of a query to n rows. Example: Suppose that you write an application that requires information on only the 20 employees with the highest salaries. To return only the rows of the employee table for those 20 employees, you can write a query like this:

Page 140: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 140 -

SELECT LASTNAME, FIRSTNAME, EMPNO, SALARY FROM EMP ORDER BY SALARY DESC FETCH FIRST 20 ROWS ONLY;

2.15. OPTIMIZE FOR n ROWS Minimizing overhead for retrieving few rows: OPTIMIZE FOR n ROWS When an application executes a SELECT statement, DB2 assumes that the application will retrieve all the qualifying rows. This assumption is most appropriate for batch environments. However, for interactive SQL applications, such as SPUFI, it is common for a query to define a very large potential result set but retrieve only the first few rows. The access path that DB2 chooses might not be optimal for those interactive applications. What OPTIMIZE FOR n ROWS does: The OPTIMIZE FOR n ROWS clause lets an application declare its intent to do either of these things:

• Retrieve only a subset of the result set • Give priority to the retrieval of the first few rows

DB2 uses the OPTIMIZE FOR n ROWS clause to choose access paths that minimize the response time for retrieving the first few rows. Use OPTIMIZE FOR 1 ROW to avoid sorts: You can influence the access path most by using OPTIMIZE FOR 1 ROW. OPTIMIZE FOR 1 ROW tells DB2 to select an access path that returns the first qualifying row quickly. This means that whenever possible, DB2 avoids any access path that involves a sort. If you specify a value for n that is anything but 1, DB2 chooses an access path based on cost, and you won't necessarily avoid sorts. How many rows you can retrieve with OPTIMIZE FOR n ROWS: The OPTIMIZE FOR n ROWS clause does not prevent you from retrieving all the qualifying rows. However, if you use OPTIMIZE FOR n ROWS, the total elapsed time to retrieve all the qualifying rows might be significantly greater than if DB2 had optimized for the entire result set. When OPTIMIZE FOR n ROWS is effective: OPTIMIZE FOR n ROWS is effective only on queries that can be performed incrementally. If the query causes DB2 to gather the whole result set before returning the first row, DB2 ignores the OPTIMIZE FOR n ROWS clause, as in the following situations:

• The query uses SELECT DISTINCT or a set function distinct, such as COUNT(DISTINCT C1).

• Either GROUP BY or ORDER BY is used, and no index can give the necessary ordering.

• An aggregate function and no GROUP BY clause is used. • The query uses UNION.

Page 141: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 141 -

Example: Suppose that you query the employee table regularly to determine the employees with the highest salaries. You might use a query like this: SELECT LASTNAME, FIRSTNAME, EMPNO, SALARY FROM EMP ORDER BY SALARY DESC; An index is defined on column EMPNO, so employee records are ordered by EMPNO. If you have also defined a descending index on column SALARY, that index is likely to be very poorly clustered. To avoid many random, synchronous I/O operations, DB2 would most likely use a table space scan, then sort the rows on SALARY. This technique can cause a delay before the first qualifying rows can be returned to the application. If you add the OPTIMIZE FOR n ROWS clause to the statement, DB2 will probably use the SALARY index directly because you have indicated that you expect to retrieve the salaries of only the 20 most highly paid employees. Example: The following statement uses that strategy to avoid a costly sort operation: SELECT LASTNAME,FIRSTNAME,EMPNO,SALARY FROM EMP ORDER BY SALARY DESC OPTIMIZE FOR 20 ROWS; Effects of using OPTIMIZE FOR n ROWS:

• The join method could change. Nested loop join is the most likely choice, because it has low overhead cost and appears to be more efficient if you want to retrieve only one row.

• An index that matches the ORDER BY clause is more likely to be picked. This is because no sort would be needed for the ORDER BY.

• List prefetch is less likely to be picked. • Sequential prefetch is less likely to be requested by DB2 because it infers that you

only want to see a small number of rows. • In a join query, the table with the columns in the ORDER BY clause is likely to be

picked as the outer table if there is an index on that outer table that gives the ordering needed for the ORDER BY clause.

2.16. RUNSTATS RUNSTATS is a DB2 utility to collect statistics about the data values in tables which can be used by the optimizer to decide the access path. These statistics are stored in DB2 catalog tables and is critical in determining access paths for an SQL statement.

Page 142: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 142 -

2.17. IMAGECOPY IMAGECOPY is a full backup of a DB2 table which can be used in recovery.

2.18. DECIMAL(n,m) For SQL declaration of DECIMAL(n,m), the COBOL equivalent generated is PIC S9(n-m)V9(m) COMP-3

2.19. Indicator Variable and -305 ABEND DB2 doesn’t differentiate between nulls that signify unknown data and those that signify inapplicable data. This distinction must be made by the program logic of each application. DB2 represents null in a special hidden column known as indicator variable. An indicator variable is defined to DB2 for each column that can accept nulls. The indicator variable is transparent to the end user but must be provided for when programming in a host language. Every column defined to a DB2 table must be designated as either allowing or disallowing nulls. The default definition for columns in a DB2 table is to allow nulls. Nulls can be prohibited for a column by specifying the NOT NULL or NOT NULL WITH DEFAULT option in the CREATE TABLE statement. Suppose we have the following SELECT statement EXEC SQL SELECT STATUS , CITY INTO : WS-STATUS ,: WS-CITY FROM XXXX.SAMPLE WHERE S# = 1234 END-SQL What if the SELECT statement selects exactly one record but the status value in that record happens to be null? With this select statement, we will receive -305 SQLCODE

Page 143: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 143 -

If there is a chance that the source of a retrieval operation might be null, the user should include an indicator variable in the INTO clause in addition to the normal target variable as shown below EXEC SQL SELECT STATUS , CITY INTO : WS-STATUS:WS-STATUS-IND ,: WS-CITY FROM XXXX.SAMPLE WHERE S# = 1234 END-SQL IF WS-STATUS-ID = -1 . . If the field to be retrieved is null and an indicator variable has been specified, then that indicator variable will be set to the value -1 and the ordinary target variable will remain unchanged. The indicator variable will be zero otherwise (i.e. not null). The indicator variable will be set to -2 if the null is not directly derived from a database field but is instead generated by DB2. DB2 will generate a null if an error ( for example division by zero or a data type conversion error) occurs in computing the value of some expression to be retrieved. We can solve -305 in two ways

• Change the program to handle indicator variables • Correct the db field in error

2.20. CASE Expressions The CASE Expression, introduced to DB2 in V5, is similar to CASE statements used by many popular programming languages. A CASE statement uses the value of a specified expression to select one statement among several for execution. A common application of the CASE statement will be to eliminate a multi table UNION statement; for example SELECT CREATOR, NAME, ‘TABLE’ FROM SYSIBM.SYSTABLES WHERE TYPE = ‘T’ UNION ALL SELECT CREATOR, NAME, ‘VIEW’ FROM SYSIBM.SYSTABLES WHERE TYPE = ‘V’

Page 144: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 144 -

UNION ALL SELECT CREATOR, NAME, ‘ALIAS’ FROM SYSIBM.SYSTABLES WHERE TYPE = ‘A’; Can be coded more simply as SELECT CREATOR, NAME, CASE TYPE WHEN ‘T’ THEN ‘TABLE’ WHEN ‘V’ THEN ‘VIEW’ WHEN ‘A’ THEN ‘ALIAS’ END FROM SYSIBM.SYSTABLES; When CASE is used in place of multiple UNIONs, performance most likely will be improved because DB2 will make fewer passes against the data to return a result set. In the preceding example, only one pass is required instead of three. CASE expressions enable one to do if-then-else type processing inside of SQL statements. The sequence of the CASE conditions can affect the answer. The first WHEN check that matches is the one used. There are two general flavors of the CASE expression. In the first kind, each WHEN statement does its own independent check. In the second kind, all of the WHEN conditions do similar "equal" checks against a common reference expression. First type SELECT I_ACCT_CA, C_CUST_BILL_STA AS BILL_STATUS, CASE C_CUST_BILL_STA WHEN 'PDF' THEN 'PAST DUE FINAL' WHEN 'CAN' THEN 'CANCELLED' WHEN 'COA' THEN 'CHARGED OFF' WHEN 'ACT' THEN 'ACTIVE' ELSE 'OTHER STATUS' END AS BILL_STATUS_DESC FROM DB2W1P.VCSS_CUST ORDER BY 1 Result set I BILL ACCT BILL STATUS CA STATUS DESC --------- ------ -------------- 1002539 ACT ACTIVE 1603295 ACT ACTIVE 2302772 ACT ACTIVE

Page 145: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 145 -

2402770 ACT ACTIVE 2402770 FIN OTHER STATUS 2402770 COA CHARGED OFF 2502623 ACT ACTIVE 2702608 ACT ACTIVE 3002996 ACT ACTIVE 5102952 ACT ACTIVE 5102952 PDF PAST DUE FINAL 5102952 CAN CANCELLED 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS Second type SELECT I_ACCT_CA, C_CUST_BILL_STA AS BILL_STATUS, CASE WHEN C_CUST_BILL_STA = 'PDF' THEN 'PAST DUE FINAL' WHEN C_CUST_BILL_STA = 'CAN' THEN 'CANCELLED' WHEN C_CUST_BILL_STA = 'COA' THEN 'CHARGED OFF' WHEN C_CUST_BILL_STA = 'ACT' THEN 'ACTIVE' ELSE 'OTHER STATUS' END AS BILL_STATUS_DESC FROM DB2W1P.VCSS_CUST ORDER BY 1 Result set I BILL ACCT BILL STATUS CA STATUS DESC --------- ------ -------------- 1002539 ACT ACTIVE 1603295 ACT ACTIVE 2302772 ACT ACTIVE 2402770 ACT ACTIVE 2402770 FIN OTHER STATUS 2402770 COA CHARGED OFF 2502623 ACT ACTIVE 2702608 ACT ACTIVE 3002996 ACT ACTIVE 5102952 ACT ACTIVE 5102952 PDF PAST DUE FINAL 5102952 CAN CANCELLED 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS 5102952 FIN OTHER STATUS 5303050 FIN OTHER STATUS 5303050 ACT ACTIVE

Page 146: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 146 -

Note

• If more than one WHEN condition is true, the first one processed that matches is used.

• If no WHEN matches, the value in the ELSE clause applies. If no WHEN matches and there is no ELSE clause, the result is NULL.

• There must be at least one non-null result in a CASE statement. Failing that, one of the NULL results must be inside of a CAST expression.

• All result values must be of the same type. • Functions that have an external action (e.g. RAND) can not be used in the expression

part of a CASE statement. To count the total number of rows those are PDF (Past Due Final) and CAN (Cancelled) SELECT COUNT(*) AS TOTAL_COUNT, SUM(CASE C_CUST_BILL_STA WHEN 'PDF' THEN 1 ELSE 0 END) AS PDF_COUNT, SUM(CASE C_CUST_BILL_STA WHEN 'CAN' THEN 1 ELSE 0 END) AS CAN_COUNT FROM DB2W1P.VCSS_CUST ORDER BY 1 Result set TOTAL PDF CAN COUNT COUNT COUNT ------ ----------- ----------- 402 35 18 To verify this result, see the below query SELECT COUNT(*) AS PDF_COUNT FROM DB2W1P.VCSS_CUST WHERE C_CUST_BILL_STA = 'PDF' PDF COUNT ------- 35 The CASE expression can also be used in an UPDATE statement to do any one of several alternative updates to a particular field in a single pass of the data: UPDATE STAFF SET COMM = CASE DEPT WHEN 15 THEN COMM * 1.1 WHEN 20 THEN COMM * 1.2 WHEN 38 THEN CASE

Page 147: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 147 -

WHEN YEARS < 5 THEN COMM * 1.3 WHEN YEARS >= 5 THEN COMM * 1.4 ELSE NULL END ELSE COMM END WHERE COMM IS NOT NULL AND DEPT < 50

2.21. Query Management Facility You can access QMF either through TSOA or TSOB. TSOA is test/development region and TSOB is production region. That is if you access DB2 through TSOB, you will be directly accessing production data (that is by default, the system will be pointing to production databases)

• You can set the profile by selecting PF 11 from the QMF main panel. One important setting is the CONFIRM, if you set it to YES, the system will ask for a confirmation before you delete a table/proc etc… Printer is the 4 character Printer ID installed in the Mainframe system and the user can direct the output of a query to the printer using the 4=Print option in the query panel (by PF4). Other options include Upper/Lower case, Space (the name of DB2 DATABASE or TABLESPACE in which tables will be saved by the SAVE DATA command –explained later) etc..

• Draw function enables the user to list all the fields in a table by entering the table

name in the command area (in the query panel) and by selecting the Draw option (PF 6). For example, if you enter the table name ABCD.CUSTOMER_INFO in the command line and press the PF 6 option, it will list a SELECT statement with all the fields in the table without a where clause. This option is useful when you don’t know the fields in the table. If you want to delete a line from the listing thus obtained, you can do so by selecting the line and by pressing PF 11. To insert a new line (for example to add where clause) you can place the cursor at the bottom of the query and press PF 10.

• Save Query As - You can save a query for future reference by the option SAVE

QUERY AS <query name>. Another option with saving a query is SAVE QUERY AS <query name> (SHARE = ALL). If you use this option, the query will be available to other users also. To do this, after typing the query, issue the save query as command. To View the query you have just saved, you can issue the command LIST QUERIES (OWNER = <your id>).

• Once you have saved the query, you can retrieve using LIST QUERIES (OWNER =

<your id>) from the QMF main panel. This will list all the queries under your id.

o Use DIS option to display a query o Run option to run the query o ERASE option to erase the query from the system

Page 148: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 148 -

• Forms to format the output of a query

We can use the FORM option to format the output of a QMF Query. Press PF 9 after a query has run. This will show the default form for that query. Where you can change the form and use this while running your query. A sample form is given below FORM.MAIN COLUMNS: Total Width of Report Columns: 346 NUM COLUMN HEADING USAGE INDENT WIDTH EDIT SEQ --- ---------------------------------------- ------- ------ ----- ----- --- 1 N_EMPL_INIT_TEST 2 4 C 1 2 N_EMPL_LST_RSLV 2 14 C 2 3 I_DSCRP 2 10 L 3 4 C_DSCRP_PRTY_TEST 2 5 C 4 5 N_TEST_CASE_NO 2 7 C 5 6 D_EST_DLVRY 2 10 TD 6 7 T_DSCRP_ABBR_DESC 2 40 C 7 8 T_DSCRP_DESC 2 240 C 8 *** END *** PAGE: HEADING ===> FOOTING ===> FINAL: TEXT ===> BREAK1: NEW PAGE FOR BREAK? ===> NO FOOTING ===> BREAK2: NEW PAGE FOR BREAK? ===> NO FOOTING ===> OPTIONS: OUTLINE? ===> YES DEFAULT BREAK TEXT? ===> YES 1=Help 2=Check 3=End 4=Show 5=Chart 6=Query 7=Backward 8=Forward 9= 10=Insert 11=Delete 12=Report OK, FORM is displayed. COMMAND ===> SAVE FORM AS DSCRP_FORM SCROLL ===> PAGE

Here also you can use the SHARE=Y option to make it available for all the users. Later you can use the LIST ALL option to get this form and modify it according to your requirement. The modified form can be saved by using the SAVE option. While selecting the query to run, you can specify the form option in the command line to get your display formatted according to your form (as shown below)

Page 149: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 149 -

SQL QUERY T30831.DSCRP LINE 1 SELECT N_EMPL_INIT_TEST, N_EMPL_LST_RSLV, I_DSCRP, C_DSCRP_PRTY_TEST, N_TEST_CASE_NO,D_EST_DLVRY,T_DSCRP_ABBR_DESC, T_DSCRP_DESC FROM DB27.TCSS_DSCRP *** END *** 1=Help 2=Run 3=End 4=Print 5=Chart 6=Draw 7=Backward 8=Forward 9=Form 10=Insert 11=Delete 12=Report OK, T30831.DSCRP is displayed. COMMAND ===> (F=DSCRP_FORM) SCROLL ===> PAGE

You can change the width, indent etc… with Forms More on FORMS See the output display in QMF

Page 150: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 150 -

REPORT LINE 73370 POS 1 79 N N C N T EMPL EMPL DSCRP TEST D DSCRP INIT LST I PRTY CASE EST ABBR TEST RSLV DSCRP TEST NO DLVRY DESC +----+--------------+----------+-----+-------+----------+---------------------- * 1 G 28445 1 PRODX - P35A697R-MISSING A COD -------------- * 1 G CLARK 28446 2 R2 02/28/2006 J MEMBER/C MEMBER DON' -------------- * 1 J ESTIMATED 28447 1 EMER - CHNG WRKF DEST TABLE F -------------- * 1 C SGRIMES 28448 1 R15 - STL EQPT CHG -------------- * 1 S BRYAN 28449 3 EMER 03/02/2006 CODE TABLE REQUEST -------------- * 1 M 28450 2 PRODX - PSI RATE REFUND PROCES J 28451 2 - ELEC PMCHG CD CHKER NE -------------- * 2 ============== 28,449 *** END *** 1=Help 2= 3=End 4=Print 5=Chart 6=Query 7=Backward 8=Forward 9=Form 10=Left 11=Right 12= OK, FORWARD performed. Please proceed. COMMAND ===> SCROLL ===> PAGE

Here, there is a break on the N_TEST_CASE_NO and a count on N_EMPL_LST_RSLV. This can be obtained by specifying a form shown in the next page

Page 151: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 151 -

FORM.MAIN T30831.DSCRP_FORM COLUMNS: Total Width of Report Columns: 338 NUM COLUMN HEADING USAGE INDENT WIDTH EDIT SEQ --- ---------------------------------------- ------- ------ ----- ----- --- 1 N_EMPL_INIT_TEST 1 4 C 1 2 N_EMPL_LST_RSLV COUNT 1 14 C 2 3 I_DSCRP 1 10 L 3 4 C_DSCRP_PRTY_TEST 1 5 C 4 5 N_TEST_CASE_NO BREAK1 1 7 C 5 6 D_EST_DLVRY 1 10 TD 6 7 T_DSCRP_ABBR_DESC 1 40 C 7 8 T_DSCRP_DESC 1 240 C 8 *** END *** PAGE: HEADING ===> FOOTING ===> FINAL: TEXT ===> BREAK1: NEW PAGE FOR BREAK? ===> NO FOOTING ===> BREAK2: NEW PAGE FOR BREAK? ===> NO FOOTING ===> OPTIONS: OUTLINE? ===> YES DEFAULT BREAK TEXT? ===> YES 1=Help 2=Check 3=End 4=Show 5=Chart 6=Query 7=Backward 8=Forward 9= 10=Insert 11=Delete 12=Report OK, T30831.DSCRP_FORM is displayed. COMMAND ===> SCROLL ===> PAGE

You can also change the width of a field to format the display. SUM, AVERAGE also can be used to format the output for numeric items. To list all the forms, you can use LIST FORMS or LIST FORMS (OWNER = <your id>). You can use ERASE option to delete it. Saving the output of a Query The output of a query can be saved as a table name and you can use the same in another query instead of a table. This can be done by using the option SAVE DATA AS <table name>. To view all the tables that you have saved, you can use the option LIST TABLES option from the QMF main panel.

Page 152: An Introduction to Mainframes

DB2 – Tips and Tricks

An Introduction to Mainframes - 152 -

Additional Information

• You can use wild card characters while using the LIST option. For example you can use LIST QUERIES (NAME = %WEST%). This will list all queries with ‘WEST’ in their name.

• From the QMF main panel, you can issue PF 7 to retrieve the previous commands.

Another way by which you can retrieve the previous commands is by the use of a Question mark (?) in the command line. You can use more than one question mark at the same time to skip that many commands.

• You can’t use (SHARE = Y) option with SAVE DATA AS.

• You can use the reset option to clear out the queries/results in the QMF query panel

• You can use PF 6 to refresh the LIST Object panel

• Even if you have logged on to TSOA, you can access the production version of the

data by using the CONNECT TO <db name> command in the query panel. By default, TSOA will point to the test region databases, you can use the CONNECT to make it point to the production version.

• In the QMF query panel, you can issue the EDIT command in the command line to

open up a TSO/ISPF like editor. Where you can use all the line commands to edit the queries.

• If a query is running for a long time and to cancel the same you can use Shift + Esc

key twice.

• You can give a comment with the query by prefixing it with –

• You can use the short for O instead of OWNER in LIST command

Page 153: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 153 -

Chapter 3

JCL – Tips and Tricks

Page 154: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 154 -

3. JCL – Tips and Tricks

3.1. IEBCOPY With IEBCOPY, you are able to perform any of the following

• Make a copy of a PDS or PDSE (PDSE is explained in the next section) • Merge partitioned data sets (except when unloading) • Create a sequential form of PDS or PDSE for backup or transport • Reload one or more members from a PDSU (Partitioned Data Set Unloaded – An

IEBCOPY unload data set. A sequential file that can be restored by IEBCOPY to create a PDS) into a PDS or PDSE

• Select specific members of a PDS or PDSE to be copied, loaded or unloaded • Rename selected members of a PDS or PDSE when copied • Exclude members from a data set to be copied, unloaded or loaded • Compress a PDS in place • Convert a PDS to a PDSE or a PDSE to a PDS…

Examples

3.1.1. Copy an entire PDS to another PDS //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBCOPY //********************************************************** //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.JCLS,DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.JCLS.BKUP, // DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(10,10,40)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT2 /* Here, the PDS - XXXX.JCLTEST.RIJO.JCLS will be copied to XXXX.JCLTEST.RIJO.JCLS.BKUP

Page 155: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 155 -

3.1.2. Convert a PDS to a PDSE //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBCOPY //******************************************************** //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.JCLS,DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.PDSE.JCLS, // DISP=(NEW,CATLG,DELETE), // DSNTYPE=LIBRARY, // DSORG=PO, // UNIT=TESTDA, // SPACE=(CYL,(10,10)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT2 /* Here, the PDS - XXXX.JCLTEST.RIJO.JCLS will be copied to XXXX.JCLTEST.RIJO.PDSE.JCLS where the latter will be created as a PDSE

3.1.3. You will get error if you try the following JCL //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBCOPY //********************************************************** //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.WORK.SRTINPUT,DISP=SHR, //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.WORK.SRTINPUT.BKUP, // DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(1,1)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT2 /* Where, XXXX.JCLTEST.RIJO.WORK.SRTINPUT and XXXX.JCLTEST.RIJO.WORK.SRTINPUT.BKUP are sequential data sets. The errors that are displayed are E1 8 DSS20026E DATA SET 'XXXX.JCLTEST.RIJO.WORK.SRTINPUT.BKUP' MUST BE A PDS. E2 8 DSS11046E DATA SET 'XXXX.JCLTEST.RIJO.WORK.SRTINPUT' IS NOT AN UNLOADED DATA SET.

Page 156: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 156 -

3.1.4. Unloading Copy an entire PDS to a sequential tape data set (Unloading) //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=J,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBCOPY //********************************************************* //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.JCLS,DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.JCLS.UNLOAD, // DISP=(NEW,CATLG), // UNIT=CART, // DCB=(LRECL=80,RECFM=FB,BLKSIZE=0) //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT2 /*

3.1.5. Loading Restoring unloaded copy from tape to DASD (Loading) //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=J,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBCOPY //******************************************************** //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.JCLS.UNLOAD,DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.JCLS.LOADED, // DISP=(NEW,CATLG), // UNIT=TESTDA, // SPACE=(CYL,(10,10,40),RLSE), // DCB=(LRECL=80,RECFM=FB,BLKSIZE=0) //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT2 /*

Page 157: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 157 -

3.1.6. Compressing Compressing is used to make use of the fragmented space in a PDS //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=J,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBCOPY //********************************************************* //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.JCLS,DISP=SHR //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT1 /* You need not have to worry about compressing if you are using a PDSE (please refer the section on PDSE)

3.1.7. SELECT SELECT lets you copy only selected members //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=J,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBCOPY //********************************************************************** //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.PDSE.JCLS,DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.JCLS.IEBCOPY, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(5,5,5),RLSE), // DCB=(LRECL=80,RECFM=FB,BLKSIZE=800) //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT2 SELECT MEMBER=(IEBCOPY1,IEBCOPY2,IEBCOPY3,IEBCOPY4, - IEBCOPY5,IEBCOPY6) /* //

Page 158: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 158 -

3.1.8. EXCLUDE Exclude lets you exclude few members while copying //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBCOPY //********************************************************************** //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.PDSE.JCLS,DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.JCLS.OTHERS, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(10,10,40),RLSE), // DCB=(LRECL=80,RECFM=FB,BLKSIZE=800) //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT2 EXCLUDE MEMBER=(IEBCOPY1,IEBCOPY2,IEBCOPY3,IEBCOPY4, - IEBCOPY5,IEBCOPY6) /* //

3.1.9. Rename IEBCOPY lets you rename a member while copying, see this example, IEBCOPY6 will be renamed in the new PDS - XXXX.JCLTEST.RIJO.JCLS.IEBCOPY as NEWIEBC6 //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=J,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBCOPY //**************************************************************** //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.PDSE.JCLS,DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.JCLS.IEBCOPY, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(5,5,5),RLSE), // DCB=(LRECL=80,RECFM=FB,BLKSIZE=800) //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT2 SELECT MEMBER=(IEBCOPY1,IEBCOPY2,IEBCOPY3,IEBCOPY4, IEBCOPY5,(IEBCOPY6,NEWIEBC6)) /* //

Page 159: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 159 -

3.1.10. Merging PDSs //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBCOPY //********************************************************** //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.JCLS.IEBCOPY,DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.JCLS.OTHERS,DISP=SHR //SYSUT3 DD DSN=XXXX.JCLTEST.RIJO.JCLS.ALL, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(10,10,40),RLSE), // DCB=(LRECL=80,RECFM=FB,BLKSIZE=800) //SYSIN DD * COPY INDD=(SYSUT1,SYSUT2),OUTDD=SYSUT3 /* // Here, XXXX.JCLTEST.RIJO.JCLS.IEBCOPY and XXXX.JCLTEST.RIJO.JCLS.OTHERS will be merged to a new PDS - XXXX.JCLTEST.RIJO.JCLS.ALL

3.2. IEBGENER IEBGENER is a generalized copy utility used to perform the following tasks

• Produce a backup copy of a sequential data set or a member of a PDS or PDSE • Produce a PDS or PDSE, or a member of either, from a sequential file • Produce a printed list of either sequential data sets or PDS/PDSE members • Reblock a data set or change its logical record length, etc…

Sample IEBGENER JCL //JS10 EXEC PGM=IEBGENER,REGION=1024K //SYSPRINT DD SYSOUT=* *MESSAGES //SYSUT1 DD DSN=…,DISP=… *SEQUENTIAL INPUT FILE //SYSUT2 DD DSN=…,DISP=… *OUTPUT FILE //SYSIN DD * CONTROL STATEMENTS /*

Page 160: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 160 -

Examples

3.2.1. Create a data set from in stream data //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBGENER //******************************************************************** //SYSPRINT DD SYSOUT=* //SYSIN DD DUMMY //SYSUT1 DD * AJITH TVM MCA 15000 12345678 AJAY TVM MCA 18000 11111111 ANIL TVM BTECH 15000 22222222 SAJAN TVM MCA 18000 12121212 KIRAN TVM MCA 15000 33333333 THOMAS TVM BTECH 18000 13131313 PHILIP TVM MCA 15000 21212121 MANU TVM MCA 18000 34343434 JAYA CHANDRAN TVM BTECH 15000 45544554 ARUN TVM BTECH 18000 78654321 //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.WORK.SRTINPUT, // DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //

3.2.2. Backup of a PDS/PDSE member to another PDS/PDSE This JCL lets you create a backup of a PDS/PDSE member to another PDS/PDSE //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBGENER //************************************************************* //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.PDSE.JCLS(IEBGEN2), // DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.PDSE.JCLS(IEBGEN3), // DISP=SHR, // UNIT=TESTDA, // SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD DUMMY //SYSUDUMP DD SYSOUT=*

Page 161: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 161 -

3.2.3. Backup of a sequential data set to another sequential data set This JCL lets you copy a sequential data set to another sequential data set //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBGENER //********************************************************* //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.WORK.SRTINPUT, // DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.WORK.SRTINBK, // DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD DUMMY //SYSUDUMP DD SYSOUT=*

3.2.4. Backup of a sequential data set to a member of a PDS/PDSE //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBGENER //******************************************************** //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.WORK.SRTINPUT, // DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.WORK(SRTINBK), // DISP=SHR, // UNIT=TESTDA, // SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD DUMMY //SYSUDUMP DD SYSOUT=*

Page 162: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 162 -

3.2.5. Back up copy of a PDS/PDSE member to a sequential data set //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBGENER //********************************************************* //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.WORK(SRTINBK), // DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.WORK.SRTBKUP, // DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD DUMMY //SYSUDUMP DD SYSOUT=*

3.2.6. To produce PDSE from a PDS member //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBGENER //*********************************************************** //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.WORK(SRTINBK), // DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.PDSE.WORK(SRTINBK), // DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // DSORG=PO, // DSNTYPE=LIBRARY, // SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD DUMMY //SYSUDUMP DD SYSOUT=*

Here, the PDS member XXXX.JCLTEST.RIJO.WORK(SRTINBK) will be copied to XXXX.JCLTEST.RIJO.PDSE.WORK(SRTINBK) where the latter is a new PDS and will be created as a PDSE.

Page 163: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 163 -

3.2.7. To change the block size //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBGENER //************************************************************ //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.WORK.SRTINPUT, // DISP=SHR, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.WORK.SRTINPUT.NEWBS, // DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=32000) //SYSIN DD DUMMY //SYSUDUMP DD SYSOUT=*

3.2.8. You will get error if you try the following JCL //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBGENER //********************************************************* //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.WORK, // DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.WORK.BKUP, // DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(10,10,100),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD DUMMY //SYSUDUMP DD SYSOUT=* Where, XXXX.JCLTEST.RIJO.WORK and XXXX.JCLTEST.RIJO.WORK.BKUP are PDS You will get errors like this. E1 8 DSS20027E DDNAME 'SYSUT1', DSN 'XXXX.JCLTEST.RIJO.WORK' SHOULD HAVE BEEN A PHYSICAL SEQUENTIAL DATA SET. ACTUAL DSORG IS PO. E2 8 DSS20027E DDNAME 'SYSUT2', DSN 'XXXX.JCLTEST.RIJO.WORK.BKUP' SHOULD HAVE BEEN A PHYSICAL SEQUENTIAL DATA SET. ACTUAL DSORG IS PO.

Page 164: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 164 -

3.3. PDSE A PDSE is a Partitioned Data Set Extended. It consists of a directory and zero or more members, just like a PDS. It can be created with JCL, TSO/E and ISPF just like a PDS and can be processed with the same access methods. The directory can expand automatically as needed, up to the addressing limit of 524,286 members. It also has an index which provides a fast search for member names. Space from deleted or moved members is automatically reused for new members, so you don’t have to compress a PDSE to remove wasted space. Each member of a PDSE can have up to 15,728,639 records Allocating a PDSE

3.3.1. Batch Allocation The DSNTYPE JCL Keyword specifies that a data set should be a PDSE or PDS. If DSNTYPE=LIBRARY is specified, the data set is a PDSE. If DSNTYPE=PDS is specified, the data set is a PDS //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEFBR14 //********************************************************* //SYSPRINT DD SYSOUT=* //SYSIN DD DSN=XXXX.JCLTEST.RIJO.PDSE, // DISP=(NEW,CATLG,DELETE), // DSNTYPE=LIBRARY, // UNIT=TESTDA, // SPACE=(CYL,(10,10,10)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) // When directory blocks are not specified, DSORG=PO must be included to identify the data set as partitioned //SYSIN DD DSN=XXXX.JCLTEST.RIJO.PDSE2, // DISP=(NEW,CATLG,DELETE), // DSNTYPE=LIBRARY, // DSORG=PO, // UNIT=TESTDA, // SPACE=(CYL,(10,10)),

Page 165: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 165 -

3.3.2. TSO/E Allocation

When allocating a PDSE with the TSO/E ALLOCATE command, you can specify DSNTYPE to identify the data set as PDSE or PDS. If a data set exists with the DCB attributes that you need, you can use the LIKE parameter to copy the attributes to the new PDSE ALLOC DS(‘XXXX.JCLTEST.RIJO.PDSE2’) LIKE(‘XXXX.JCLTEST.RIJO.PDSE’) The example below shows an example of allocating a PDSE using the LIKE parameter to copy the attributes of an existing PDS. Adding the DSNTYPE(LIBRARY) parameter to the allocation makes the data set PDSE. ALLOC DS(‘XXXX.JCLTEST.RIJO.PDSE3’) LIKE(XXXX.JCLTEST.RIJO.PDSE’) DSNTYPE(LIBRARY)

3.3.3. ISPF Allocation We can use the 3.2 option Data Set Name . . . : XXXX.JCLTEST.RIJO.PDSE6 Management class . . . MCTSL (Blank for default management class) Storage class . . . . SCSMS (Blank for default storage class) Volume serial . . . . TSLB90 (Blank for system default volume) ** Device type . . . . . (Generic unit or device address) ** Data class . . . . . . DCPOTSL (Blank for default data class) Space units . . . . . TRACK (BLKS, TRKS, CYLS, KB, MB, BYTES or RECORDS) Average record unit (M, K, or U) Primary quantity . . 1 (In above units) Secondary quantity 1 (In above units) Directory blocks . . 0 (Zero for sequential data set) * Record format . . . . FB Record length . . . . 80 Block size . . . . . 800 Data set name type : LIBRARY (LIBRARY, HFS, PDS, or blank) * (YY/MM/DD, YYYY/MM/DD

Page 166: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 166 -

The Data set name type field specifies whether the new data set is to be a PDSE or PDS. Specify the Data set name type field to be LIBRARY to define a PDSE. With a PDSE allocation, the Directory blocks field is optional. Creating PDSE Members Member creation for PDSE is functionally same as for a PDS. There is no functional difference between the two formats Deleting PDSE Members A member of a PDSE can be deleted through the ISPF library panel or access method services. With a JCL disposition of delete (DISP=(OLD,DELETE)), the entire data set is deleted. This is the same as for a PDS.

3.3.4. IEBCOPY TO CONVERT A PDS TO PDSE Here is an example of using IEBCOPY to convert a PDS to a PDSE. In this example, IEBCOPY retains the original PDS, creates a PDSE and copies the members of the PDS into the PDSE. The space is explicitly defined for the PDSE. You may use the LIKE parameter to get the DCB information form a PDS or PDSE //RQRIJOJB JOB (RQRIJOJ,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=IEBCOPY //******************************************************** //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=XXXX.JCLTEST.RIJO.JCLS,DISP=SHR //SYSUT2 DD DSN=XXXX.JCLTEST.RIJO.PDSE.JCLS, // DISP=(NEW,CATLG,DELETE), // DSNTYPE=LIBRARY, // DSORG=PO, // UNIT=TESTDA, // SPACE=(CYL,(10,10)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT2

3.3.5. When to use a PDSE A data set should be considered for PDSE allocation or conversion when one or more of these characteristics apply

• Frequent compresses are needed for the data set • Out of space abends occur often

Page 167: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 167 -

• A large directory leads to lengthy directory searches (PDS directory searches are sequential while PDSE searches are indexed)

• The directory size is unknown at allocation time • The directory size will grow considerably • The data set is shared for output • Members will be shared and reused many times • Protection is needed to prevent users from overwriting the directory or changing the

DCB attributes for members

3.4. (NEW, CATLG, CATLG) and a production ABEND I was surprised to see one Job abended with JCL ERR in production. This job was running successfully for years and how can it end with JCL ERR? The answer I found was very interesting. The Job abended initially with S0C3 – The return code was -911 (Deadlock or Timeout). The operations restarted the job at the abended step and it again abended with JCL ERR. I analyzed the abend and found that the problem was with the restart step. It was like this . . //JS010DB2 EXEC DB2QBTCH,REGION=8M,PROG=P35CR118,PLAN=$CSD18, // COND=(0,LT) //*BSD //******************************************************************* //* * //*---------------------- STEP: JS010DB2 ---------------------------* //* * //* PROGRAM-NUMBER : P35CR118 * //* * //* DESCRIPTION : CREATE EXTRACT FILE FOR INPUT TO DNP REPORT * //* PROGRAM P35CR121 * //* * //******************************************************************* //*ESD //OD35234O DD SYSOUT=&BUND //D35A65AO DD DSN=TEMP.&HINODE..P35CR118.D35A65A.DNPFILE, // DISP=(NEW,CATLG,CATLG), // RECFM=FB, // DSORG=PS, // LRECL=213, // SPACE=(213,(&LG))

Initially the Job abended with S0C3 in step JS010DB2 and the data set ‘TEMP.&HINODE..P35CR118.D35A65A.DNPFILE’ got created and catalogued and remained in the catalogue even after the job abended because of the (NEW, CATLG,

Page 168: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 168 -

CATLG) disposition. So when the operations restarted the job from the abended step, it ended with ‘Unable to allocate the data set TEMP.&HINODE..P35CR118.D35A65A.DNPFILE, the data set already exists in the catalogue’ So the right disposition of this data set is (NEW, CATLG, DELETE). We can use (NEW, CATLG, CATLG) in a scenario where we want to retain the datasets even if the job is abnormally terminated.

3.5. Another Production ABEND – JCL ERR I had another interesting analysis with a job flow, where Job A creates an output file, which is read by Job B, processes it and then deletes the original input file. Job B is the successor of Job A. Since Job B reads, processes and then deletes the file produced by Job A, there were no IEFBR14 steps to clear out the data sets in Job A. This is a daily sequence, where every day the Job B completes the processing done by Job A. Job A abended with JCL ERR, it was trying to allocate the output file (this is the file that is read by the Job B and then after processing subsequently deletes it) and found that the data set is already existing. I thought that the Job B might not have run the day before and caused the abend, I looked at the Job listing and found that the Job B completed successfully and it deleted the data set too. I became confused, and then the only reason can be the job A might have been submitted more than twice the day before… that also did not happen..! Albeit reluctantly, I took a backup copy of this dataset and I manually deleted the same and restarted the job and send across a mail to the distribution list…. I started cursing the machines… I started thinking that these stupid machines will behave differently at different times… After some time, I got a mail from one developer… He submitted Job A, the day before for testing purpose…without changing the production data set name that caused the creation of the production data set (the output file from A) and hence the abend… I scratched my head and this time my thought was different… that the problem was not with the machines…but with…

Page 169: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 169 -

3.6. ICETOOL ICETOOL is built on top of DFSORT. It comes up with lots of processing options. One sample JCL is shown below. //TEXTR001 JOB 00124,'TEST', // CLASS=J,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //TOOLS1 EXEC PGM=ICETOOL, // COND=(0,NE) //************************************************************ //TOOLMSG DD SYSOUT=* //DFSMSG DD SYSOUT=* //IN DD DSN=ABCD.TEST.INPUT(0), // DISP=SHR //OUT1 DD DSN=ABCD.TEST.TEXTRACT.V001, // DISP=(,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(10,10),RLSE), // DCB=(RECFM=FB,LRECL=2700) //OUT2 DD DSN=ABCD.TEST.TEXTRACT.V002, // DISP=(,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(10,10),RLSE), // DCB=(RECFM=FB,LRECL=2700) //OUT3 DD DSN=ABCD.TEST.TEXTRACT.V003, // DISP=(,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(10,10),RLSE), // DCB=(RECFM=FB,LRECL=2700) //TOOLIN DD * COPY FROM(IN) TO(OUT1) USING(CTL1) COPY FROM(IN) TO(OUT2) USING(CTL2) COPY FROM(IN) TO(OUT3) USING(CTL3) /* //CTL1CNTL DD * INCLUDE COND=(415,3,ZD,EQ,301,AND, 418,2,ZD,EQ,03,AND, 469,2,CH,EQ,C' ',AND, 1702,22,CH,EQ,C' ') OPTION STOPAFT=100 /* //CTL2CNTL DD * INCLUDE COND=(415,3,ZD,EQ,800,AND, 418,2,ZD,EQ,26,AND, 469,2,CH,EQ,C'C2',AND, 1702,22,CH,EQ,C' ') OPTION STOPAFT=100 /*

Page 170: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 170 -

//CTL3CNTL DD * INCLUDE COND=(415,3,ZD,EQ,301,AND, 418,2,ZD,EQ,03,AND, 469,2,CH,EQ,C' ',AND, 1702,22,CH,EQ,C' ') OPTION STOPAFT=100 /* //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //* This JCL copies records from ABCD.TEST.INPUT to the three OUT datasets as shown in the JCL based on the control card as specified in the COPY statement. It also does the additional processing of copying only the first 100 records satisfied by the INCLUDE COND statement

3.7. ICETOOL - count the records I had another requirement – to check whether the file contains any records. If the file is empty, I shouldn’t print that file (even if the file is empty, the printer interface will print few pages to align the printer, we wanted to avoid that), otherwise I can direct the output to the printer. The JCL will look like this //JS020SRT EXEC PGM=ICETOOL,COND=(0,LT) //TOOLMSG DD SYSOUT=* //DFSMSG DD SYSOUT=* //IN DD DISP=SHR,DSN=CY$$.P35AM084.OD35809.PRINT //OUT1 DD DSN=TEST.RIJO.P35AM084.FD35765.LABE001, // DISP=(NEW,CATLG,DELETE), // SPACE=(320,(30,10),RLSE), // AVGREC=&SIZE, // RECFM=FB, // LRECL=320 //OUT2 DD DSN=TEST.RIJO.P35AM084.FD35765.LABE002, // DISP=(NEW,CATLG,DELETE), // SPACE=(320,(30,10),RLSE), // AVGREC=&SIZE, // RECFM=FB, // LRECL=320 //OUT3 DD DSN=TEST.RIJO.P35AM084.FD35765.LABE003, // DISP=(NEW,CATLG,DELETE), // SPACE=(320,(30,10),RLSE), // AVGREC=&SIZE, // RECFM=FB, // LRECL=320

Page 171: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 171 -

//OUT4 DD DSN=TEST.RIJO.P35AM084.FD35765.LABE004, // DISP=(NEW,CATLG,DELETE), // SPACE=(320,(30,10),RLSE), // AVGREC=&SIZE, // RECFM=FB, // LRECL=320 //TOOLIN DD * COPY FROM(IN) TO(OUT1) USING(CTL1) COPY FROM(IN) TO(OUT2) USING(CTL2) COPY FROM(IN) TO(OUT3) USING(CTL3) COPY FROM(IN) TO(OUT4) USING(CTL4) /* //CTL1CNTL DD * OPTION STOPAFT=2500 /* //CTL2CNTL DD * SKIPREC=2500 OPTION STOPAFT=2500 /* //CTL3CNTL DD * SKIPREC=5000 OPTION STOPAFT=2500 /* //CTL4CNTL DD * SKIPREC=7500 /* //JS030SRT EXEC PGM=ICETOOL,COND=(0,LT) //TOOLMSG DD SYSOUT=* //DFSMSG DD SYSOUT=* //IN1 DD DISP=SHR,DSN=TEST.RIJO.P35AM084.FD35765.LABE001 //TOOLIN DD * COUNT FROM(IN1) EMPTY /* /*JOBPARM LINECT=0 //JS040DB2 EXEC DB2UBTCH,PROG=P35AM042,PLAN=DB2W1CB,COND=(0,LT) //*BSD Lots of processing is happening here, the input file CY$$.P35AM084.OD35809.PRINT will be copied to the 4 OUT files with 2500 records each and the last file will contain the left over records. That is it can contain more than 2500 records. There can be a case that the output files are empty. The COUNT option will help us to set the return code depending on the number of records in the file given in the FROM control parameter. If the file is empty, it will set the return code to 12, the next step is coded with COND=(0,LT) and it will avoid processing the empty file

3.8. SORT – modify the output record If you want to copy only a selected range of fields from the input record to the output record, you can use the following format. In this case, the output record will contain the 1:288 of the input record and the rest of the space will be blanked out

Page 172: An Introduction to Mainframes

JCL – Tips and Tricks

An Introduction to Mainframes - 172 -

//JS010SRT EXEC SORTD,COND=(0,LT) //SYSOUT DD SYSOUT=* //SORTMSG DD SYSOUT=* //* //SORTIN DD DSN=CY035.P35MR113.FD35765.LABEL,DISP=SHR //* //SORTOUT DD DSN=CY$$.T30831.FD35765.LABEL.SRT, // DISP=(NEW,CATLG,CATLG), // SPACE=(320,(30,10),RLSE), // AVGREC=K, // RECFM=FB, // LRECL=320 //SYSIN DD * SORT FIELDS=COPY OUTREC FIELDS=(1:1,288,C' ') END /*

Page 173: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 173 -

Chapter 4

DFSORT – Tips and Tricks

Page 174: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 174 -

4. DFSORT – Tips and Tricks

4.1. DFSORT Unleashed DFSORT is a program you use to sort, merge and copy information

• When you sort records, you arrange them in a particular sequence, choosing an order more useful to you than the original one

• When you merge records, you combine the contents of two or more previously sorted data sets into one.

• When you copy records, you make an exact duplicate of each record in your data set. Merging records first requires that the input data sets are identically sorted for the information you will use to merge them and they are in the same order required for output. You can merge up to 100 different data items at a time. In addition to the three basic functions, you can perform other processing simultaneously.

• You can control which record to keep in the final output data set of a DFSORT run by using INCLUDE and OMIT statements in your application. These statements work like filters, testing each record against the criteria that you supply and retaining only the ones you want for the output data set

• You can edit and reformat your records before or after other processing by using

INREC and OUTREC statements. INREC and OUTREC statements support a wide variety of reformatting tasks.

• You can sum numeric information from many records into one record with the SUM statement. For example, if you want to know the total amount of a yearly payroll, you can add the values for a field containing salaries from the records of all your employees

• You can create one or more output datasets for a sort, copy or merge application

from a single pass over one or more input data sets by using OUTFIL control statements. You can use multiple OUTFIL statements, with each statement specifying the OUTFIL processing to be performed for one or more output data sets. OUTFIL processing begins after all other processing ends

Page 175: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 175 -

4.2. A simple JCL for SORT Input AJITH TVM MCA 15000 12345678 AJAY TVM MCA 18000 11111111 ZARIN TVM BTECH 15000 22222222 SAJAN TVM MCA 18000 12121212 KIRAN TVM MCA 15000 33333333 THOMAS TVM BTECH 18000 13131313 PHILIP TVM MCA 15000 21212121 MANU TVM MCA 18000 34343434 JAYA CHANDRAN TVM BTECH 15000 45544554 ARUN TVM BTECH 18000 78654321 JCL //ABCDEFGX JOB (A123,SAMPLE),'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //STEP1 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SORTIN DD DSN=HINODE.RIJO.WORK.SRTINPUT, // DISP=SHR //SORTOUT DD DSN=HINODE.RIJO.WORK.SRTOUT, // DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD * SORT FIELDS=(1,20,A),FORMAT=CH /* Output AJAY TVM MCA 18000 11111111 AJITH TVM MCA 15000 12345678 ARUN TVM BTECH 18000 78654321 JAYA CHANDRAN TVM BTECH 15000 45544554 KIRAN TVM MCA 15000 33333333 MANU TVM MCA 18000 34343434 PHILIP TVM MCA 15000 21212121 SAJAN TVM MCA 18000 12121212 THOMAS TVM BTECH 18000 13131313 ZARIN TVM BTECH 15000 22222222

The same JCL can also be written with a control card (control statements embedded in a dataset) containing sort control statements.

Page 176: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 176 -

JCL //ABCDEFGX JOB A123,'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //STEP1 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SORTIN DD DSN=HINODE.RIJO.WORK.SRTINPUT, // DISP=SHR //SORTOUT DD DSN=HINODE.RIJO.WORK.SRTOUT3, // DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD DSN=HINODE.RIJO.JCLS(SRT2CTC), // DISP=SHR Control Card SORT FIELDS=(1,20,A),FORMAT=CH From hereafter, we will use control card instead of inline control statement

4.3. INCLUDE Control Statement

Use an INCLUDE statement if you want only certain records to appear in the output data set. The INCLUDE statement selects the records you want to include. You can specify either an INCLUDE statement or an OMIT statement in the same DFSORT run, but not both. A logical expression is one or more relational conditions logically combined, based on fields in the input record, and can be represented at a high level as follows

Page 177: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 177 -

If the logical expression is true for a particular record, the record is included in the output data set Four types of relational conditions can be used as follows

• Comparisons Compare two compare fields or a compare field and a decimal, hexadecimal, character or current date constant For example, you can compare the first 6 bytes of each record with its last 6 bytes, and include only those records in which those fields are identical or you can compare a field with today’s date and include only those records for future events

• Substring comparison tests Search for a constant within a field value or a field value within a constant For example, you can search the value in a six byte field for the character constant ‘OK’ and include only those records for which ‘OK’ is found somewhere in the field or you can search for the character constant J69 or L92 or J82 for the value in a 3 byte field, and include only those records for which J69 or J92 or J82 appears in the field.

• Bit Logic Tests Test the state (on or off) of selected bits in a binary field using a bit or hexadecimal mask or a bit constant. For example, you can include only those records which have bits 0 and 2 on in a one byte field. Or you can include only those records which have bits 3 and 12 on and bits 6 and 8 off in a 2 byte field

• Date Comparisons Compare a two digit year date field to a two digit year date constant, the current two digit year date or another two digit year date field, using the century window in effect. COND

Page 178: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 178 -

Logical expression: specifies one or more relational conditions logically combined, based on fields in the input record. If the logical expression is true for a given record, the record is included in the output data set. ALL or (ALL): Specifies that all of the input records are to be included in the output data sets. NONE or (NONE): Specifies that none of the input records are to be included in the output data sets. FORMAT

FORMAT=F can be used to specify a particular format for one or more compare fields Relational Condition The relational condition specifies that a comparison or bit logic test be performed. Relational conditions can be logically combined, with AND or OR to form a logical expression. If they are combined, the following rules apply

• AND statements are evaluated before OR statements unless parentheses are used to change the order of evaluation; expressions inside parentheses are always evaluated first (Nesting of parentheses is limited only by the amount of storage available.)

• The symbols & (AND) and | (OR) can be used instead of the words Comparisons Relational Condition Format Two formats for the relational condition can be used. Please see the picture below

Page 179: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 179 -

Comparison Operators are follows EQ Equal to NE Not equal to GT Greater than GE Greater than or equal to LT Less than LE Less than or equal to Fields p1, m1, f1: These variables specify a field in the input record to be compared either to another field in the input record or to a constant

• p1: specifies the first byte of the compare field relative to the beginning of the input record. The first data byte of a fixed length record (FLR) has relative position 1. The first data byte of a variable length record (VLR) has position 5 (because the first 4 bytes contain the record descriptor word). All compare fields must start on a byte boundary and no compare field can extend beyond byte 32752.

• m1: specifies the length of the compare field. Acceptable lengths for different formats

are given below.

• f1: specifies the format of the data in the compare field. Permissible formats are given below.

Page 180: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 180 -

p2, m2, f2: these variables specify another field in the input record with which the p1, m1,f1 field will be compared. Constants A constant can be a decimal number (n, +n, -n), character string (C’xx…xx’), or hexadecimal string (X’yy…yy’).

Page 181: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 181 -

Decimal Number Format The format for coding decimal constant is

Current Date as decimal number DATE1P, DATE2P or DATE3P can be used to generate a decimal number for the date of the run. The table below shows the decimal number generated for each current date operand along with an example. YYYY represents the year, mm represents the month (01-12), DD represents the date (01-31) and DDD represents the day of the year (001-366) Operand Constant April 19, 2001 DATE1P +YYYYMMDD +20010419 DATE2P +YYYYMM +200104 DATE3P +YYYYDDD +2001109 Character String Format The format for coding a character string constant is

The value x may be any EBCDIC character. You can specify up to 256 characters. If you want to include a single apostrophe in the character string, you must specify it as two single apostrophes. Thus Required: O’NEILL Specify: C’O’’NEILL’

Current Date as Character String DATE1, DATE1(C), DATE2, DATE2(C), DATE3, DATE3(C) and DATE4 can be used to generate a character string for the date of the run. The figure below shows the character string generated for each current date operand along with an example using (/) for (c) where relevant. YYYY represents the year, MM represents the month (01-12), DD represents the day (01-31), DDD represents the day of the year (001-366), HH represents the hour (00-23) ,

Page 182: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 182 -

MM (for time) represents the minute (00-59), SS represents the seconds (00-59) and c can be any character except a blank. Operand Constant April 19, 2001, 04:52:45 PM DATE1 C’YYYYMMDD’ C’20010419’ DATE1(C) C’YYYYCMMCDD’ C’2001/04/19’ DATE2 C’YYYYMM’ C’200104’ DATE2(C) C’YYYYCMM’ C’2001/04’ DATE3 C’YYYYDDD’ C’2001109’ DATE3(C) C’YYYYCDDD’ C’2001/109’ DATE4 C’YYYY-MM-DD-

HH.MM.SS’ C’2001-04-19-16.52.45’

Tip: When a field is shorter than the character string it is compared to, DFSORT truncates the string on the right. You can take advantage of this to compare a field to only part of the DATE4 timestamp when appropriate. For example, INCLUDE COND=(1,13,CH,GT,DATE4) Would compare the field in positions 1-13 to the truncated DATE4 constant C’YYYY-MM-DD-HH’ Hexadecimal String Format

The value yy represents any pair of hexadecimal digits. You can specify up to 256 pairs of hexadecimal digits. Because the first digit and sign are ignored in a PD0 field, you should not include the first digit or sign in a hexadecimal constant to be compared to a PD0 field. For example, 3 byte PD0 values like X’01234C’ and X’01234D’ would be equal to a hexadecimal constant of X’1234’. Padding and Truncation In a field to field comparison, the shorter compare field is padded appropriately. In a field to constant comparison, the constant is padded or truncated to the length of the compare field. Character and hexadecimal strings are padded and truncated on the right The padding characters are

• X’40’ for character string • X’00’ for hexadecimal string

Decimal constants are padded and truncated on the left. Padding is done with zeros in the proper format.

Page 183: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 183 -

Including Records in the Output Data Set – Comparison Examples Example 1

This example illustrates how to only include records in which

• The floating sign number in bytes 5 through 12 is greater than the floating sign number in bytes 13 to 20

OR

• The floating sign number in bytes 105 through 108 is less than or equal to 1000 Example 2

This example illustrates how to only include records in which

• The first 10 bytes contain STOCKHOLM (This 9 character string was padded on the right with a blank) and the zoned decimal number in bytes 21 through 28 is greater than 50000

OR

• Bytes 31 through 34 do not contain HERR Here, we have an example to select only members who have the degree MCA Input AJITH EKM MCA 15000 12345678 AJAY TVM MCA 18000 11111111 ZARIN TVM BTECH 15000 22222222 SAJAN TVM MCA 18000 12121212 KIRAN TVM MCA 15000 33333333 THOMAS TVM BTECH 18000 13131313 PHILIP EKM MCA 15000 21212121 MANU TVM MCA 18000 34343434 JAYA CHANDRAN EKM BTECH 15000 45544554 ARUN TVM BTECH 18000 78654321

Page 184: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 184 -

JCL //ABCDEFGX JOB A123,'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //STEP1 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SORTIN DD DSN=HINODE.RIJO.WORK.SRTINPUT, // DISP=SHR //SORTOUT DD DSN=HINODE.RIJO.WORK.SRTOUT2, // DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD DSN=HINODE.RIJO.JCLS(SRT2CTC), // DISP=SHR Sort Card INCLUDE COND=(38,5,CH,EQ,C'MCA') SORT FIELDS=(1,20,A),FORMAT=CH Output AJAY TVM MCA 18000 11111111 AJITH EKM MCA 15000 12345678 KIRAN TVM MCA 15000 33333333 MANU TVM MCA 18000 34343434 PHILIP EKM MCA 15000 21212121 SAJAN TVM MCA 18000 12121212

Example 3

This example illustrates how to include records in which a zoned decimal date of the form Z’yyyymmdd’ in bytes 21-28 is greater than today’s date . DATE1P generates a decimal number for the current date in the form +yyyymmdd. Substring Comparison Tests Two types of substring comparison tests are offered, as follows:

• Find a constant within a field value. For example you can search the value in a 6 byte field for the character constant C’OK’. If the field value is, for example, C’**OK**’ or C’****OK’, the relational condition is true; if the field value is C’**ERR*’, the relational condition is false

Page 185: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 185 -

• Find a field value within a constant. For example, you can search the character constant C’J69,L92,J82’ for the value in a 3 byte field. If the field value is C’J69’, C’L92’ or C’J82’, the relational condition is true; if the field value is C’X24’, the relational condition is false. Note that the comma is used within the constant to separate the valid 3-character values; any character that will not appear in the field value can be used as a separator in the constant.

Relational Condition Format Two formats for the relational condition can be used:

Substring comparison operators are as follows EQ Equal to NE Not Equal to Fields: p1,m1: These variables specify the character field in the input record for the substring test

• p1 specifies the first byte of the character input field for the substring test, relative to the beginning of the input record. The first data byte of a fixed length record has relative position 1. The first data byte of a variable length record has relative position 5 (because the first 4 bytes contain the record descriptor word). All fields to be tested must start on a byte boundary and must not extend beyond byte 32752

• m1 specifies the length of the field to be tested. The length can be 1 to 32752 bytes. Constant The constant can be a character string or a hexadecimal string

Page 186: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 186 -

If m1 is greater than the length of the constant, the field value will be searched for the constant and the condition will be true if a match is found when the EQ comparison operator is specified or if a match is not found when the NE comparison operator is specified. If m1 is smaller than the length of the constant, the constant will be searched for the field value and the condition will be true if a match is found when the EQ comparison operator is specified or if a match is not found when the NE comparison operator is specified. Substring comparison example

This example illustrates how to include only records in which

• OK is found somewhere within bytes 11 through 6010 OR

• Bytes 5 through 7 contain J69, L92 or J82 Here is an example to include only records that contain ALP or EKM or KLM in the byte positions 21 through 23 Input AJITH EKM MCA 15000 12345678 AJAY ALP MCA 18000 11111111 ZARIN TVM BTECH 15000 22222222 SAJAN KLM MCA 18000 12121212 KIRAN TVM MCA 15000 33333333 THOMAS KLM BTECH 18000 13131313 PHILIP EKM MCA 15000 21212121 MANU TVM MCA 18000 34343434 JAYA CHANDRAN KLM BTECH 15000 45544554 ARUN TVM BTECH 18000 78654321

JCL //ABCDEFGX JOB A123,'RIJO JOSEPH', // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //STEP1 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SORTIN DD DSN=HINODE.RIJO.WORK.SRTINPUT, // DISP=SHR //SORTOUT DD DSN=HINODE.RIJO.WORK.SRTOUT3,

Page 187: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 187 -

// DISP=(NEW,CATLG,DELETE), // UNIT=TESTDA, // SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSIN DD DSN=HINODE.RIJO.JCLS(SRT2CTC), // DISP=SHR Sort Card INCLUDE FORMAT=SS,COND=(21,3,EQ,C'KLM,ALP,EKM') SORT FIELDS=(1,20,A),FORMAT=CH Output AJAY ALP MCA 18000 11111111 AJITH EKM MCA 15000 12345678 JAYA CHANDRAN KLM BTECH 15000 45544554 PHILIP EKM MCA 15000 21212121 SAJAN KLM MCA 18000 12121212 THOMAS KLM BTECH 18000 13131313

4.4. Bit Logic Tests Two methods for bit logic testing are offered as follows

• Bit operator with hexadecimal or bit mask • Bit comparison tests

While any bit logic test can be specified using either of the two methods, each of them offers unique advantages not found with the other. Bit Operator Tests This method of bit logic testing allows you to test whether selected bits in a binary field are all on, all off, in a mixed on-off state, or in selected combination of these states. While this method allows you to test many different possible bit combinations with a single operation, it is less suited to determine if a field contains exactly one particular combination of on and off bits than method 2 (described below) Relational Condition Format Two formats for the relational condition can be used:

Page 188: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 188 -

Or, if the FORMAT=BI operand is used:

Page 189: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 189 -

Fields: p1,m1: These variables specify the character field in the input record for the substring test

• p1 specifies the first byte of the character input field for the substring test, relative to the beginning of the input record. The first data byte of a fixed length record has relative position 1. The first data byte of a variable length record has relative position 5 (because the first 4 bytes contain the record descriptor word). All fields to be tested must start on a byte boundary and must not extend beyond byte 32752

• m1 specifies the length of the field to be tested. The length can be 1 to 256 bytes. Mask A hexadecimal string or bit string that indicates the bits in the field selected for testing. If a mask bit is on (1), the corresponding bit in the field is tested. If a mask bit is off (0), the corresponding bit in the field is ignored. Hexadecimal String Format The format for coding hexadecimal string mask is

The value yy represents any pair of hexadecimal digits that constitute a byte. Each bit must be 1 (test bit) or 0 (ignore bit). You can specify up to 256 pairs of hexadecimal digits. Bit String Format The format for coding bit string mask is

The value bbbbbbbb represents 8 bits that constitutes a byte. Each bit must be 1 (test bit) or 0 (ignore bit). You can specify up to 256 groups of 8 bits. The total number of bits in the mask must be a multiple of 8. A bit mask string can only be used with a bit operator Padding and Truncation The hexadecimal or bit mask is truncated or padded on the right to the byte length of the binary field. The padding character is X’00’ (all bits off and thus not tested) Examples

Page 190: An Introduction to Mainframes

DFSORT – Tips and Tricks

An Introduction to Mainframes - 190 -

This example illustrates how to only include records in which Byte 27 contains ‘D’ and Byte 18 has bit 0 on

This example illustrates how to only include records in which byte 11 has some, but not all of bits 0, 5 and 7 on SORT – RECORD PROCESSING ORDER

Page 191: An Introduction to Mainframes

TSO/ISPF – Tips and Tricks

An Introduction to Mainframes - 191 -

Chapter 5

TSO/ISPF – Tips and Tricks

Page 192: An Introduction to Mainframes

TSO/ISPF – Tips and Tricks

An Introduction to Mainframes - 192 -

5. TSO/ISPF – Tips and Tricks

5.1. COBOL Compiler Version To know which version of COBOL compiler you are using, look at the first line of your compilation listing.

5.2. HRECALL To recall a dataset that has been migrated without freezing your screen, type HRECALL next to the dataset name in 3.4

5.3. TSO SEND/TRANSMIT To send short messages, use TSO SEND ‘message’ U(userid). If the person is not logged on but you want to send a message which he/she can read when he logs on , say TSO SEND ‘message’ U(userid) LOGON. To send large information, use TSO TRANSMIT.

5.4. Information about your DS To know the percentage free space and other statistics of your data set, go to option 3.1 and select I. 3.1 provides other options also.

5.5. Save a sequence of commands The commands you use regularly can be saved as a function key. For example if you often change a JCL, save it , submit it and then go to the job spool, you could save a PF key as ‘SAVE;SUB,=IOF’. To do this , type KEYS on command line and make the necessary entries.

5.6. Tape Datasets You can’t Rename/Delete a tape dataset. Only you can uncatalog it.

Page 193: An Introduction to Mainframes

TSO/ISPF – Tips and Tricks

An Introduction to Mainframes - 193 -

5.7. SB37 on Saving a DS Your PDS is out of space. Start another session, open this PDS in 3.4 and type Z next to it, it will compress your PDS. All X37 abends are out of space situations.

5.8. No space in directory If you get the above error message while creating a member in a PDS, which means your PDS can no longer accommodate more members in it. You need to increase the directory blocks. Each directory block can hold at least 4 members.

5.9. CREATE/REPLACE Suppose that you are editing your component in View mode and you want to save the changes. In such a case, you can use CREATE or REPLACE. The said example is just an instance and you can use CREATE/REPLACE for a variety of needs

5.9.1. CREATE CREATE creates a member of a PDS or a sequential dataset from the data you are editing Simplified syntax is CREATE {member} {range} Where member is the name of the new member and range is two labels that specify the group of lines, from beginning to end, which are added to the new member. Note: CREATE adds a member to a PDS only if a member of the same name doesn’t already exist. You have to specify a range of lines from the data you are editing. If you want to use the entire data you are editing, you can use the system defined labels .ZF and .ZL (stands for the first and last line) , or you can label the lines according to your needs or you can use CC/MM to select the lines. But please note the difference between CC/MM. You can specify the member in the command line or you can give CREATE .ZF .ZL and press enter, you will get the edit entry panel and you can specify the DSN. If you want to create a member in the same PDS in which the component you are editing resides, you can give CREATE .ZF .ZL NEWCMPNM

Page 194: An Introduction to Mainframes

TSO/ISPF – Tips and Tricks

An Introduction to Mainframes - 194 -

If it is in another PDS , you can give a command like CREATE .ZF .ZL ‘IPHT.XXX.YYY(ABC)’ Or CREATE .ZF .ZL (or the range that you wish), and press enter; specify the DSN in the edit entry panel

5.9.2. REPLACE The REPLACE primary command replaces a sequential data set or a member of a PDS with the data you are editing. If the member you want to replace doesn’t exist, the editor creates it. Simplified Syntax is REPLACE {member} {range} The rules for REPLACE are same as that of CREATE

5.9.3. Saving a DS in view mode You might have come across this problem several times, you might have opened the DS in view mode, made lot of changes and when you tried to save it, you might have got the error. It is possible in a different way. If you have made changes to the member in view mode, you can use REPLACE . ZF .ZL <Original Member Name> - This will replace the original member with the changes that you made to the member in view mode. As good as saving from view mode

5.10. CUT/PASTE I know you are good at it, but still The CUT primary command saves lines to one of eleven named clipboards for later retrieval by the PASTE command. The lines can be appended to the lines already saved by a previous CUT command or can replace existing lines in a clipboard. The syntax of the CUT command is CUT {line pointer range} {DEFAULT | Clipboard name} {REPLACE | APPEND} {DISPLAY} Where,

Page 195: An Introduction to Mainframes

TSO/ISPF – Tips and Tricks

An Introduction to Mainframes - 195 -

Line pointer range is Two line pointers that specify the range of lines in the current member those are to be added to or replace data in the clipboard. A line pointer can be a label or relative line number. You must specify both a starting and ending line pointer. If you do not specify a range of lines, all lines in the edit session are copied to the clipboard. E.g.: CUT .a .b Clipboard name is The name of the clipboard to use. If you omit this parameter, the ISPF default clipboard (named DEFAULT) is used. You can define up to ten additional clipboards. The size of the clipboards and number of clipboards might be limited by installation defaults. E.g.: CUT CUT1 PASTE CUT1 CUT CUT2 PASTE CUT2 REPLACE | APPEND is Specify REPLACE to replace existing data in the clipboard. Specify APPEND to add the data to the clipboard. You can select REPLACE or APPEND as the default by entering the EDITSET command on the editor command line. The default action depends on the setting specified in the panel displayed by the EDITSET. DISPLAY is Show a list of existing clipboards. From this list you can browse, edit, clear, or rename the clipboards. E.g.: CUT DISPLAY. Clipboard manager will pop up and will give the options to view, edit …

5.11. ISPF EDITOR COMMANDS

• To search for a value say ‘0980312’ stored in COMP-3 format, you can use this method

F X ‘0980312’

• To do a case sensitive search for a given search string, use this method.

Page 196: An Introduction to Mainframes

TSO/ISPF – Tips and Tricks

An Introduction to Mainframes - 196 -

Just enclose the search string within quotes and have the letter C in front of the string itself.

E.g. F C ‘FindMe’ will find all the ‘FindMe’ strings only if the case matches

• To specify the direction of search i.e., how to search for a string in the backward/

forward direction (with respect to your current cursor position)?

Direction Keyword Example Backward PREV F ‘job’ PREV finds for string ‘job’ in

backward direction Forward No need to mention

any keyword. It’s default direction

F ‘job’ finds for string ‘job’ in forward direction.

From the beginning of the file

FIRST F ‘job’ FIRST finds the first instance of sting ‘job’ in the file.

Count of all instances in file

ALL F ‘job’ ALL finds the first instance of sting ‘job’ in the file and gives total-no-of-instances of sting ‘job’ in the file.

• To search for a string that is not prefix/suffix of another word. That is to find for an

instance of a search string that is whole word by itself. To do this, you can use the following method.

• Use the keyword ‘word’ at the end of the find command. That is F job WORD will

find for the whole word job

• To go to a particular line number, we can use the following command

L ‘search string’. This is the Label command.

5.12. FLIP We use X ALL ; F ALL <text-1> frequently - and it will hide all the lines except the lines with text-1. If you want to see all those hidden lines, you can use the command FLIP; instead of giving, reset and then again X LL <text-1>

5.13. Auto complete We can have auto complete feature in ISPF like that we have while browsing the internet. Try the following.

• Go to ISPF 3.4 • Enter KEYS in the command line and press enter. The KEYS window will pop up.

Page 197: An Introduction to Mainframes

TSO/ISPF – Tips and Tricks

An Introduction to Mainframes - 197 -

• Set any key to AUTOTYPE, save and exit. For example set F4 as AUTOTYPE. • Now type any dataset partially and press the assigned PF key. • You can use the assigned PF key to get the next match.

NOTE: It will not retrieve GDGs and VSAM files

5.14. NRETRIEV This is a way of making the system remember previously typed dataset names.

• Enter KEYS in the command line, the KEYS window will popup • Set any key to NRETRIEV and exit. • Now when you are in 3.4 or which ever screen you have set the KEYS option, press

the assigned PF keys. • Pressing the assigned PF key will bring up one by one the last 30 accessed datasets

from the REFLIST.

Page 198: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 198 -

Chapter 6

VSAM – Tips and Tricks

Page 199: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 199 -

6. VSAM – Tips and Tricks VSAM is one of the access method used to process data. We all have used VSAM and may work with VSAM datasets daily, but exactly how it works and why we use it instead of other access method may seem to be a mystery.

6.1. VSAM Basics

6.1.1. VSAM Overview In the early 1970s, IBM introduced a collection of three data set organizations – sequential, indexed and direct access together with the access methods and utilities to be used on the Mainframe OS This collection of data set organizations is called the Virtual Storage Access Method (VSAM). The term virtual relates to the fact that VSAM was introduced at approximately the same time as the initial IBM virtual storage operating systems OS/VS1 and OS/VS2. VSAM was developed to replace the Indexed Sequential Access Method (ISAM), which is a much older technology. ISAM has major processing overheads which IBM wanted to improve.

6.1.2. What is VSAM? VSAM is one of several access methods that defines the technique by which data is stored and retrieved. It is GET/PUT interface used to transfer data from a Direct Access Storage Device (DASD) to an application program. VSAM doesn’t support data stored on tape. VSAM is used to organize and access data, and maintain information about this data which is stored or referenced in a catalog. VSAM data sets must be cataloged in an integrated catalog facility (ICF) structure. Records are arranged by an index key or by relative byte addressing. VSAM uses direct or sequential processing of fixed and variable length records on DASD There are two major parts to VSAM: Catalog Management and Record Management … We discussed in the previous session that there are 2 Major parts to VSAM, catalog management and record management

Page 200: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 200 -

6.1.3. Catalog Management The catalog, which contains information about the data sets, can be an ICF or a VSAM catalog. DFSMS/MVS deals only with ICF catalogs. All VSAM datasets must be defined in an ICF catalog.

6.1.4. Record Management The purpose of record management is to maintain records in a VSAM dataset for an application or a system program. Today VSAM supports five dataset organizations

• Key-sequenced dataset (KSDS) • Entry-sequenced dataset (ESDS) • Fixed-length relative record dataset (RRDS) • Variable-length relative record dataset (VRRDS) • Linear dataset (LDS)

The primary difference between the VSAM dataset organizations is the way in which their records are accessed and retrieved

6.1.5. Logical Record & Physical Record A logical record is a unit of information used to store data in a VSAM dataset. A physical record is device dependent and calculated by catalog at the time data is defined.

6.1.6. Control Interval Logical records are contained in a control interval. The fundamental building block of every component of VSAM is CI. A CI is the unit of information that VSAM transfers between the storage device and processor. One CI can be made of one or more physical blocks of DASD. A CI consists of the following.

• Logical records stored from beginning to end • Unused space, referred to as free space for data records to be inserted into or

lengthened. • Control information, which is made up of 2 types of fields; one control interval

definition field (CIDF) per CI, and one or more record definition fields (RDF) per logical record.

Page 201: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 201 -

CIDF is a 4 byte field It contains information about the length of data in CI and the amount and location of the free space RDF is a 3 byte field It describes the length of the records and how many adjacent records are of the same length The CI components and properties may vary depending on the data set organization. For example, an LDS doesn’t contain CIDF or RDFs in its CI. All of the bytes in the LDS CI are data bytes.

It may be noted that the CIDF, RDF’s, and free space are transparent to the application program. A COBOL application program processes records without knowledge of the CIDF, RDF’s, or free space.

6.1.7. More about VSAM VSAM is IBM’s latest and most advanced access method. It makes efficient use of the virtual storage of MVS, hence the name ‘Virtual Storage Access Method”. In the initial releases, it appeared to be only a replacement for the indexed sequential access method (ISAM), but as a result of continuing enhancements, it has proven to be more than just an access method. The system catalog of the MVS OS is a VSAM catalog (called the master catalog). VSAM catalogs support not only VSAM data sets, but also non VSAM data sets and generation data groups. Paging data sets in the MVS system are also VSAM data sets. The Virtual Telecommunications Access Method (VTAM) uses some of the VSAM macros. VSAM is also used as an access method for database management systems such as IMS, DB2 etc. VSAM is a high performance access method used in MVS, MVS/XA, MVS/ESA and VSE/ESA operating systems. VSAM software resides in virtual storage along with the program that needs its services for manipulation of data on a DASD

Page 202: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 202 -

AMS (Access Method Services) is a service program that helps you to allocate, maintain, and delete catalogs and data sets. It currently consists of one utility program called IDCAMS. This utility program is used in a job step just like any other utility program of OS/VS (e.g, IEBGENER, IEBCOPY, etc)

6.2. VSAM Data Sets

6.2.1. KSDS A key sequenced data set (KSDS) has a data set organization in which records are sequenced on a key field. Knowing the value of a key field, you can randomly access the logical record. A KSDS consists of two physical components on the DASD. The first one, called the data component, contains the records that hold the user data, including the key field. The second component is called the index component, and contains the key fields and pointers to the location of the record(s) to which that key field belongs Index component Data component K1 Ptr

.

.

.

Base cluster Usually, the key field is small when compared to the whole record. Therefore, the index component is a small, compact entity. It is short and can be searched quickly to find the physical location. The index and data components of KSDS organized file are jointly called a base cluster. In a KSDS, records are stored in ascending collating sequence of the prime key field. Records can be retrieved and inserted, both randomly and sequentially. Free space for

K1 <other Data Items >

Page 203: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 203 -

additional records is provided by the initial allocation of a KSDS. This space is allocated at regular intervals and is left free at the time of initial loading of the data set As a result of excessive random insertions and deletions, they eventually become physically out of sequence, although they are still in logical sequence when accessed through the index of the cluster. Keeping records in physical sequence permits more efficient sequential retrieval of records. Therefore, key sequenced data sets require occasional reorganization to put the records back into physical key sequence, although they always remain in logical key sequence. Unlike ISAM, VSAM data sets do not have an overflow component. Records can be updated in place. Also, records can be physically deleted, thus freeing space to be reused for other insertions. Records in a KSDS may be of variable length. Remember that the key field of a KSDS must be unique and that, while updating a KSDS record, its key field can’t be modified. Records of a KSDS can be accessed in a key sequence other than that of the prime key field. Such a key is called an alternate key and need not be unique.

6.2.2. ESDS The records in an ESDS (Entry Sequenced Data Set) are sequenced in the order in which they are entered in the data set. An ESDS is analogous to a physical sequential file. As in a physical sequential file, new insertions in an ESDS are always added to the end of the data set. There could be fixed or variable length records. Existing records can never be deleted. If the application wants to delete a record, it must flag that record as inactive. As far as VSAM is concerned, that record is not deleted. It is the responsibility of the application program to identify that record as deleted (invalid). Records can be updated but without length change. To change the length of a record, you must either store it at the end of the data set as a new record or override an existing record of the same length that you have flagged as inactive. A record can be accessed sequentially or directly by its RBA (Relative Byte Address – RBA is the physical location of the logical record contained in the data set. RBA is the offset of a logical record from the beginning of the data set. The first record in the VSAM data set has an RBA of zero; the second record has an RBA equal to the length of the first record, and son on. The RBA of a logical record depends only on the record’s position in the sequence of records. The RBA is always expressed as a full word binary integer (4 bytes))

• Sequential Processing: VSAM automatically retrieves records in stored sequence. Sequential processing can be started from the beginning or somewhere from the middle of the data set. In the latter case, positioning is necessary before sequential processing can be performed

Page 204: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 204 -

• Direct Processing: When a record is added or loaded, VSAM indicates its RBA. To retrieve records directly, you must supply the RBA for the record as a search argument. Although an ESDS doesn’t contain an index component, you can build an alternate index to keep track of these RBAs.

The figure below shows the format of an ESDS. Empty spaces in the CI are referred to as unused space because they can never be used. This is a result of CI internal fragmentation (spanned record is only for logical records that are greater than the CI size, we shall learn about this later)

6.2.3. RRDS In an RRDS (Relative Record Data Set), the entire data set is a string of fixed length slots. Each slot occupies a fixed position and is identified by its position relative to the first slot of the data set. The relative position of each slot is called the relative record number (RRN). An RRN is an integer that identifies the position of the slot, not the value of a particular field within the slot. Each slot of an RRDS may or may not contain a record.

Page 205: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 205 -

RRN 1 RRN 2

Record 1 Record 2 Record 3 Empty Empty Record 4 Record 5 Empty Empty

RRN 9 An RRDS has only a data component. Records in an RRDS may be inserted, retrieved, updated and deleted both sequentially and randomly. If we can develop an algorithm that establishes a relationship between a record and an RRN slot, RRDS is the fastest access method. Records in RRDS are always fixed in length. Alternate indexes are not supported on RRDS. When a record is deleted from a particular slot, the slot remains in the same physical location although a record doesn’t exist in that slot anymore. RRDS are maintenance free and do not require any reorganization. RRDS is not dependent on the physical device on which it is stored. This makes it device independent.

6.2.4. LDS An LDS is a data set which doesn’t contain control information (CIDF and RDF). All the LDS records are considered to be a long string of characters. LDS is an ESDS without any VSAM required control fields. Each record of LDS is contained in the CI. Each CI can only be 4KB long. LDS data organization is primarily used by DB2.

Page 206: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 206 -

6.3. Accessing & Inserting VSAM Data I give below the composition of a typical key sequenced data set

25 p 95 p Index SetIndexComponent

7 p 25 p 35 p 60 p 95 Sequence Set

1 10 26 40 63

2 15 Free 28 43 95

4 18 CI 30 52

7 22 35 55 FreeFree

space 25Free

space 60 Space

CI1 CI2 CI3 CI4 CI5 CI6 CI7 CI8 CI9

Control Area 1 Control Area 2 Control Area 3

Data Component

For simplicity, let’s assume that it consists of only fixed length records. Here we are respresenting a record by its key value. All the horizontal boxes represent control intervals of the index component and the vertical boxes represent control intervals within their respective control areas of the data component. The index component is further sub divided into two parts called the index set and the sequence set. These are different hierarchical levels of the index component. The sequence set is always at the lowermost level of the index and points to the control intevals of the data component. The index set consist of one to theree levels, each pointing to the next lower level until you reach the sequence set. The number of index set levels depends on the size of the file and other factors such as CI size, CA size and free space allocation. There is always only one sequence set record for each data CA. The different entries in a sequence set record point to the hightest key record in the data component control intervals. Further up in the index hierarchy, different entries in the index set record point to the hightest key record in the sequence set control interval. To understand the concepts better, let’s retrieve a record with key 52. VSAM begins its search at the highest level of the index component. It starts the comparison from the left and compares the key (52) with the leftmost key value in the index set (25). If the key is not less than or equal to the value in the index set, it makes a comparison with the next key. In the

Page 207: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 207 -

example, our key (52) is less than 95, so VSAM follows the pointer for the key 95 and reaches the appropriate sequence set record. VSAM makes the same kind o comparison within the sequence set until it finds the field in the sequence set that is greater than or equal to the key we are looking for. In this case, the sequence set field that fulfills the search is 60. VSAM follows the pointer dwonward to find the control interval of the data component where the record with the key 52 can be found. Once it locates the recod ithin the CI, the record is moved to your program. I give below the composition of a typical key sequenced data set

25 p 95 p Index SetIndexComponent

7 p 25 p 35 p 60 p 95 Sequence Set

1 10 26 40 63

2 15 Free 28 43 95

4 18 CI 30 52

7 22 35 55 FreeFree

space 25Free

space 60 Space

CI1 CI2 CI3 CI4 CI5 CI6 CI7 CI8 CI9

Control Area 1 Control Area 2 Control Area 3

Data Component

The free space given in CI may be used for the addition of records. The free CI will be used for CI split and free CA will be used if there is a CA split. Suppose we want to insert a record with the key value 5. Traversing the hierarchical chain, as we did for accessing, VSAM finds the record with key value 5 logically belongs to the first CI (CI1) of first CA. VSAM will determine that there is eneough free space to insert another record. Record 5 logically fits between records 4 and 7, so VSAM will push record 7 down to free space and place record 5 in the location perviously occupied by record 7. It will then update the RDF and CIDF information to indicate theat there is no free space left in that CI Suppose we want to add a record whose key is 20 to the above layout. VSAM determines that this record belongs to CI2 between records 18 and 22. It also determines that there is not enough free space in that CI in which to place the record. So VSAM locates a free CI (CI3) within that control area (we will see later what will happen if there is no free CI). It then

Page 208: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 208 -

moves approximately half of the records from CI2 to the newly acquired free CI. This process is called a CI Split. VSAM also updates the information in sequence set 1 to reflect the new key pointer pairs. After records 5 & 20 are added, our lay out will look like.

25 p 95 p Index SetIndexComponent

7 p 18 p 25 p 35 p 60 p 95 Sequence Set

1 10 20 26 40 63

2 15 22 28 43 95

4 18 25 30 52

5Free

spaceFree

space 35 55 Free

7Free

space 60 Space

CI1 CI2 CI3 CI4 CI5 CI6 CI7 CI8 CI9

Control Area 1 Control Area 2 Control Area 3

Data Component

Let’s see another insertion, we want to add a record with the key 45. It should logically be inserted between record keys 43 and 52 in CI5. However, ther is no free space in that CI. VSAM tries to find a free CI within CA2. Since there is no free CI in that CA as well, VSAM peforms a CA split. First it acquires a free CA within the data set. If there is no free CA available, VSAM makes a secondary space allocation of the data set, if possible, and acquire a CA from the secondary allocation. If you did not provide for secondary allocation when you defined your VSAM data set, or if a secondary allocaiton can’t be made because there is insufficient space, VSAM will inform your program of the program of the problem. In our case, a free CA is available. VSAM acquires it and moves approximately half of the records from the problem CA to the acquired CA, spreading them evenly over the new CI’s . It also updates information at the different levels of the index component, so that each key pointer pair points to the highest key element at the next lower level in the hierarchy. The process is called CA Split After inserting 45, our KSDS layout will look like the one given below.

Page 209: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 209 -

25 p 43 p 95 p Index SetIndexComponent

7 p 18 p 25 p 30 p 43 p 55 p 95 p Sequence Set

1 10 20 26 35 45 60

2 15 22 28 40 52 63

4 18 25 30 43 55 95

5Free

spaceFree

spaceFree

spaceFree

space FreeFree

spaceFree

space Free

7 CI CI

CI1 CI2 CI3 CI4 CI5 CI6 CI7 CI8 CI9

Control Area 1 Control Area 2 Control Area 3

Data Component

6.4. Alternate Index Alternate Indexes (AIX) lets us view the existing data layout in a different angle than the one provided by the unique key (unique index) Confused? We know that only if the record key (or RBA) is known can we randomly retrieve the data record. For example suppose we have a data layout with SSN, Employee number (which is also a unique field), Employee name (which is not unique) and few other details. Where SSN is the key and an index has been made out of it. What happens if it is necessary to retrieve a record by Employee number (or by Employee name) rather than SSN Suppose we have a second KSDS and each record in this data set has only two useful fields. One of the field is Employee number and the other one is SSN. Let us also suppose that the record key in our second data set is Employee number. We will have as many records in our second data set as we have in our base cluster, because, for each record in the base cluster there is a record in the second KSDS To access the record in the base cluster using Employee Number is a two step process The second data set is a KSDS, we will access the record in this data set whose key is Employee number. Once the record has been read into the I/O buffer, you will have access to the SSN, which is the other field in that record

Page 210: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 210 -

Read the employee record in the base cluster with the SSN The second data set in the above example is called an alternate index cluster, and the Employee number is called the alternate key Pictorial Representation Alternate Index Control information used by VSAM

Employee Number SSN

Base Cluster SSN Employee

Number Other Fields

Unique Alternate Key/Nonunique Alternate Key on KSDS Picture says it all. ! Base Cluster SSN Employee Number Employee Name 111 50 AAA 222 20 BBB 333 30 CCC 444 40 AAA 555 10 DDD Primary Key Alternate Key1 Alternate Key2 Unique Alternate Index Cluster – based on Alternate Key1 (which is unique) VSAM control information Employee Number SSN 10 555 20 222 30 333 40 444 50 111 Key of alternate key cluster Prime key pointers to Base

Page 211: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 211 -

Nonunique Alternate Index Cluster – based on Alternate Key2 (which is Nonunique) VSAM control information Employee Number SSN AAA 111 444 BBB 222 CCC 333 DDD 555 Key of alternate key cluster Prime key pointers to Base

6.5. PATH and AIX We have seen that accessing a record in the base cluster of a KSDS or an ESDS can be done in one of the two ways

• The record can be accessed directly from the base cluster if you know the prime key value in a KSDS, or with the RBA in an ESDS, or

• The record can be accessed through an alternate index if you know the alternate key value

In the second case, as we have seen, two distinct elements are involved; first, finding the record in the alternate index cluster throught the alternate key, thus getting the corresponding prime key or RBA; second, accessing the record in the base cluster once you know the prime key or RBA. It is clear that accessing a record through an alternate key involves more coding on the part of the programmer. It also requires two I/O areas defined in the DATA DIVISION of a COBOL program, one for accessing the alterante index cluster record and the other for accessing base cluster records. The way to avoid all this extra coding is to use AMS to define a PATH between the base cluster and the associated AIX cluster. A PATH is an entry in the VSAM catalog that establishes a logical link between an AIX cluster and a base cluster. It doesn’t contain any records; it just establishes a relationship. PATH has a name like any other dataset name Opening a data set with the path name opens both the alternate index an its associated base cluster. Then, if you want to read a record in the base cluster by using an alternate key value, it automatically finds the corresponding prime key in the alternate index. You do not have to do any coding in your program to search for the corresponindg prime key – VSAM does all the processing for you. It will appear to your program as if the base cluster is sequnced on many different alternate key fields. You can have as many different paths as you have alternate index clusters.

Page 212: An Introduction to Mainframes

VSAM – Tips and Tricks

An Introduction to Mainframes - 212 -

PATH 2 PATH 1 PATH 3 This is how you define a PATH //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=A //SYSIN DD * DEFINE PATH - (NAME(EMPLOYEE.KSDS.PATH1) - PATHENTRY(EMPLOYEE.KSDS.AIX1.CLUSTER) - UPDATE) /* // This defines a PATH between EMPLOYEE.KSDS.AIX1.CLUSTER and its base cluster EMPLOYEE.KSDS.CLUSTER

AIX 2 Base Cluster AIX 1

AIX 3

Page 213: An Introduction to Mainframes

General – Tips and Tricks

An Introduction to Mainframes - 213 -

Chapter 7

General – Tips and Tricks

Page 214: An Introduction to Mainframes

General – Tips and Tricks

An Introduction to Mainframes - 214 -

7. General – Tips and Tricks

7.1. 10 Common Abends S322 Timed out, try changing job class S806 Load module not found. Check library specified in JOBLIB S913 Insufficient authority - Check if you have required access to dataset S878 Region size is not enough. Increase the value you have specified in REGION parameter of JOB statement or in EXEC step. Or you can give REGION=0M; in this case, the system will allocate the maximum size available S522 Job cancelled by either user or operator. S0C4 Storage related problem. Check your linkage section, table definition, and FD section JCL error File attributes don’t match; For example, I have given RECFM=VB, RECLEN is same as that specified in FD section. Why do I get this error? For variable record format files you should add 4 bytes to record length in DCB

Page 215: An Introduction to Mainframes

General – Tips and Tricks

An Introduction to Mainframes - 215 -

S0C7 Invalid character in COMP/COMP-3 numeric field – check all COMP/COM-3 numeric fields and arithmetic operations. S013 A file open error S722 The Sysout or spool is full. You program is writing too many things to Sysout. Increase job’s Sysout limit by specifying ‘LINES=(150,WARNING)’ option in job statement and then retry. This will increase your Sysout limit to ‘150’ thousand lines.

7.2. Comparing 2 files of different layouts If you want to compare 2 files of different layouts you can use this form of 3.13 Suppose you want to compare the 2978:2979 (start_column:stop_column) of the new file with the 1565:1566 (start_column:stop_column - 2 Chars) of the old file, then here is the option that you may use. Select 3.13 Give new and old DSNs Point to the Options in the menu bar and press enter Select Edit Statements (1) option Give the options like this CMPCOLMN 2978:2979 CMPCOLMO 1565:1566 The resulting JCL will look like this //RQ123JOB JOB (00124,'SUPERC'),RJOSEPH, // CLASS=A,MSGCLASS=Z,REGION=0M,NOTIFY=&SYSUID //SUPERC EXEC PGM=ISRSUPC, // PARM=(CHNGL,WORDCMP, // '', // '') //NEWDD DD DSN=ISPS.RJOSEPH.RIJO.WORK(COMP1), // DISP=SHR //OLDDD DD DSN=ISPS.RJOSEPH.RIJO.WORK(COMP2), // DISP=SHR

Page 216: An Introduction to Mainframes

General – Tips and Tricks

An Introduction to Mainframes - 216 -

//OUTDD DD SYSOUT= * //SYSIN DD * CMPCOLMN 2978:2979 CMPCOLMO 1565:1566 /* Note: While comparing using CMPCOLM/ CMPCOLMN / CMPCOLMO, you can’t give file compare; you can give either line compare or word compare You can either submit the Comparison operation as online or batch.

7.3. Counting the number of records

7.3.1. Tape Data Set Suppose that the LRECL is 100 bytes, the block size is 1000 bytes then, if we know the block count, we can find the approximate number of records in the tape dataset by the following calculation Number of records = (Block size * Block count) / (Record size). In the above case, if we have only 10 blocks, then Number of records = (1000* 10)/100 = 100 This is an approximate value because, the last block may not be full. Note: To get the block count and all the details regarding the tape data set, you can use the V1.8 option (file aid) Select V1.8/Select option 1 and give password as user. Give DSN in the option ‘Inquire/update TMC record by Data Set Name’ without quotes/Press enter. This would work for data sets that are not archived.

7.3.2. DASD Data Set Suppose the allocation for a DASD data set is (TRK(10,2)). We have the following information

Page 217: An Introduction to Mainframes

General – Tips and Tricks

An Introduction to Mainframes - 217 -

1 Cylinder = 15 Tracks 1 Track = 56,664 bytes In the above case, the maximum number of records that can be stored is The total space allocation in the above case is 10+15*2 = 40 Tracks. That is 40 * 56,664 bytes Suppose that the LRECL is 80 bytes. Then the maximum number of records that can be stored is = (40 * 56664)/80 = 28332

7.4. Processing Options in IMS DB

7.4.1. DEFINING THE IMS DATABASE In the IMS, this takes the form of a Data Base Description (DBD) step. In this step, one defines a Data Base Description (DBD), which is processed, and the resulting information is maintained in an IMS library A DBD describes the complete structure of a database. An installation must create one DBD for each DL/I database Although each database has a single physical structure that’s defined by a DBD, the application programs that process it can have different views of it. These views, also called application data structures, specify the databases (one or more) a program can access, the data elements the program can “see” in those databases, and the processing the program can do. This information is specified in a PSB (Program Specification Block) The DBA codes the assembler language statements necessary to define a DBD or PSB, then assembles and links them, storing the resulting load module in a PDS. This process is called control block generation; generating a DBD is usually called a DBDGEN, and generating a PSB is called PSBGEN.

Page 218: An Introduction to Mainframes

General – Tips and Tricks

An Introduction to Mainframes - 218 -

Let us consider an Inventory Database The structure of the database is DBD DBD NAME = INDBD * SEGM NAME = INVENSEG, PARENT=0, BYTES = 63 FIELD NAME = (INVENCOD, SEQ), BYTES = 3, START = 1, TYPE = C FIELD NAME = INVENNAM, BYTES = 30, START = 4, TYPE = C FIELD NAME = INVENADR, BYTES = 30, START = 34, TYPE = C * SEGM NAME = INITMSEG, PARENT=INVENSEG, BYTES = 44 FIELD NAME = (INITMNUM, SEQ), BYTES = 5, START = 1, TYPE = C FIELD NAME = INITMDES, BYTES = 35, START = 6, TYPE = C FIELD NAME = INITMPRC, BYTES = 4, START = 41, TYPE = P * SEGM NAME = INLOCSEG, PARENT=INITMSEG, BYTES = 44 FIELD NAME = (INLOCLOC, SEQ), BYTES = 3, START = 1, TYPE = C FIELD NAME = INLOCONH, BYTES = 4, START = 4, TYPE = P FIELD NAME = INLOCROP, BYTES = 4, START = 8, TYPE = P FIELD NAME = INLOCONO, BYTES = 4, START = 12, TYPE = P FIELD NAME = INLOCDAT, BYTES = 6, START = 16, TYPE = C *

VENDOR

ITEM

LOCATION

Page 219: An Introduction to Mainframes

General – Tips and Tricks

An Introduction to Mainframes - 219 -

PSB The first macro in the PSBGEN job stream is PCB (Program Communication Block). The PCB describes one database. A PSBGEN job contains one PCB macro for each database the application program can access A sample PSB for the above DBD is given below PCB TYPE = DB, DBDNAME = INDBD, KEYLEN = 11, PROCOPT = LS SENSEG NAME = INVENSEG SENSEG NAME = INITMSEG, PARENT = INVENSEG SENSEG NAME = INLOCSEG, PARENT = INITMSEG The KEYLEN parameter specifies the length of the longest concatenated key the program can process in the database PROCOPT specifies the program’s processing options. They indicate what processing the program is allowed to perform on the database LS indicate that the program can perform only load operations The DBA can code the PROCOPT parameter on the SENSEG macro to control access to the database more selectively than is possible at the database level PCB TYPE = DB, DBDNAME = INDBD, KEYLEN = 11 SENSEG NAME = INVENSEG, PROCOPT = K SENSEG NAME = INITMSEG, PARENT = INVENSEG, PROCOPT = K SENSEG NAME = INLOCSEG, PARENT = INITMSEG, PROCOPT = G This means that the user may not access the data within this segment but may use it only for traversal of the hierarchy. A PROCOPT of K indicates that key sensitivity only. A GN call with no SSAs can access only data sensitive segments. If a key sensitive segment is designated for retrieval in an SSA, the segment is not moved to the user’s I/O area. The key is placed at the appropriate offset in the key feedback area of the PCB. If there is a difference in the processing options specified on the PCB and SENSEG statements and the options are compatible, SENSEG PROCOPT overrides the PCB PROCOPT

7.4.2. IMS DL/I DATA BASE TYPES During installation, the database administrator (DBA) chooses the type of database to use for the IMS-DL/I databases. The DBA decides which type of database to use based on how most of the programs that use an IMS-DL/I database will access the data in the database. The following is a list of database types that the DBA can use to define an IMS-DL/I database

Page 220: An Introduction to Mainframes

General – Tips and Tricks

An Introduction to Mainframes - 220 -

Data Entry Data Base (DEDB) It is a direct-access database that consists of one or more areas, with each area containing both root segments and dependent segments. The database is accessed using VSAM improved control interval processing (ICIP). Main Storage Data Base (MSDB) It is a root-segment database, residing in main storage, which can be accessed to a field level. Hierarchical Direct Access Method (HDAM) It is one of DL/I's two direct-access methods. A direct-access method allows DL/I to locate any database record, regardless of the record sequence in the database, by using a randomizing routine or an index. HDAM provides direct access to data through a randomizing routine. Sequentially accessing an HDAM database, DL/I retrieves data in the order that the data are physically stored in the database. Hierarchical Indexed Direct Access Method (HIDAM) It is one of DL/I's two direct-access methods. HIDAM provides direct access to data through an index. Hierarchical Sequential Access Method (HSAM) It is one of DL/I's sequential-access methods. In a sequential-access database, segments are stored in a hierarchical sequence, one segment after another. HSAM provides sequential access to root segments and dependent segments. You can access data in HSAM databases, but you cannot update any of the data. Hierarchical Indexed Sequential Access Method (HISAM) You can processes data sequentially, but it has an index that enables you to directly access records in the database. Generalized Sequential Access Method (GSAM) It allows IMS/ESA batch application programs to access a sequential OS/390 data set record that is defined as a database record. This database record is handled as one unit, with no segments, fields, or hierarchical structure. Any records to be added are inserted at the end of the database. GSAM does not allow you to update or delete records in the database. Simple Hierarchical Sequential Access Method (SHSAM) It is an HSAM database that contains only one segment type, a root segment. Only two types of calls are valid with SHSAM databases: Get calls to read a database and Insert calls to load a database. You must reload a database in order to update it.

Page 221: An Introduction to Mainframes

General – Tips and Tricks

An Introduction to Mainframes - 221 -

Simple Hierarchical Indexed Sequential Access Method (SHISAM) It is a HISAM database with only one segment type, a root segment.

7.4.3. PROCOPT It is the parameter keyword for the processing options on sensitive segments declared in the PCB that you can use in an associated application program. G Get Function I Insert Function R Replace Function, Includes G. D Delete Function, Includes G. A All, includes the above four functions. PROCOPT = A is the default setting P Required if command code D is to be used O If the O option is used for a PCB, IMS doesn’t check the ownership of the segments returned. Therefore, the read without integrity program might get a segment that has been updated by another program. If the updating program abends and backs out, the read without integrity program will have a segment that doesn’t exist in the database and never did. N Reduces the number of abends that read only application programs are subject to. Read only application programs can reference data being updated by another application program. When this happens, an invalid pointer to the data might exist. If an invalid pointer is detected, the read only application program abends. By specifying N, you avoid this. A GG status code

Page 222: An Introduction to Mainframes

General – Tips and Tricks

An Introduction to Mainframes - 222 -

is returned to the program instead. The program must determine whether to terminate processing, continue processing by reading a different segment, or access the data using a different path. T T is the same as the N operand, except that T causes DL/I to automatically retry the operation. If the retry fails, a GG status code is returned to the application program. E Enables exclusive use of the database or segment by online programs L Load function for database loading (except HIDAM) GS Get Segments in ascending sequence only (HSAM only). If you specify GS for HSAM databases, they will be read using the Queued Sequential Access Method (QSAM) instead of the Basic Sequential Access Method (BSAM) in a DL/I IMS region. LS Segments loaded in ascending sequence only (HIDAM, HDAM). This load option is required for HIDAM. Because you must specify LS for HIDAM databases, the index for the root segment sequence field will be created at the time the database is loaded H Specifies high speed sequential processing for the application program using a particular PSB. The restrictions for using PROCOPT = H are

It can be used for DEDBs only It is allowed on the PCB level and not on the segment level. It must be used with other Fast Path Processing options A maximum of four PROCOPT options can be specified, including H It can only be specified for BMP s Only one PROCOPT = H PCB per database is allowed

If you don’t specify the PROCOPT operand, it defaults to PROCOPT = A. The replace and delete functions also imply the get function * In a non-terminal related or fixed terminal related MSDB, only the processing options G and R are valid

Page 223: An Introduction to Mainframes

General – Tips and Tricks

An Introduction to Mainframes - 223 -

In a dynamic terminal-related MSDB, the processing options G, I, R, D, A or any combination of G, I, R and D are valid In a DEDB, the processing options G, I, R, D, A, P, N, T, O and H are valid

Page 224: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 224 -

Chapter 8

ISPF Editor Commands

Page 225: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 225 -

8. ISPF Editor Commands Though we are using ISPF editor everyday, most of us don’t know many of the commands. This is aimed at showing you few of the ISPF commands which are useful for your day to day activities. This is not the complete list. I ignored the most frequently used commands

8.1. < - Data Shift Left Moves the body of a program statement to the left without shifting the label or comments (from the first position to the position that contains more than one blank is treated as a block and only that block is moved. The portion beyond that blank area is not moved)

8.2. > - Data Shift Right Moves the body of a program statement to the right without shifting the label or comments (from the first position to the position that contains more than one blank is treated as a block and only that block is moved. The portion beyond that blank area is not moved)

8.3. ( - Column Shift Left Moves characters on a line to the left without altering their relative spacing- characters shifted past the current BOUNDS (we will see this later) are deleted

8.4. ) - Column Shift Right Moves characters on a line to the right without altering their relative spacing- characters shifted past the current BOUNDS (we will see this later) are deleted Note: in all the above 4 cases, <<, >>, ((and )) can be used to move a block of lines To understand the difference, see the original position of the following 000028 37,3,CH,EQ,C'AOS', OR, 000029 37,3,CH,EQ,C'GC ', OR, 000030 37,3,CH,EQ,C'BNK', OR, 000031 37,3,CH,EQ,C'CVR', OR, 000032 37,3,CH,EQ,C'EDR',OR, 000033 37,3,CH,EQ,C'MJC',OR, 000034 37,3,CH,EQ,C'OEC',OR,

Page 226: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 226 -

I am applying the shift operators as shown below 0000(( 37,3,CH,EQ,C'AOS', OR, 0000(( 37,3,CH,EQ,C'GC ', OR, 0000<< 37,3,CH,EQ,C'BNK', OR, 0000<< 37,3,CH,EQ,C'CVR', OR, 000032 37,3,CH,EQ,C'EDR',OR, 000033 37,3,CH,EQ,C'MJC',OR, 000034 37,3,CH,EQ,C'OEC',OR, After pressing enter 000028 37,3,CH,EQ,C'AOS', OR, 000029 37,3,CH,EQ,C'GC ', OR, 000030 37,3,CH,EQ,C'BNK', OR, 000031 37,3,CH,EQ,C'CVR', OR, 000032 37,3,CH,EQ,C'EDR',OR, 000033 37,3,CH,EQ,C'MJC',OR, 000034 37,3,CH,EQ,C'OEC',OR, See, the << command treated the sequence of characters till the position that contained more than one blank as a block and it ignored the area after that whereas the (( command moved the line to the left without altering the relative spacing

8.5. AUTOSAVE ON : When you enter END, any changed data is saved OFF PROMPT : You are notified that changes have been made and that either the

SAVE command or the CANCEL command must be used. When you use the AUTOSAVE PROMPT by itself it implies the OFF command

OFF NOPROMPT : You are not notified and the data is not saved when you use an END

command

8.6. BOUNDS The BOUNDS line command (line command is the one that is issued on the line itself as shown below) displays boundary definition line

ON OFF

PROMPT NO PROMPT

AUTOSAVE

Page 227: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 227 -

000001 //T30831X JOB (624,TEST,0001),'JOSEPH',CLASS=Y, 000002 // MSGCLASS=X,REGION=0M,NOTIFY=&SYSUID 000003 //* =BNDS> < > 000004 //* 000005 //JOBLIB DD DSNAME=TS06.QSTART.LOADLIB,DISP=SHR 000006 // DD DSNAME=CGE2.DB2.DSNLOAD,DISP=SHR 000007 // DD DSNAME=CY10.Q1.BATCH.LOADLIB,DISP=SHR 000008 // DD DSNAME=PRODLIB,DISP=SHR The BOUNDS primary command (primary command is the one that is issued on the command line) sets the left and right boundaries and saves them in the edit profile BOUNDS left-column right-column EDIT CY$$.T30831.JCLLIB(ARMSMTCH) - 01.01 Command ===> BOUNDS 1 72 ****** ***************************** Top of Data ********* 000001 //T30831X JOB (624,TEST,0001),'JOSEPH',CLASS=Y, 000002 // MSGCLASS=X,REGION=0M,NOTIFY=&SYSUID 000003 //* 000004 //* 000005 //JOBLIB DD DSNAME=TS06.QSTART.LOADLIB,DISP=SHR You can’t specify the same column for both the boundaries. An * can be used to represent the current value of the boundary If both the primary command and line command are used in the same interaction, the line command overrides the primary command BOUNDS 10 * This command will set the left boundary to 10 and leave the right boundary as it is You can use the BOUNDS command to limit editing (search/change/shifting) to a specified boundary in the editing area

8.7. BROWSE This primary command allows you to browse a sequential dataset or partitioned dataset member during your current edit session. To exit from the browse session, enter the END command. The current session resumes

Page 228: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 228 -

8.8. CHANGE We all use Change very frequently, I give here only one specific case We use X ALL to hide the complete display and use F ALL String-3 to display only those lines which contains String-3. The above syntax is applicable in that scenario X : Scans only lines that are excluded from the display NX : Scans only lines that are not excluded from the display

8.9. COMPARE The COMPARE or COMP command compares the file you are editing with an external sequential data set or a member of a PDS. Lines that are exists only in the file being edited are marked and the lines that exists only in the file being compared are inserted as information lines in the file being edited COMP command together with MD command can be used for retrofitting purpose I will explain this Suppose for example, at time t1, I had taken code A from production and my intention is to make changes to 2000-PROCESS paragraph. And this is the code at time t1 000223 /*************************************************************** 000224 ** ** 000225 * THIS PARAGRAPH CONTROLS THE PROCESSING FLOW OF THE PROGRAM * 000226 ** ** 000227 **************************************************************** 000228 000229 2000-PROCESS. 000230 000231 PERFORM 2100-OPEN-EBPP-TERM-CSR 000232 THRU 2100-OPEN-EBPP-TERM-CSR-EXIT 000233 000234 PERFORM 2200-PROCESS-EBPP-ROWS 000235 THRU 2200-PROCESS-EBPP-ROWS-EXIT 000236 UNTIL END-OF-EBPP-TERM-CSR 000237 000238 PERFORM 2300-CLOSE-EBPP-TERM-CSR 000239 THRU 2300-CLOSE-EBPP-TERM-CSR-EXIT 000240 000241 . 000242 2000-PROCESS-EXIT. 000243 EXIT.

X NX

CHANGE String-1 String-2

Page 229: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 229 -

I made changes to 2000-PROCESS paragraph. And this is the code at time t2. Say, I added a new Para, 2250-PRINT-REPORT 000223 /*************************************************************** 000224 ** ** 000225 * THIS PARAGRAPH CONTROLS THE PROCESSING FLOW OF THE PROGRAM * 000226 ** ** 000227 **************************************************************** 000228 000229 2000-PROCESS. 000230 000231 PERFORM 2100-OPEN-EBPP-TERM-CSR 000232 THRU 2100-OPEN-EBPP-TERM-CSR-EXIT 000233 000234 PERFORM 2200-PROCESS-EBPP-ROWS 000235 THRU 2200-PROCESS-EBPP-ROWS-EXIT 000236 UNTIL END-OF-EBPP-TERM-CSR 000237 000238 PERFORM 2250-PRINT-REPORT 000239 THRU 2250-PRINT-REPORT-EXIT 000240 000241 PERFORM 2300-CLOSE-EBPP-TERM-CSR 000242 THRU 2300-CLOSE-EBPP-TERM-CSR-EXIT 000243 000244 . 000245 2000-PROCESS-EXIT. 000246 EXIT.

After I took the code from production, somebody else changed the code i.e., after time t1 and moved back to production before time t2 and the production code now look like this. A new Para 2150-CHECK-PROCESSING has been added 000223 /*************************************************************** 000224 ** ** 000225 * THIS PARAGRAPH CONTROLS THE PROCESSING FLOW OF THE PROGRAM * 000226 ** ** 000227 **************************************************************** 000228 000229 2000-PROCESS. 000230 000231 PERFORM 2100-OPEN-EBPP-TERM-CSR 000232 THRU 2100-OPEN-EBPP-TERM-CSR-EXIT 000233 000234 PERFORM 2150-CHECK-PROCESSING 000235 THRU 2150-CHECK-PROCESSING-EXIT 000236 000237 PERFORM 2200-PROCESS-EBPP-ROWS 000238 THRU 2200-PROCESS-EBPP-ROWS-EXIT 000239 UNTIL END-OF-EBPP-TERM-CSR 000240 000241 PERFORM 2300-CLOSE-EBPP-TERM-CSR 000242 THRU 2300-CLOSE-EBPP-TERM-CSR-EXIT 000243 000244 . 000245 2000-PROCESS-EXIT. 000246 EXIT.

Page 230: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 230 -

Before I move my code back to production, I have to make sure that this change has been incorporated and this process is known as retrofitting. Let’s see how we can do it with COMP instruction Open our version of the code, in the command line issue COMP Production- source- code-member Or

COMP Production- source- code-member X The first one will list the complete code and the second one will list only those area that have changes with the production. I issued the first version of the command and it showed the following 000223 /*************************************************************** 000224 ** ** 000225 * THIS PARAGRAPH CONTROLS THE PROCESSING FLOW OF THE PROGRAM * 000226 ** ** 000227 **************************************************************** 000228 000229 2000-PROCESS. 000230 000231 PERFORM 2100-OPEN-EBPP-TERM-CSR 000232 THRU 2100-OPEN-EBPP-TERM-CSR-EXIT 000233 ====== PERFORM 2150-CHECK-PROCESSING ====== THRU 2150-CHECK-PROCESSING-EXIT ====== 000234 PERFORM 2200-PROCESS-EBPP-ROWS 000235 THRU 2200-PROCESS-EBPP-ROWS-EXIT 000236 UNTIL END-OF-EBPP-TERM-CSR .OAAAA .OAAAB PERFORM 2250-PRINT-REPORT .OAAAC THRU 2250-PRINT-REPORT-EXIT 000240 000241 PERFORM 2300-CLOSE-EBPP-TERM-CSR 000242 THRU 2300-CLOSE-EBPP-TERM-CSR-EXIT 000243 000244 . 000245 2000-PROCESS-EXIT. 000246 EXIT.

See, the lines that are labeled (lines starting with . ), here in blue color are unique to our code, that means those are our changes and the lines coming with == display are unique to production that means those lines are in production and are not in our code. To make those code into our line, we can use MD command that will insert those lines into our code and MDD can be used to insert a block of command 000223 /*************************************************************** 000224 ** ** 000225 * THIS PARAGRAPH CONTROLS THE PROCESSING FLOW OF THE PROGRAM * 000226 ** ** 000227 **************************************************************** 000228 000229 2000-PROCESS.

Page 231: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 231 -

000230 000231 PERFORM 2100-OPEN-EBPP-TERM-CSR 000232 THRU 2100-OPEN-EBPP-TERM-CSR-EXIT 000233 =MDD== PERFORM 2150-CHECK-PROCESSING ====== THRU 2150-CHECK-PROCESSING-EXIT =MDD== 000234 PERFORM 2200-PROCESS-EBPP-ROWS 000235 THRU 2200-PROCESS-EBPP-ROWS-EXIT 000236 UNTIL END-OF-EBPP-TERM-CSR .OAAAA .OAAAB PERFORM 2250-PRINT-REPORT .OAAAC THRU 2250-PRINT-REPORT-EXIT 000240 000241 PERFORM 2300-CLOSE-EBPP-TERM-CSR 000242 THRU 2300-CLOSE-EBPP-TERM-CSR-EXIT 000243 000244 . 000245 2000-PROCESS-EXIT. 000246 EXIT.

After pressing enter, the member will look like this 000223 /*************************************************************** 000224 ** ** 000225 * THIS PARAGRAPH CONTROLS THE PROCESSING FLOW OF THE PROGRAM * 000226 ** ** 000227 **************************************************************** 000228 000229 2000-PROCESS. 000230 000231 PERFORM 2100-OPEN-EBPP-TERM-CSR 000232 THRU 2100-OPEN-EBPP-TERM-CSR-EXIT 000233 000234 PERFORM 2150-CHECK-PROCESSING 000235 THRU 2150-CHECK-PROCESSING-EXIT 000236 000237 PERFORM 2200-PROCESS-EBPP-ROWS 000238 THRU 2200-PROCESS-EBPP-ROWS-EXIT 000239 UNTIL END-OF-EBPP-TERM-CSR .OAAAA .OAAAB PERFORM 2250-PRINT-REPORT .OAAAC THRU 2250-PRINT-REPORT-EXIT 000243 000244 PERFORM 2300-CLOSE-EBPP-TERM-CSR 000245 THRU 2300-CLOSE-EBPP-TERM-CSR-EXIT 000246 000247 . 000248 2000-PROCESS-EXIT. 000249 EXIT. Sounds cool? You have to make sure you are using an MDD on the new paragraphs that are written. Suppose you are getting few labeled lines and if you are sure those lines were not inserted by you… that means those lines were deleted from production. It appears with labeled line because those lines are present only in your code. You can delete those lines from your code also.

Page 232: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 232 -

8.10. CREATE/REPLACE Suppose that you are editing your component in View mode and you want to save the changes. In such a case, you can use CREATE or REPLACE. The said example is just an instance and you can use CREATE/REPLACE for a variety of needs

8.10.1. CREATE CREATE creates a member of a PDS or a sequential dataset from the data you are editing Simplified syntax is CREATE {member} {range} Where member is the name of the new member and range is two labels that specify the group of lines, from beginning to end, which are added to the new member. Note: CREATE adds a member to a PDS only if a member of the same name doesn’t already exist. You have to specify a range of lines from the data you are editing. If you want to use the entire data you are editing, you can use the system defined labels .ZF and .ZL (stands for the first and last line) , or you can label the lines according to your needs or you can use CC/MM to select the lines. But please note the difference between CC/MM. You can specify the member in the command line or you can give CREATE .ZF .ZL and press enter, you will get the edit entry panel and you can specify the DSN. If you want to create a member in the same PDS in which the component you are editing resides, you can give CREATE .ZF .ZL NEWCMPNM If it is in another PDS , you can give a command like CREATE .ZF .ZL ‘IPHT.XXX.YYY(ABC)’ Or CREATE .ZF .ZL (or the range that you wish), and press enter; specify the DSN in the edit entry panel

8.10.2. REPLACE The REPLACE primary command replaces a sequential data set or a member of a PDS with the data you are editing. If the member you want to replace doesn’t exist, the editor creates it.

Page 233: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 233 -

Simplified Syntax is REPLACE {member} {range} The rules for REPLACE are same as that of CREATE

8.10.3. Saving a DS in view mode You might have come across this problem several times, you might have opened the DS in view mode, made lot of changes and when you tried to save it, you might have got the error. It is possible in a different way. If you have made changes to the member in view mode, you can use REPLACE . ZF .ZL <Original Member Name> - This will replace the original member with the changes that you made to the member in view mode. As good as saving from view mode

8.11. CUT/PASTE The CUT primary command saves lines to one of eleven named clipboards for later retrieval by the PASTE command. The lines can be appended to the lines already saved by a previous CUT command or can replace existing lines in a clipboard. The syntax of the CUT command is CUT {line pointer range} {DEFAULT | Clipboard name} {REPLACE | APPEND} {DISPLAY} Where, Line pointer range is Two line pointers that specify the range of lines in the current member those are to be added to or replace data in the clipboard. A line pointer can be a label or relative line number. You must specify both a starting and ending line pointer. If you do not specify a range of lines, all lines in the edit session are copied to the clipboard. E.g.: CUT .a .b Clipboard name is The name of the clipboard to use. If you omit this parameter, the ISPF default clipboard (named DEFAULT) is used. You can define up to ten additional clipboards. The size of the clipboards and number of clipboards might be limited by installation defaults. E.g.: CUT CUT1 PASTE CUT1

Page 234: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 234 -

CUT CUT2 PASTE CUT2 REPLACE | APPEND is Specify REPLACE to replace existing data in the clipboard. Specify APPEND to add the data to the clipboard. You can select REPLACE or APPEND as the default by entering the EDITSET command on the editor command line. The default action depends on the setting specified in the panel displayed by the EDITSET. DISPLAY is Show a list of existing clipboards. From this list you can browse, edit, clear, or rename the clipboards. E.g.: CUT DISPLAY. Clipboard manager will pop up and will give the options to view, edit …

8.12. DEFINE DEFINE name {ALIAS name-2} {NOP} {RESET} {DISABLED} This particular form of DEFINE can be used to assign an ALIAS to a macro or a built in function Open a member in EDIT mode Issue the following commands DEFINE A ALIAS SAVE Now you can use A instead of SAVE DEFINE A DISABLED Now if you issue A instead of SAVE, you will get the error ‘DISABLED COMMAND’ DEFINE A NOP This let you to make A to have no effect

Page 235: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 235 -

DEFINE A RESET To reset the definition of A

8.13. EDIT If you use EDIT, from within an EDIT session, it allows you to edit a sequential data set or a PDS member during your current edit session To exit from a nested edit session, enter an END or CANCEL command. The current session resumes

8.14. EDITSET or EDSET Causes the editor settings dialogue box to begin, enabling you to modify the editor settings

8.15. F Redisplays one or more lines at the beginning of a block of excluded lines F Or F {n} Here, I excluded all lines with the ‘DISPLAY’ String 000500 MOVE WS01-Q-EBPP-ROW-DEL-CNT 000501 TO WS01-Q-EBPP-ROW-DEL-CNT-Z - - - - - - - - - - - - - - - - - - - 5 Line(s) not Displayed 000507 WS01-Q-EBPP-TERM-ROW-CNT-Z - - - - - - - - - - - - - - - - - - - 1 Line(s) not Displayed 000509 WS01-Q-EBPP-ROW-DEL-CNT-Z 000510 ELSE - - - - - - - - - - - - - - - - - - - 2 Line(s) not Displayed

If I issue the following command 000500 MOVE WS01-Q-EBPP-ROW-DEL-CNT 000501 TO WS01-Q-EBPP-ROW-DEL-CNT-Z - -F4 - - - - - - - - - - - - - - - - 5 Line(s) not Displayed 000507 WS01-Q-EBPP-TERM-ROW-CNT-Z - - - - - - - - - - - - - - - - - - - 1 Line(s) not Displayed 000509 WS01-Q-EBPP-ROW-DEL-CNT-Z 000510 ELSE - - - - - - - - - - - - - - - - - - - 2 Line(s) not Displayed

Page 236: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 236 -

The display will be changed to this. See, four lines of DISPLY has been shown in response to F4 000500 MOVE WS01-Q-EBPP-ROW-DEL-CNT 000501 TO WS01-Q-EBPP-ROW-DEL-CNT-Z 000502 DISPLAY 'SUCCESSFULLY COMPLETED' 000503 DISPLAY '-------------------------------------------' 000504 DISPLAY 'TABLE DELETE STATISTICS' 000505 DISPLAY '-------------------------------------------' - - - - - - - - - - - - - - - - - - - 1 Line(s) not Displayed 000507 WS01-Q-EBPP-TERM-ROW-CNT-Z - - - - - - - - - - - - - - - - - - - 1 Line(s) not Displayed 000509 WS01-Q-EBPP-ROW-DEL-CNT-Z 000510 ELSE - - - - - - - - - - - - - - - - - - - 2 Line(s) not Displayed

8.16. FLIP We use X ALL ; F ALL <text-1> frequently - and it will hide all the lines except the lines with text-1. If you want to see all those hidden lines, you can use the command FLIP; instead of giving, reset and then again X LL <text-1>

8.17. L Like the F command we see above, L command can be used in the similar fashion – to redisplay the last line or lines of a block of excluded lines

8.18. LC/LCC Type LC in a line to convert it to lower case, block can be converted by using LCC

8.19. LOCATE/L This primary command allows you to scroll up/down to a specified line. The line then appears as the first line on the panel LOCATE {Label | Line number} You can label a line by issuing ‘.’ and then any alphabetic string

8.20. O Overlay lines It is better explained through an example

Page 237: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 237 -

Please see the following portion of JCL 000016 SORT FIELDS=COPY 000017 OMIT COND=(37,3,CH,EQ,C'CSS',OR 000018 37,3,CH,EQ,C'SPL',OR 000019 37,3,CH,EQ,C'TLT',OR 000020 37,3,CH,EQ,C'STL',OR 000021 37,3,CH,EQ,C'AC ',OR 000022 37,3,CH,EQ,C'AR ',OR 000023 37,3,CH,EQ,C'TOS',OR 000024 37,3,CH,EQ,C'MAR',OR 000025 37,3,CH,EQ,C'VCH',OR 000026 37,3,CH,EQ,C'VCR',OR 000027 37,3,CH,EQ,C'UIP',OR 000028 37,3,CH,EQ,C'AOS',OR 000029 37,3,CH,EQ,C'GC ',OR 000030 37,3,CH,EQ,C'BNK',OR 000031 37,3,CH,EQ,C'CVR',OR 000032 37,3,CH,EQ,C'EDR',OR 000033 37,3,CH,EQ,C'MJC',OR 000034 37,3,CH,EQ,C'OEC',OR 000035 37,3,CH,EQ,C'HEA',OR 000036 37,3,CH,EQ,C'CNT',OR 000037 37,3,CH,EQ,C'XCO',OR 000038 37,3,CH,EQ,C'G/L',OR 000039 37,3,CH,EQ,C'CIS',OR 000040 37,3,CH,EQ,C'LPS',OR 000041 37,3,CH,EQ,C'CSG',OR 000042 37,3,CH,EQ,C'CSE',OR 000043 37,3,CH,EQ,C'CSO',OR 000044 37,3,CH,EQ,C'CFG',OR 000045 37,3,CH,EQ,C'CFE',OR 000046 37,3,CH,EQ,C'CFO',OR 000047 37,3,CH,EQ,C'IEA',OR 000048 37,3,CH,EQ,C'LED',OR 000049 37,3,CH,EQ,C'H30',OR 000050 37,3,CH,EQ,C'HEL') 000051 /* You know this is wrong as we didn’t give a ‘,’ after the OR, so how shall we fix it?, we will manually insert a , after every OR? ……. NO…….., had it been thousands of lines, it would take long time to do that. Here the ‘O’ comes into picture. Let’s see how we can do this 000016 SORT FIELDS=COPY 00001C , 0000OO OMIT COND=(37,3,CH,EQ,C'CSS',OR 000019 37,3,CH,EQ,C'SPL',OR 000020 37,3,CH,EQ,C'TLT',OR 000021 37,3,CH,EQ,C'STL',OR 000022 37,3,CH,EQ,C'AC ',OR 000023 37,3,CH,EQ,C'AR ',OR 000024 37,3,CH,EQ,C'TOS',OR 000025 37,3,CH,EQ,C'MAR',OR

Page 238: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 238 -

000026 37,3,CH,EQ,C'VCH',OR 000027 37,3,CH,EQ,C'VCR',OR 000028 37,3,CH,EQ,C'UIP',OR 000029 37,3,CH,EQ,C'AOS',OR 000030 37,3,CH,EQ,C'GC ',OR 000031 37,3,CH,EQ,C'BNK',OR 000032 37,3,CH,EQ,C'CVR',OR 000033 37,3,CH,EQ,C'EDR',OR 000034 37,3,CH,EQ,C'MJC',OR 000035 37,3,CH,EQ,C'OEC',OR 000036 37,3,CH,EQ,C'HEA',OR 000037 37,3,CH,EQ,C'CNT',OR 000038 37,3,CH,EQ,C'XCO',OR 000039 37,3,CH,EQ,C'G/L',OR 000040 37,3,CH,EQ,C'CIS',OR 000041 37,3,CH,EQ,C'LPS',OR 000042 37,3,CH,EQ,C'CSG',OR 000043 37,3,CH,EQ,C'CSE',OR 000044 37,3,CH,EQ,C'CSO',OR 000045 37,3,CH,EQ,C'CFG',OR 000046 37,3,CH,EQ,C'CFE',OR 000047 37,3,CH,EQ,C'CFO',OR 000048 37,3,CH,EQ,C'IEA',OR 000049 37,3,CH,EQ,C'LED',OR 000050 37,3,CH,EQ,C'H30',OR 0000OO 37,3,CH,EQ,C'HEL') Three changes I have made 1. I created a template line to insert those ‘,’ and copied that line with ‘C’ 00001C , 2. I blocked the start and beginning of the area to be changed with OO/OO Press Enter, your changes are ready 000016 SORT FIELDS=COPY 000017 , 000018 OMIT COND=(37,3,CH,EQ,C'CSS',OR, 000019 37,3,CH,EQ,C'SPL',OR, 000020 37,3,CH,EQ,C'TLT',OR, 000021 37,3,CH,EQ,C'STL',OR, 000022 37,3,CH,EQ,C'AC ',OR, 000023 37,3,CH,EQ,C'AR ',OR, 000024 37,3,CH,EQ,C'TOS',OR, 000025 37,3,CH,EQ,C'MAR',OR, 000026 37,3,CH,EQ,C'VCH',OR, 000027 37,3,CH,EQ,C'VCR',OR, 000028 37,3,CH,EQ,C'UIP',OR, 000029 37,3,CH,EQ,C'AOS',OR, 000030 37,3,CH,EQ,C'GC ',OR, 000031 37,3,CH,EQ,C'BNK',OR,

Page 239: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 239 -

000032 37,3,CH,EQ,C'CVR',OR, 000033 37,3,CH,EQ,C'EDR',OR, 000034 37,3,CH,EQ,C'MJC',OR, 000035 37,3,CH,EQ,C'OEC',OR, 000036 37,3,CH,EQ,C'HEA',OR, 000037 37,3,CH,EQ,C'CNT',OR, 000038 37,3,CH,EQ,C'XCO',OR, 000039 37,3,CH,EQ,C'G/L',OR, 000040 37,3,CH,EQ,C'CIS',OR, 000041 37,3,CH,EQ,C'LPS',OR, 000042 37,3,CH,EQ,C'CSG',OR, 000043 37,3,CH,EQ,C'CSE',OR, 000044 37,3,CH,EQ,C'CSO',OR, 000045 37,3,CH,EQ,C'CFG',OR, 000046 37,3,CH,EQ,C'CFE',OR, 000047 37,3,CH,EQ,C'CFO',OR, 000048 37,3,CH,EQ,C'IEA',OR, 000049 37,3,CH,EQ,C'LED',OR, 000050 37,3,CH,EQ,C'H30',OR, 000051 37,3,CH,EQ,C'HEL') , 000052 /* 000053 //SYSPRINT DD SYSOUT=* The only additional thing that you have to do is to remove the template line from the display. You should be careful designing the template line (or source line). Only blank characters in the lines specified with O or OO are overlaid with the corresponding characters from the source lines

8.21. PROFILE If you type PROFILE primary command in your edit session, it will display the edit profile – you can change it inline Command ===> Scroll ===> CSR 000016 SORT FIELDS=COPY =PROF> ....JCLLIB (FIXED - 80)....RECOVERY OFF WARN....NUMBER OFF.............. =PROF> ....CAPS ON....HEX OFF....NULLS ON STD....TABS OFF...................... =PROF> ....AUTOSAVE OFF NOPROMPT....AUTONUM OFF....AUTOLIST OFF....STATS ON.... =PROF> ....PROFILE LOCK....IMACRO NONE....PACK OFF....NOTE ON.................. =PROF> ....HILITE OFF CURSOR FIND.............................................. 000017 ,

8.22. RECOVERY Sets edit recovery mode, which allows you to recover data after a system failure or power outage RECOVERY {ON/OFF}

Page 240: An Introduction to Mainframes

ISPF Editor Commands

An Introduction to Mainframes - 240 -

If the ON is specified, the system creates and updates a recovery data set for each change and the editor begins recording an audit trail of your interactions

8.22. SETUNDO SETUNDO {STORAGE|RECOVER|ON|OFF} STORAGE : Enables the saving of edit changes in storage RECOVER : Enables the saving of edit changes through the recovery ON : Enables edit changes to be saved in storage OFF : Disables

8.23. SORT SORT can be used to sort the formatted data in an edit window SORT {A/D} {Start-column {End-column}} You can specify 5 sort fields like this

8.24. TS If you want to split a line to two, type TS in the line command section and place the cursor where you want the line to be split and press enter

8.25. UC Like LC, UC/UCC changes the selected line/lines to upper case

8.26. UNDO Each time you enter UNDO, it reverses edit interactions, one at a time, in the order in which they have entered. To use UNDO, you must have either RECOVERY ON or SETUNDO ON. It can UNDO only those changes made after RECOVERY or SETUNDO was turned on

Page 241: An Introduction to Mainframes

Bibliography

An Introduction to Mainframes - 241 -

Bibliography Leon, Alexis. Mainframe Handbook. Leon Vikas Birchall, Graeme. DB2 UDB V8.2 SQL Cookbook Dohare, Ashok. Manual for Investigation of Computer Related Crimes. Department of Information Technology. MCIT, Govt. of India Ebbers, Mike; O’Brien, Wayne; Ogden, Bill. Introduction to the New Mainframe: z/OS Basics – IBM Redbooks Wikipedia IBM Archives - http://www-03.ibm.com/ibm/history/index.html IBM Archives – A Brief History of the IBM ES/9000, System/390 and zSeries IBM Archives – IBM Highlights, 1885-1969 Bell Labs – http://www.bell-labs.com Arora, Sumita. Computer Science C++. Dhanpat Rai & Co. http://nobelprize.org http://www.dell.com http://shop.lenovo.com Arellanes, R.J. IBM COBOL for MVS & VM Version 1 Release 2 Performance Tuning – IBM Corporation, Software Solutions Roy, M.K; Dastidar, D.Ghosh. COBOL Programming Including MS COBOL and COBOL-85. Tata McGraw-Hill Publishing Company Limited Newcomer, Larry. Schaum’s outline of Theory and Problems of Programming with Modern Structured COBOL - Second Edition. Schaum’s Outline Series. McGraw-Hill, INC. Mullins, Craig.S. DB2 Developer’s Guide. Pearson Education Ranade, Jay; Ranade Hirday. VSAM Concepts, Programming, and Design - Second Edition. Mc Graw-Hill, INC Brown, Gary DeWard. System 370/390 Job Control Language - Third Edition. John Wiley & Sons, INC Zamir, Saba; Ranade, Chander. The MVS JCL Primer Date, C.J; White, Colin J. A Guide to DB2 – Third Edition. Addison-Wesley Publishing Company Kageyama, Yukihisa. CICS Handbook. Mc Graw-Hill, INC

Page 242: An Introduction to Mainframes

Bibliography

An Introduction to Mainframes - 242 -

Eckols, Steve. IMS for the COBOL Programmer. Mike Murach & Associates Lovelace, Mary; Dalisay, Dawn; Salla, Alvaro; Sokal, Valeria. VSAM Demystified. IBM Redbooks Morton, Nigel; Ayyar, Rama; Gutschke, Dirk. Partitioned Data Set Extended (PDSE) Usage Guide. IBM Redbooks z/OS DFSORT Application Programming Guide – IBM Yaeger, Frank.L. DFSORT: ICETOOL Mini-User Guide. DFSORT Team, IBM Systems Software Development http://www.mapsofworld.com/referrals/computers/types-of-computers/index.html http://www.britannica.com/ http://www-03.ibm.com/systems/i http://www-03.ibm.com/systems/z/ The Times of India – Capital Edition – Nov 14- 2007 http://www-03.ibm.com/press/us/en/pressrelease/22579.wss http://www-03.ibm.com/ibm/history/exhibits/mainframe/mainframe_basinfo.html http://www-03.ibm.com/ibm/history/exhibits/mainframe/mainframe_album.html http://www.aig.qc.ca/mvs/24to31.html z/Architecture Principles of Operation. IBM Gribbin P.J. Development of 360/370 Architecture - A Plain Man's View. http://www.princeton.edu http://computer.howstuffworks.com http://www.webopedia.com/ http://publib.boulder.ibm.com http://www.cs.mun.ca – Memorial University of Newfoundland – Department of Computer science - Course: CS 3725

Page 243: An Introduction to Mainframes

INDEX

An Introduction to Mainframes - 243 -

INDEX 31 bit addressing--------------------------- 63 abacist--------------------------------------- 15 abacus--------------------------------------- 15 absolute address --------------------------- 81 access registers ---------------------------- 74 actuator ------------------------------------- 53 address space------------------------------- 84 Address Space ----------------------------- 59 AI-------------------------------------------- 29 AIX----------------------------------------- 208 Alias---------------------------------------- 135 ALL 31 ------------------------------------ 131 Altair ---------------------------------------- 27 AMODE ------------------------------------ 60 analog computers-------------------------- 39 Analog Computers ------------------------ 31 Application Designers -------------------- 96 application programmer ------------------ 96 AUTOSAVE------------------------------ 225 Auxiliary storage -------------------------- 79 Availability--------------------------------- 42 AWO--------------------------------------- 127 Batch Job ----------------------------------- 45 Batch operating systems------------------ 25 Batch Processing ---------------------- 44, 56 BFP------------------------------------------ 73 binary system ------------------------------ 18 Bit Logic Tests---------------------------- 186 Blaise Pascal ------------------------------- 17 BLOCK------------------------------------ 101 blocking factor---------------------------- 101 BlueGene ----------------------------------- 39 BOUNDS---------------------------- 224, 225 BROWSE---------------------------------- 226 buffer--------------------------------------- 101 byte index ---------------------------------- 86 CA split ------------------------------------ 206 Cache Memory ---------------------------- 82 CASE -------------------------------------- 142 CCW ---------------------------------------- 80 Central Storage ---------------------------- 43 CHANGE---------------------------------- 227 channel paths------------------------------- 76 channel subsystem ------------------------ 75 Channels------------------------------------ 51 Charles Babbage--------------------------- 19 CHECK------------------------------------ 131

CI Split------------------------------------- 207 CICS ---------------------------------------- 98 CIDF --------------------------------------- 200 CKD----------------------------------------- 53 Claude Shannon --------------------------- 21 COALESCE------------------------------- 136 COBOL------------------------------------ 101 Colossus ------------------------------------ 22 COMP-------------------------------------- 106 COMP-2 ----------------------------------- 107 COMP-3 ----------------------------------- 107 COMPARE-------------------------------- 227 Compatibility ------------------------------ 43 computer cluster --------------------------- 38 computer generation ---------------------- 21 Computing Tabulating Recording------- 20 Concatenate ------------------------------- 136 COND-------------------------------------- 176 CONTINUE------------------------------- 110 control blocks ------------------------------ 78 Control Interval--------------------------- 199 control registers---------------------------- 74 COUNT------------------------------------ 170 CPU -------------------------------- 43, 51, 73 CPW----------------------------------------- 34 CREATE ---------------------------- 192, 231 cryptographic facility --------------------- 75 CUT ---------------------------------- 193, 232 DASD ----------------------------------- 43, 53 DAT ------------------------------------- 84, 87 DBD---------------------------------------- 216 DBRM ------------------------------------- 134 DCLGEN ---------------------------------- 137 DEFINE ----------------------------------- 233 Density-------------------------------------- 53 DFSORT----------------------------------- 173 Difference engine-------------------------- 19 Digital Computers------------------------- 31 DISPLAY --------------------------------- 126 DRAM -------------------------------------- 82 DYNAM----------------------------------- 130 dynamic address translation-------------- 84 Dynamic address translation ------------- 87 Dynamic CALL--------------------------- 122 EDIT --------------------------------------- 234 EDITSET ---------------------------------- 234 EDSAC ------------------------------------- 24

Page 244: An Introduction to Mainframes

INDEX

An Introduction to Mainframes - 244 -

EDSET------------------------------------- 234 EDVAC------------------------------------- 24 EKA----------------------------------------- 39 ENIAC-------------------------------------- 23 ESCON --------------------------------- 51, 65 ESDS--------------------------------------- 202 eServer zSeries 900 ----------------------- 66 eServer zSeries 990 ----------------------- 68 ETR ----------------------------------------- 75 EVALUATE ------------------------------ 108 Expanded storage-------------------------- 73 Expanded Storage ------------------------- 61 EXPLAIN --------------------------------- 138 FBA ----------------------------------------- 53 FICON ---------------------------------- 52, 68 fifth generation ---------------------------- 29 first generation----------------------------- 22 FLIP---------------------------------- 195, 235 floating-point registers-------------------- 74 FORM ------------------------------------- 148 Fourth Generation ------------------------- 27 FPC------------------------------------------ 74 FPS ------------------------------------------ 73 frame ---------------------------------------- 90 Frame --------------------------------------- 60 General Purpose Computer -------------- 32 general registers --------------------------- 74 Herman Hollerith-------------------------- 20 HFP ----------------------------------------- 73 HRECALL -------------------------------- 191 Hybrid computers ------------------------- 39 Hybrid Computers------------------------- 31 I/O Devices----------------------------- 43, 52 IBM ----------------------------------------- 20 ICETOOL --------------------------------- 168 IDAW--------------------------------------- 80 IEBCOPY --------------------------------- 153 IEBGENER ------------------------------- 158 IMAGECOPY ---------------------------- 141 IMS------------------------------------------ 98 IMS DB------------------------------------ 216 INCLUDE--------------------------- 173, 175 Indexes------------------------------- 109, 127 INDEXES --------------------------------- 127 Indicator Variable ------------------------ 141 Integral Boundaries ----------------------- 80 integrated circuit--------------------------- 25 Intel ----------------------------------------- 26 IOCS --------------------------------------- 101

iogen ---------------------------------------- 63 IRD ------------------------------------------ 68 Jack Kilby ---------------------------------- 26 Jacquard loom ----------------------------- 18 JCL error ---------------------------------- 213 John Napier -------------------------------- 16 John von Neumann------------------------ 22 Joseph Marie Jacquard-------------------- 18 KSDS -------------------------------------- 201 LC ------------------------------------------ 235 LCC ---------------------------------------- 235 LDS ---------------------------------------- 204 Leibniz -------------------------------------- 17 LOCATE ---------------------------------- 235 Logarithms --------------------------------- 16 LPAR --------------------------------------- 52 Main storage ------------------------------- 72 mainframe ---------------------------------- 41 Mainframe------------------------------ 34, 77 MARK-1------------------------------------ 23 MCM---------------------------------------- 67 MD ----------------------------------------- 229 MDD --------------------------------------- 229 microcomputer----------------------------- 32 microprocessor------------------------- 27, 32 midrange systems-------------------------- 33 Minicomputers----------------------------- 32 MIP------------------------------------------ 67 MIPS ------------------------------------ 26, 69 Monolithic---------------------------------- 49 MSI------------------------------------------ 26 multiprocessing ---------------------------- 78 Multiprocessing---------------------------- 51 multiprocessing computer---------------- 38 multiprogramming ------------------------ 78 Multiprogramming ------------------------ 56 MVS----------------------------------------- 59 MVS/XA ------------------------------- 60, 92 Napier's Bones ----------------------------- 16 NEXT SENTENCE ---------------------- 110 NOAWO----------------------------------- 127 NODYNAM ------------------------------ 130 NOOPTIMIZE---------------------------- 128 NORENT ---------------------------------- 130 NOSSRANGE ---------------------------- 128 NRETRIEV ------------------------------- 196 Null Indicator ----------------------------- 134 NUMA -------------------------------------- 38 NUMPROC ------------------------------- 129

Page 245: An Introduction to Mainframes

INDEX

An Introduction to Mainframes - 245 -

OLTP --------------------------------------- 45 OMIT -------------------------------------- 173 operating system--------------------------- 76 operator facilities -------------------------- 76 OPTIMIZE -------------------------- 128, 139 page ----------------------------------------- 90 Page ------------------------------------- 60, 86 page index ---------------------------------- 86 Page Stealing------------------------------- 90 page-in -------------------------------------- 61 page-out------------------------------------- 61 paging--------------------------------------- 61 Paging----------------------------------- 60, 85 Pascaline------------------------------------ 17 PASTE------------------------------- 193, 232 PATH -------------------------------------- 210 PDSE--------------------------------- 153, 163 physical record---------------------------- 101 Plan----------------------------------------- 134 PR/SM -------------------------------------- 52 Prefixing------------------------------------ 81 Printers-------------------------------------- 53 Processing Options----------------------- 216 PROCOPT--------------------------------- 220 Production Control Analyst -------------- 97 PROFILE---------------------------------- 238 PSB----------------------------------------- 216 PSBGEN----------------------------------- 216 PSW----------------------------------------- 73 QMF --------------------------------------- 146 QW ----------------------------------------- 120 RACF --------------------------------------- 98 RDF ---------------------------------------- 200 real address--------------------------------- 81 Real storage -------------------------------- 79 RECOVERY------------------------------ 238 REDEFINES------------------------------ 103 Region -------------------------------------- 86 region first index -------------------------- 87 region index -------------------------------- 86 region second index----------------------- 87 region third index-------------------------- 87 Reliability ---------------------------------- 42 RENAMES-------------------------------- 104 RENT -------------------------------------- 130 REPLACE--------------------------- 192, 231 retrofitting --------------------------------- 229 RISC ---------------------------------------- 28 RMODE ------------------------------------ 60

Robert Noyce ------------------------------ 26 RRDS -------------------------------------- 203 RUNSTATS------------------------------- 140 S013---------------------------------------- 214 S0C4 --------------------------------------- 213 S0C7 --------------------------------- 112, 214 S322---------------------------------------- 213 S522---------------------------------------- 213 S722---------------------------------------- 214 S806---------------------------------------- 213 S878---------------------------------------- 213 S913---------------------------------------- 213 SB37 --------------------------------------- 192 Scalability ---------------------------------- 42 SDSF---------------------------------------- 98 SEARCH ---------------------------- 109, 121 SEARCH ALL---------------------- 109, 121 Second Generation ------------------------ 25 Security ------------------------------------- 42 Segment------------------------------------- 86 segment index------------------------------ 86 SELECT ----------------------------------- 110 Serviceability ------------------------------ 42 SETUNDO -------------------------------- 239 Seymour Cray------------------------------ 37 SIMD---------------------------------------- 38 single chip ---------------------------------- 32 slide rule ------------------------------------ 16 slot------------------------------------------- 90 Slot ------------------------------------------ 60 SMP ----------------------------------------- 38 Solid Logic Technology ------------------ 47 SORT -------------------------------------- 239 Special Purpose Computer --------------- 32 Spooling ------------------------------------ 56 SRAM--------------------------------------- 82 SRM----------------------------------------- 61 SSI------------------------------------------- 26 SSL------------------------------------------ 68 SSRANGE -------------------------------- 128 Static CALL------------------------------- 121 Storage Addressing------------------------ 80 Stored program concept ------------------ 22 Subscripts---------------------------- 109, 127 SUBSCRIPTS ---------------------------- 127 Super computers--------------------------- 36 Swapping ------------------------------- 61, 90 Synonym----------------------------------- 134 sysgen --------------------------------------- 63

Page 246: An Introduction to Mainframes

INDEX

An Introduction to Mainframes - 246 -

sysplex -------------------------------------- 65 System Administrator--------------------- 96 System Generation ------------------------ 62 System Initialization ---------------------- 63 System Operator--------------------------- 97 System Programmer ---------------------- 95 System/360----------------------------- 41, 46 System/370--------------------------------- 48 System/390--------------------------------- 64 Tabulating Machine Company ---------- 20 tabulator ------------------------------------ 20 TATA --------------------------------------- 38 teraflop-------------------------------------- 39 Third Generation -------------------------- 25 Thomas J. Watson Sr --------------------- 21 Time Sharing------------------------------- 57 TLB ----------------------------------------- 88 transistor------------------------------------ 25 TRUNC------------------------------------ 129

TS------------------------------------------- 239 UC------------------------------------------ 239 UNDO ------------------------------------- 239 Unit Record Devices ---------------------- 52 UNIVAC – I ------------------------------- 24 URD----------------------------------------- 52 USAGE ------------------------------------ 106 Views -------------------------------------- 135 virtual address ----------------------------- 81 Virtual Memory---------------------------- 82 Virtual Storage----------------------------- 55 VLSI ---------------------------------------- 27 VSAM ------------------------------------- 198 WAS ---------------------------------------- 98 XA--------------------------------------- 60, 64 z/Architecture ------------------------------ 36 z/OS -------------------------------- 66, 77, 84 z900 ----------------------------------------- 66 z990 ----------------------------------------- 69