Sort - PDF

Embed Size (px)

Text of Sort - PDF

z/OS

DFSORT: Getting Started

SC26-7527-04

z/OS

DFSORT: Getting Started

SC26-7527-04

Note Before using this information and the product it supports, be sure to read the general information under Notices on page 185.

Fifth Edition, September 2009 This edition applies to Version 1 Release 11 of z/OS (5694-A01) and to all subsequent releases and modifications until otherwise indicated in new editions. This edition replaces SC26752703. IBM welcomes your comments. A form for readers comments may be provided at the back of this publication, or you may address your comments to the following address: v International Business Machines Corporation v MHVRCFS, Mail Station P181 v 2455 South Road v Poughkeepsie, NY 12601-5400 v United States of America v v FAX (United States & Canada): 1+845+432-9405 v FAX (Other Countries): v Your International Access Code +1+845+432-9405 v v IBMLink (United States customers only): IBMUSM10(MHVRCFS) v Internet e-mail: mhvrcfs@us.ibm.com v World Wide Web: http://www.ibm.com/servers/eserver/zseries/zos/webqs.html If you would like a reply, be sure to include your name, address, telephone number, or FAX number. Make sure to include the following in your comment or note: v Title and order number of this document v Page number or topic related to your comment When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. Copyright International Business Machines Corporation 1983, 2009. US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

ContentsFigures . . . . . . . . . . . . . . vii Tables . . . . . . . . . . . . . . . ix About this document . . . . . . . . . xiHow to use this document . . . . . . . . . xi Required product knowledge . . . . . . . . xii Accessing z/OS DFSORT documents on the Internet xii Using LookAt to look up message explanations . . xii Writing Constants . . . . . . . . Character Strings . . . . . . . Hexadecimal Strings . . . . . . Decimal Numbers . . . . . . . Numeric Tests for INCLUDE and OMIT . Substring Search for INCLUDE and OMIT VB Data Set Considerations . . . . . Starting Positions . . . . . . . Short Control Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 30 30 30 31 32 32 32 32

Part 1. Introduction . . . . . . . . . 1Chapter 1. What is DFSORT? . . . . . 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 3 4 5 5 5 6 6 6 7 7 DFSORT on the World Wide Web . . . . DFSORT FTP Site . . . . . . . . . . Data Sets, Records and Fields. . . . . . Sorting Data Sets . . . . . . . . . . Merging Data Sets . . . . . . . . . Copying Data Sets . . . . . . . . . What Else Can You Do with DFSORT?. . . Creating and Running DFSORT Jobs . . . Writing Jobs . . . . . . . . . . Summary of DFSORT Control Statements. Running Jobs . . . . . . . . . . Creating and Using the Sample Data Sets. .

Chapter 4. Summing Records . . . . . 35Writing the SUM Statement . . . Suppressing Records with Duplicate Handling Overflow . . . . . . VB Data Set Considerations . . . Starting Positions . . . . . Short Summary Fields . . . . . . . Control . . . . . . . . . . . . . . Fields . . . . . . . . . 35 37 . 38 . 38 . 38 . 38

Chapter 5. Reformatting Records with Fixed Fields . . . . . . . . . . . . 39Reformatting Records After Sorting with BUILD or FIELDS . . . . . . . . . . . . . . . Reordering Fields to Reserve Space . . . . . Inserting Binary Zeros . . . . . . . . . . Inserting Blanks . . . . . . . . . . . . Inserting Strings . . . . . . . . . . . . Character Strings . . . . . . . . . . Hexadecimal Strings . . . . . . . . . Setting Up a Basic Report. . . . . . . . Changing Uppercase to Lowercase . . . . . Converting Numeric Fields to Different Formats . Editing Numeric Fields . . . . . . . . . Displaying Data in Hexadecimal . . . . . . Performing Arithmetic with Numeric Fields and Constants . . . . . . . . . . . . . . Doing Lookup and Change . . . . . . . . Left-Justifying and Right-Justifying Data. . . . Left-Squeezing and Right-Squeezing Data . . . Reformatting Records with OVERLAY . . . . Extending Records with OVERLAY . . . . . Reformatting Records with FINDREP. . . . . Reformatting Records with IFTHEN . . . . . Reformatting Records Before Sorting . . . . . Using Other Statements with INREC . . . . . Preventing Overflow When Summing Values . . Inserting Sequence Numbers . . . . . . . VB Data Set Considerations . . . . . . . . RDW . . . . . . . . . . . . . . Starting Positions and Columns . . . . . Variable Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 41 42 42 43 43 44 45 45 46 47 50 50 51 53 55 59 60 62 63 67 67 68 69 72 72 72 73

Part 2. Learning to Write JCL and DFSORT Control Statements . . . . 11Chapter 2. Sorting, Merging, and Copying Data Sets. . . . . . . . . . 13Sorting Data Sets . . . . . . . . . . Sorting by Multiple Fields . . . . . . Continuing a Statement . . . . . . . Comment Statements . . . . . . . . JCL for Sorting Data Sets Directly . . . . Merging Data Sets . . . . . . . . . . Writing the MERGE Control Statement . . JCL for Merging Data Sets Directly . . . VB Data Set Considerations . . . . . . . Starting Positions . . . . . . . . . Short Control Fields . . . . . . . . Copying Data Sets . . . . . . . . . . Specifying COPY on the SORT, MERGE, or OPTION Statement . . . . . . . . . JCL for Copying Data Sets Directly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 15 17 17 17 19 20 21 22 22 22 23

