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

Can we find specific member without knowing the name of PDS or can we search a member to which PDS it belongs to? if so how?

6 Answers  


What is maximum length of block size?

5 Answers   Cap Gemini, Kanbay, TCS,


Given a input file with duplicates how to remove the duplicate records from the file using JCL?

6 Answers   CDS, Convergys, TCS,


Is Default for MSGCLASS = (1,1) ?

2 Answers   IBM,


Explain the function of job statement in jcl?

0 Answers  






wht r different types of sort fields in jcl ?

1 Answers   IBM,


What happens if both JOBLIB and STEPLIB is specified ?

8 Answers  


I have 60 steps in the JCL and want to Execute Only First from PROC by overriding in JCL ?

0 Answers  


I need to compare two VSAm files. In input VSAM file some fields are updating and the updated feilds are coming into the output file. now i need to compare these two files with respect to a perticular field. Please suggest a suitable JCL code me.

2 Answers   Cognizant, Wipro,


What is the difference between the JOBLIB and the STEPLIB statements?

3 Answers  


1) Is CLASS used for assigning Priority (as we say a job having class '6' will run before the job having class '5'? then what is the difference between CLASS and PRTY ? 2) In a same JCL, 2 JOB statements with different Classes and NO PRTY are submitted ? which will run first ? & with different classes and different PRTY also, which will run first now ?

3 Answers   IBM,


What are the difference between jcl and jes?

0 Answers  


Categories