Suppose i have a file with 10 recs and i want to skip only the
7 th record and copy the rest into another file. How do i do
it using SORT?
Answers were Sorted based on User's Feedback
Answer / manoj
This can be done using two SORTs in a JCL.
1. In the first SORT, sort the file and create two output
files.
File 1: Containing records from 1 to 7
File 2: Containing records 9 & 10
//SYSIN DD*
SORT FIELDS=COPY
OUTFIL FILES=01,ENDREC=07
OUTFIL FILES=02,STARTREC=09,ENDREC=10
/*
2. Use another SORT statement and then merge the two
statements created above.
Is This Answer Correct ? | 13 Yes | 5 No |
Hi,
you can do something like this using inrec & outfil
//STEP010 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
XXXX1 ABCEDFHIJCKLMO
XXXX2 ABCDEFGHIJKLMO
XXXX3 ABCDEFGHIJKLMO
XXXX4 ABCDEFGHIJKLMO
XXXX5 ABCDEFGHIJKLMO
XXXX6 ABCDEFGHIJKLMO
XXXX7 ABCDEFGHIJKLMO
XXXX8 ABCDEFGHIJKLMO
XXXX9 ABCDEFGHIJKLMO
XXX10 ABCDEFGHIJKLMO
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY,EQUALS
INREC IFTHEN=(WHEN=GROUP,RECORDS=10,PUSH=(21:SEQ=1))
OUTFIL INCLUDE=(21,1,CH,NE,C'7'),BUILD=(1,20)
Output:
XXXX1 ABCEDFHIJCKLMO
XXXX2 ABCDEFGHIJKLMO
XXXX3 ABCDEFGHIJKLMO
XXXX4 ABCDEFGHIJKLMO
XXXX5 ABCDEFGHIJKLMO
XXXX6 ABCDEFGHIJKLMO
XXXX8 ABCDEFGHIJKLMO
XXXX9 ABCDEFGHIJKLMO
XXX10 ABCDEFGHIJKLMO
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / madhu
We can achieve the same easily by using ICETOOL.
//STEP001 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=SORT.TEST,DISP=SHR
//SORTOUT DD DSN=SORT.TEST.OUTPUT,DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(500,500),RLSE)
//TOOLIN DD *
SUBSET FROM(SORTIN) TO(SORTOUT) INPUT REMOVE RRN(4) RRN(6)
/*
//
Explanation:
SORTIN refer input file with 10 records
SORTOUT is the new file created by excluding 4th and 6th records.
SUBSET,INPUT and REMOVE are defined ones in ICETOOL.
RRN is used to refer the required record .
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / ananth
srot fields = copy
stopaft=6
next we have to give another step by using disp=(mod,delete,delete)
skiprec=7
stopaft=4
then 7th record gone remainging records into output file.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / shubham_a
I am giving it a try, please correct me if anything is wrong
//JOBNAME JOB `ACCINFO`,MSGCLASS=X
//STEP001 EXEC PGM=DFSORT
//SORTOUT DD DSN=ABC.DEF.GHI
// DISP=(,CTLG)
//SORTIN DD DSN=ABC.EXAMPLE.INFILE,DISP=SHR
//SORTOUT DD DSN=ABC.EXAMPLE.OUTFILE,DISP=(,CATLG,DELETE)
//SORTOF01 DD DSN=ABC.EXAMPLE.OUTFILE,DISP=SHR
//SORTOF02 DD DSN=ABC.EXAMPLE.OUTFILE,DISP=SHR
// DCB=*.SORTIN,SPACE=*.SORTIN
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FILES=01,STOPAFT=06
OUTFIL FILES=02,SKIPREC=07,STOPAFT=10
/*
//SYSOUT DD SYSOUT=* =COPY
//
Is This Answer Correct ? | 4 Yes | 3 No |
Answer / sanjay soni
Let me give it a try:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,80,SEQNUM,3,ZD)
INCLUDE COND=(81,03,NE,ZD,3)
OUTREC BUILD=(1,80)
/*
Is This Answer Correct ? | 0 Yes | 2 No |
Can we write same stepname for one or more steps in on job ?
How to change default PROCLIB?
Describe the JOB statement, its meaning, syntax and significant keywords?
There are a set of 10 files and a customer will be selecting random no of files(i.e they may be more than 2, may not be in the order).Sometimes he might just select one file or sometimes no files at all.How do you code a JCL for this? Is it possible to code just JCL alone for this problem?
In JCL..for TIME Parameter was specified both JOB & STEP..which one is overrides
what is the function of spool command?
What are the default system and catalog libraries in JCL?
What are the kinds of job control statements?
A statement about PROCs is " In PROCs, Symbolic Parameters can be assigned on PROC and EXEC", BUT On which EXEC, (i) On the JCL's EXEC which is calling to PROC1. (Inside JCL, EXEC PROC1) (ii) or On the PROC's EXEC where it calls the PGM1. (Inside PROC, EXEC PGM=PGM1)
What is a GDG? Why do we go for a GDG ? utility used to create GDG?
What is condition checking in jcl? Is this possible?
what is instream data