8
Few useful Tricks using DFSORT and ICETOOL TABLE OF CONTENTS 1.1 Introduction........................................................................................................................... 5 1.2 Intended Users...................................................................................................................... 5 1.3 User Guidance....................................................................................................................... 5 1..3.1 How to Install..................................................................................................................... 5 1.4 Using SPLIT1R:....................................................................................................................... 5 1.5 Using SPLIT:........................................................................................................................... 6 1.6 Using SPLITBY:....................................................................................................................... 7 1.7 Using STARTREC and ENDREC:............................................................................................. 8 1.8 Using ICETOOL to check the empty dataset:.....................8

Useful Tricks Using Dfsort and Icetool

  • Upload
    mukesh

  • View
    285

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Useful Tricks Using Dfsort and Icetool

Few useful Tricks using DFSORT and ICETOOL

TABLE OF CONTENTS

1.1 Introduction...........................................................................................................................51.2 Intended Users.....................................................................................................................51.3 User Guidance......................................................................................................................51..3.1 How to Install.........................................................................................................................51.4 Using SPLIT1R:......................................................................................................................51.5 Using SPLIT:...........................................................................................................................61.6 Using SPLITBY:......................................................................................................................71.7 Using STARTREC and ENDREC:.......................................................................................81.8 Using ICETOOL to check the empty dataset:.............................................................8

Page 2: Useful Tricks Using Dfsort and Icetool

11 Introduction

DFSORT and ICETOOL have lot of uses in Mainframe application. Few of them will be discussed here.

DFSORT’s SPLIT option can be used to split a dataset into two or more datasets in different manner.

Merging two input fields (one field holding a decimal number and the second field holding the sign of the decimal number) into one output field can be done easily through DFSORT.

We may come across a scenario where we need to execute a program which uses an input file and if we have high possibility of getting an empty input file then we may wish to skip that step from execution. ICETOOL can be used to check whether an input dataset is an empty dataset and if the input dataset is an empty dataset then the RC of that step can be set to 12 or 4 and using this RC the actual step which uses this input file can be skipped out of execution.

Page 3: Useful Tricks Using Dfsort and Icetool

12 Intended Users

These jobs can be used by all Mainframe Application Programmers who want to split a dataset into two or more dataset and who want to check an empty input file.

13 User Guidance

1.3.1 How to Install

The following JCL’s can be typed in a member of PDS file and can be SUBMITted as and when required.

14 Using SPLIT1R:

The below job can be used to split the input file into output files each having specific number of contiguous records. For e.g. the below job which has SPLIT1R parameter given as 3 will split the input file and writes the first 3 records to the first output file, the second 3 records to the second output file etc., and any extra records to the last output file.

//JOBNAME JOB (Acct info),'SORT', // MSGCLASS=U,CLASS=0,MSGLEVEL=(1,1),NOTIFY=&SYSUID//S1 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DSN=YOUR.INPUT.DATASET,DISP=SHR //OUT1 DD DSN=YOUR.OUTPUT.DATASET.OUT1, // DISP=(NEW,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=80),UNIT=SYSDA, // SPACE=(TRK,(1,1),RLSE) //OUT2 DD DSN=YOUR.OUTPUT.DATASET.OUT1, // DISP=(NEW,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=80),UNIT=SYSDA, // SPACE=(TRK,(1,1),RLSE) //OUT3 DD DSN=YOUR.OUTPUT.DATASET.OUT1, // DISP=(NEW,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=80),UNIT=SYSDA, // SPACE=(TRK,(1,1),RLSE) //SYSIN DD * SORT FIELDS=(1,15,CH,A) OUTFIL FNAMES=(OUT1,OUT2,OUT3),SPLIT1R=3 /*

If the input dataset (SORTIN) has the following recordsINPUT RECORD 01INPUT RECORD 02INPUT RECORD 03INPUT RECORD 04INPUT RECORD 05INPUT RECORD 06INPUT RECORD 07INPUT RECORD 08

Page 4: Useful Tricks Using Dfsort and Icetool

INPUT RECORD 09INPUT RECORD 10

Then the OUT1 file will have the following records INPUT RECORD 01INPUT RECORD 02INPUT RECORD 03

The OUT2 file will have the following records INPUT RECORD 04INPUT RECORD 05INPUT RECORD 06

The OUT3 file will have the following records INPUT RECORD 07INPUT RECORD 08INPUT RECORD 09INPUT RECORD 10

15 Using SPLIT:SPLIT option of the DFSORT can be used when we need to split the input file in a cyclic manner. i.e., if we try to split the input file into three o/p files using SPLIT option then the first record of the i/p file will be written to the file o/p file, second i/p record to the second o/p file, third i/p record to third o/p file, fourth i/p record to first o/p file and so on until the end of the input file records.