|

. 23 . 23

Chapter 3. Including or Omitting Records . . . . . . . . . . . . . . 25Writing the INCLUDE Statement . . . . . . Writing the OMIT Statement. . . . . . . . Allowable Comparisons for INCLUDE and OMIT Copyright IBM Corp. 1983, 2009

. 26 . 28 29

Chapter 6. Reformatting Records with Variable Fields . . . . . . . . . . . 75Using %nn Parsed Fields with BUILD and OVERLAY . . . . . . . . . . . . . . . 75

iii

Using %nn Parsed Fields with IFTHEN . Where You Can Use %nn Fields in BUILD OVERLAY . . . . . . . . . . . PARSE Parameters . . . . . . . .

. . and . . . .

. . .

. 77 . 78 . 79

Chapter 11. Using the ICETOOL Utility 123ICETOOL Operators . . . . . . . . . . Sample Input Data Sets . . . . . . . . . Writing Required JCL Statements . . . . . . ICETOOL Comment and Blank Statements . . Printing Statistics For Numeric Fields . . . . Continuing an Operator Statement . . . . Statistics For VB Data Set Record Lengths . . Creating Identical Sorted Data Sets . . . . . Creating Different Subsets of a Sorted Data Set . Creating Multiple Unsorted Data Sets . . . . Counting Values in a Range . . . . . . . Printing Simple Reports . . . . . . . . . Printing Tailored Reports . . . . . . . . Using Formatting Items . . . . . . . . . Edit Masks . . . . . . . . . . . . Number of Digits . . . . . . . . . . Leading Zeros . . . . . . . . . . . Edit Patterns . . . . . . . . . . . No Statistics . . . . . . . . . . . . Division . . . . . . . . . . . . . Leading, Floating and Trailing Characters . . Printing Sectioned Reports . . . . . . . . Printing How Many Times Fields Occur . . . Selecting Records by Field Occurrences . . . . Joining Fields from Different Data Sets . . . . Matching Records from Different Data Sets . . Sorting Records between Headers and Trailers . Keeping or Removing Headers, Trailers and Relative Records . . . . . . . . . . . Complete ICETOOL Job and TOOLMSG Output . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 124 125 125 126 128 128 129 131 134 134 136 137 139 139 141 141 142 142 142 143 143 146 148 152 154 157

Chapter 7. Creating Multiple Output Data Sets and Reports . . . . . . . . 81Creating Multiple Identical Copies. . . . . . . 82 Selecting and Sampling by Relative Record Number 83 Including, Omitting, and Saving Discards . . . . 84 Reformatting . . . . . . . . . . . . . . 86 Repeating . . . . . . . . . . . . . . . 88 Splitting . . . . . . . . . . . . . . . 89 Creating Reports: OUTFIL vs ICETOOL . . . . . 91 Creating Reports with OUTFIL . . . . . . . . 91 Data . . . . . . . . . . . . . . . . 91 Headers . . . . . . . . . . . . . . 93 Trailers and Statistics . . . . . . . . . . 95 No Data or Carriage Control Characters . . . . 96 VB Data Set Considerations for Headers and Trailers . . . . . . . . . . . . . . . 97 Sections . . . . . . . . . . . . . . 97 Converting FB to VB . . . . . . . . . . . 100 Converting VB to FB . . . . . . . . . . . 102

|

Chapter 8. Calling DFSORT from a Program . . . . . . . . . . . . . 105Passing Control Statements . . . . . Calling DFSORT from a COBOL Program Sorting Records . . . . . . . Merging Records . . . . . . . Sorting with COBOL FASTSRT . . . Calling DFSORT from a PL/I Program . . . . . . . . . . . . . . . . . . . . . . . . . 105 105 106 108 111 111

| | |

. 158 159

Part 4. Learning to Use Symbols

165

Chapter 9. Overriding Installation Defaults . . . . . . . . . . . . . . 113Specifying PARM Parameters on a JCL EXEC Statement. . . . . . . . . . . . . Specifying an OPTION Control Statement in DFSPARM . . . . . . . . . . . . . . . 114 . 114

Chapter 12. Defining and Using Symbols . . . . . . . . . . . . . 167Creating the SYMNAMES Data Set . . . . . Defining Symbols for Fields . . . . . . . Using Symbols for Fields in DFSORT Statements Using Symbols for Fields in ICETOOL Operators Defining and Using Symbols for Constants . . . 167 . 167 169 170 . 171

Chapter 10. Using DFSORT Efficiently

117117 117 118 118 118 118 119 119 119 119 119

Be Generous with Main Storage . . . . . . . Allow Memory Object Sorting, Hipersorting and Dataspace Sorting . . . . . . . . . . . .