MainframeSupports
tip week 14/2008:

I have written some tips about comparing data in DB2 and in datasets. These tips have mainly focused on finding differences by comparing all data against each other. Most of the time your needs are different. Typically you want to compare only the content of certain fields. Such a comparison may be interesting between records in the same dataset as well as across datasets.

One of the fastest IBM products is in my view DFSORT. DFSORT has a builtin tool called ICETOOL which is able to do a lot of useful stuff. ICETOOL has a tailor-made function to perform comparisons called SELECT. Now imagine a dataset MY.NEW.DATASET containing a list of dataset names with dataset information. In dataset MY.OLD.DATASETS you have another list with dataset names and dataset information, but not necessarily the same informations. Common to both datasets is the dataset name in position 1 to 44. You want to find out which dataset names are common to both datasets. This may be acheived in the following manner:

//COMPARE  EXEC PGM=ICETOOL
//SORTIN   DD DISP=SHR,DSN=MY.NEW.DATASETS
//         DD DISP=SHR,DSN=MY.OLD.DATASETS
//SORTOUT  DD SYSOUT=*
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//TOOLIN   DD *
    SELECT FROM(SORTIN) TO(SORTOUT) ON(1,44,CH) ALLDUPS
/*

Records with the same dataset name are written to SYSOUT. In this example I have chosen SYSOUT=* as the output destination which makes me able to view the result in SDSF or SYSVIEW. All records with the same dataset name are written out even if they come from the same dataset. If I was interested in the dataset names occuring only once I just change parameter ALLDUPS to NODUPS.

It is important to notice that it is your responsibility to make it possible to identify if a record originally comes from the new dataset or the old dataset. ICETOOL does not care at all and regards all records as coming from the same dataset. There are many other ways to use the SELECT function in ICETOOL. You may read about them here.

Previous tip in english        Sidste danske tip        Tip list