//JOBNAME JOB (Acct info),'SORT', // MSGCLASS=U,CLASS=0,MSGLEVEL=(1,1),NOTIFY=&SYSUID//S1 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DSN=YOUR.INPUT.DATASET,DISP=SHR //OUT1 DD DSN=YOUR.OUTPUT.DATASET.OUT1, // DISP=(NEW,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=80),UNIT=SYSDA, // SPACE=(TRK,(1,1),RLSE) //OUT2 DD DSN=YOUR.OUTPUT.DATASET.OUT1, // DISP=(NEW,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=80),UNIT=SYSDA, // SPACE=(TRK,(1,1),RLSE) //OUT3 DD DSN=YOUR.OUTPUT.DATASET.OUT1, // DISP=(NEW,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=80),UNIT=SYSDA, // SPACE=(TRK,(1,1),RLSE) //SYSIN DD * SORT FIELDS=(1,15,CH,A) OUTFIL FNAMES=(OUT1,OUT2,OUT3),SPLIT/*

If we had used the same output file which we used for SPLIT1R example, then the output files will be having the below records

OUT1INPUT RECORD 01INPUT RECORD 04INPUT RECORD 07

Page 5: Useful Tricks Using Dfsort and Icetool

INPUT RECORD 10

OUT2INPUT RECORD 02INPUT RECORD 05INPUT RECORD 08

OUT3INPUT RECORD 03INPUT RECORD 06INPUT RECORD 09

16 Using SPLITBY:SPLITBY option does the same as SPLIT, except that the SPLITBY=n writes the n records to the output dataset in rotation.

//JOBNAME JOB (Acct info),'SORT', // MSGCLASS=U,CLASS=0,MSGLEVEL=(1,1),NOTIFY=&SYSUID//S1 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DSN=YOUR.INPUT.DATASET,DISP=SHR //OUT1 DD DSN=YOUR.OUTPUT.DATASET.OUT1, // DISP=(NEW,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=80),UNIT=SYSDA, // SPACE=(TRK,(1,1),RLSE) //OUT2 DD DSN=YOUR.OUTPUT.DATASET.OUT1, // DISP=(NEW,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=80),UNIT=SYSDA, // SPACE=(TRK,(1,1),RLSE) //OUT3 DD DSN=YOUR.OUTPUT.DATASET.OUT1, // DISP=(NEW,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=80),UNIT=SYSDA, // SPACE=(TRK,(1,1),RLSE) //SYSIN DD * SORT FIELDS=(1,15,CH,A) OUTFIL FNAMES=(OUT1,OUT2,OUT3),SPLITBY=2/*

If we had used the same output file which we used for SPLIT1R example, then the output files will be having the below records

OUT1:INPUT RECORD 01INPUT RECORD 02INPUT RECORD 07INPUT RECORD 08

OUT2:INPUT RECORD 03INPUT RECORD 04INPUT RECORD 09INPUT RECORD 10

Page 6: Useful Tricks Using Dfsort and Icetool

OUT3:INPUT RECORD 05INPUT RECORD 06

17 Using STARTREC and ENDREC:

STARTREC and ENDREC can be used if we need to copy few records, for which we know their exact line number, from the input file to an output file.

//JOBNAME JOB (Acct info),'SORT', // MSGCLASS=U,CLASS=0,MSGLEVEL=(1,1),NOTIFY=&SYSUID//S1 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DSN=YOUR.INPUT.DATASET,DISP=SHR //OUT1 DD DSN=YOUR.OUTPUT.DATASET.OUT1, // DISP=(NEW,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=80),UNIT=SYSDA, // SPACE=(TRK,(1,1),RLSE) //SYSIN DD * SORT FIELDS=(1,15,CH,A) OUTFIL FNAMES=OUT1,STARTREC=003,ENDREC=008/*

If we had used the same output file which we used for SPLIT1R example, then the output file will be having the below records

INPUT RECORD 03INPUT RECORD 04INPUT RECORD 05INPUT RECORD 06INPUT RECORD 07INPUT RECORD 08

18 Using ICETOOL to check the empty dataset:The below job can be used to check whether an input file is an empty dataset. If it is an empty dataset then the RC of that step will be set to 4 and this RC can be checked in the COND parameter of the next step which uses this input file to skip that step from execution in case of empty input file

//JOBNAME JOB (Acct info),'EMPTY FILE CHECK', // MSGCLASS=U,CLASS=0,MSGLEVEL=(1,1),NOTIFY=&SYSUID//S1 EXEC PGM=SORT //TOOLMSG DD SYSOUT=* //DFSMSG DD SYSOUT=* //IN1 DD DSN=YOUR.INPUT.DATASET,DISP=SHR //SYSIN DD * COUNT FROM(IN1) EMPTY RC4

Page 7: Useful Tricks Using Dfsort and Icetool

/*

Had the option RC4 been not used then by default the Return code will get set to 12