Sie sind auf Seite 1von 7

Few useful Tricks using DFSORT and

ICETOOL

TABLE OF CONTENTS

FEW USEFUL TRICKS USING DFSORT AND ICETOOL................................................................1


1.1 Introduction.....................................................................................................2
1.2 Intended Users................................................................................................3
1.3 User Guidance.................................................................................................3
1.3.1 How to Install...............................................................................................3
1.4 Using SPLIT1R:................................................................................................3
1.5 Using SPLIT:....................................................................................................4
1.6 Using SPLITBY:................................................................................................5
1.7 Using STARTREC and ENDREC:........................................................................6
1.8 Using ICETOOL to check the empty dataset:...................................................6
1.1 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.
1.2 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.

1.3 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.

1.4 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 records


INPUT RECORD 01
INPUT RECORD 02
INPUT RECORD 03
INPUT RECORD 04
INPUT RECORD 05
INPUT RECORD 06
INPUT RECORD 07
INPUT RECORD 08
INPUT RECORD 09
INPUT RECORD 10

Then the OUT1 file will have the following records


INPUT RECORD 01
INPUT RECORD 02
INPUT RECORD 03

The OUT2 file will have the following records


INPUT RECORD 04
INPUT RECORD 05
INPUT RECORD 06

The OUT3 file will have the following records


INPUT RECORD 07
INPUT RECORD 08
INPUT RECORD 09
INPUT RECORD 10

1.5 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

OUT1
INPUT RECORD 01
INPUT RECORD 04
INPUT RECORD 07
INPUT RECORD 10

OUT2
INPUT RECORD 02
INPUT RECORD 05
INPUT RECORD 08

OUT3
INPUT RECORD 03
INPUT RECORD 06
INPUT RECORD 09

1.6 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 01
INPUT RECORD 02
INPUT RECORD 07
INPUT RECORD 08

OUT2:
INPUT RECORD 03
INPUT RECORD 04
INPUT RECORD 09
INPUT RECORD 10
OUT3:
INPUT RECORD 05
INPUT RECORD 06

1.7 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 03
INPUT RECORD 04
INPUT RECORD 05
INPUT RECORD 06
INPUT RECORD 07
INPUT RECORD 08

1.8 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
/*

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

Das könnte Ihnen auch gefallen