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



Suppose i have a file with 10 recs and i want to skip only the 7 th record and copy the rest into ..

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

Suppose i have a file with 10 recs and i want to skip only the 7 th record and copy the rest into ..

Answer / rajiv

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

Suppose i have a file with 10 recs and i want to skip only the 7 th record and copy the rest into ..

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

Suppose i have a file with 10 recs and i want to skip only the 7 th record and copy the rest into ..

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

Suppose i have a file with 10 recs and i want to skip only the 7 th record and copy the rest into ..

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

Suppose i have a file with 10 recs and i want to skip only the 7 th record and copy the rest into ..

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

Suppose i have a file with 10 recs and i want to skip only the 7 th record and copy the rest into ..

Answer / nishant singhal

SORT FIELDS=COPY
SKIPREC=06
STOPAFT=1

Is This Answer Correct ?    8 Yes 13 No

Post New Answer

More JCL Interview Questions

How to pass the temp dataset form one JOB step to another?

6 Answers   IBM,


How much space OS allocates when you create a PS or PDS?

4 Answers  


if you have big pgm. during compilation is abends with (soc7)how do you know which line has soc 7 error.

4 Answers   IBM,


how can i code cond parameter in procedures ? i have a jclk calling a proc which has 10 steps i want to execute from step 5 to step 10 where can i code restrat parameter or cond parameter for ths

4 Answers   IBM,


Explain how can an in-stream dataset be terminated?

0 Answers  






How many steps we can overide in the proc's?

2 Answers   CS,


What are three major types of JCL statements? What are their functions?

1 Answers  


how do u define a file in cobol and jcl ?

2 Answers   TCS,


in production region 100 steps are running,but i need to run only step5 without changing code how can i do it?

4 Answers   HCL,


When we give TYPERUN = SCAN , what are the syntax errors we get?

5 Answers   Kanbay,


What you mean by skeleton JCl?

2 Answers  


i have 1000 records in input file and i want to sort it and the first 200 records to be placed in output file. how to do that??

14 Answers   L&T,


Categories