Mainframes 360
The one stop destination for System Z professionals

Friday, July 10, 2009

IBM Utilities Tutorial – 03 : IEBCOMPR and SORT

Q. How is IEBCOMPR Utility program used?  What is its purpose?
IEBCOMPR is used to compare two datasets. If they match, that is if they are mirror images of each other, exactly identical, condition code return is 0. The two datasets being compared must have the same record length. The IEBCOMPR utility has this format.

//SYSUT1 DD DSN=data-set1
//SYSUT2 DD DSN=data-set2
 COMPARE TYPORG= dataset-type(PS or PO)

The two datasets, that need to be compared are given as SYSUT1 and SYSUT2. IEBCOMPR has one important control card COMPARE. This indicates the type of dataset being compared ; if you are comparing two Physical Sequential datasets, the COMPARE control card should be PS. If you are comparing two Partitioned Datasets(PDS), the COMPARE should be PO.

Note :
By default COMPARE control card has TYPORG set to PS.
Q. What is SORT Utility used for? How does SORT work?
The SORT Utility is used to sort data records in a datset. Apart from this it can be used to copy selective data, merge previously sorted datasets, remove duplicates in a dataset etc. Hence, SORT is one of the most important IBM Utilities.

The general syntax for SORT JCL/Batch JOB is as follows :

//SORTIN DD DSN=input-dataset
//SORTOUT DD DSN=SORTED-output-dataset
Control Statements go here

In order to sort, we must supply SORTIN Card with the Input dataset, which contains the original data records. We must also supply SORTOUT Card, which gives the name of the Output Dataset, where the sorted output records should be printed.

Let me show you one typical SORT JCL/Job Stream, which shows the different Input Output Datasets needed.

So, we can draw a simple schematic which illustrates the above idea. I hope this would make it sink into your mind...

SORT Utility
requires SORT Control Card. The SORT Control Statement has an action word FIELD. The SORT Control Statement tells the SORT program, which are the key fields in the file according to which it should be sorted. It tells the starting column of the key field, the length of the key field, the type of data CH-Character, BI-Binary. It also specifies, whether we want to sort in Ascending order(A) or Descending Order(D).

The SORT Control Card has the following syntax :

SORT FIELDS=(start-column-of-key-field,key-field-length,type,order)

Suppose we have an input dataset that contains records in the following format :

A6003 10 100000
A0901 20 200000
A1015 30 300000
A4082 40 400000
A0901 50 500000
A8221 60 600000
A6003 70 700000
A0901 80 800000

Suppose we, want to sort the dataset in increasing(ascending) order of
AGENT-ID. That is, we are using AGENT-ID as a key to sort the dataset. Then, we must write the SORT Control Card as :

In the data, 1 Agent can sell 2 or more insurance policies. For example,
AGENT-ID A6003 has sold both Policy-No 10 and Policy-NO 70. Then, how to sort? In that case, we can specify another secondary key, which comes into picture only when the primary key AGENT-ID is the same for two records. If we want the secondary key to be POLICY-NO, then we can code the SORT Control Card as,


More on Sorting Here >>

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

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

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