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 |
how many types of sorts are there in jcl?
How to exclude the duplicate records from two concateded flat files (records from both files must be removed)?
how do u see jobs submitted before ur job ?
List some valid operation codes in JCL
My JCL contains four steps //STP1 A(+1), DISP = NEW //STP2 A(+2), DISP = NEW //STP3 A(+3), DISP = NEW //STP4 A(+1), DISP = OLD STP3 was abended and I want restart my JCL from STP3 onwards & what are the precaution I want to take & what are the changes I need to make. Pls let me know.
if time parameter is not coded on the job card and job step then what is the default time assigned to the entire job and for each step in the job by the systyem ?
IN DFSORT sum fields=none is usec to remove duplicates.how to write the duplicates in another dataset?
What is the error/SOC code if dd names are not sysut1 and sysut2 in IEBGENER?
How to copy VSAM files without using REPRO
If Region=0k means What Happen?
Could you provide an example and its effect OF, Using COND on JOB and EXEC both ?
Is automatic restart possible in jcl? If yes, how?