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

Say I have a file with 12 records. Each record has the name of the month. I have to append data in these 12 records into 1 record. How is it possible?

2 Answers   CTS,


how many max steps can we use in a job? pls answer to my question

9 Answers   TCS,


How many types of libraries are there in JCL ?

2 Answers   IBM,


consider the following progrm statements MOVE 0 TO SW.NO.OF.REC PERFORM PRI-OUT UNTIL SW=1 DISPALY NO.OF.REC STOP RUN PRE-OUT READ IN-FILE AT END MOVE 1 TO SW WRITE OUO-REC FROM IN-REC ADD 1 TO NO.OF REC if the IN-FILE contains 1000 records what value will be displayed after the PERFORM is over? assume that N0.OF.REC has PIC 9(4) a.1000 b.1001 c.1 d.none of the above

1 Answers  


List the various advantages of using jcl language?

0 Answers  






what's the significance of freespace(0 0) and freespace(100 100)

3 Answers  


What is the motivation behind coding class parameter in job statement?

0 Answers  


When cursor is not closed what is the error?

3 Answers   IBM,


How do you override a specific DDNAME/SYSIN in PROC from a JCL?

6 Answers   CTS,


How Can we see all generations of a GDG ?

3 Answers   Polaris,


i have 10 steps in jcl program but i have to exicute only 2,4,6,8th and 10th ?how it's possible?

10 Answers   IBM,


//{name} INCLUDE MEMBER=memname {comments} in the include statement, what actually happens when its executed? The membername conatains a list of valid JCL statements, so will the include statement be substituted by these statements and how can we mention the pds that conatains the member? How does the include group differ from a PROC? how is include statement connected to JOBLIB and STEPLIB?

2 Answers   CCS, CTS,


Categories