I have a file in which I have 20 records. I want my first
record to go into file 1 and second record to go in second
file. I want to copy the alternate records like this in the
two output files. How can I do this using JCL?

Answers were Sorted based on User's Feedback



I have a file in which I have 20 records. I want my first record to go into file 1 and second reco..

Answer / satish

//job statement
//step1 exec pgm=sort
//sortin dd dsn=input file that contain 20 records
//file1 dd dsn=output file
//file2 dd dsn=another output file
//sysout dd sysout=*
//sysin dd *
option copy
outfil fnames=(file1,file2),split
/*

Is This Answer Correct ?    7 Yes 0 No

I have a file in which I have 20 records. I want my first record to go into file 1 and second reco..

Answer / muttaiah

Adding to satish answer.

Option copy is similar to sort fields= copy or merge
fields=copy.
It is used to simply copy the records from input to output
file.

Outfil is used when we want to do process records in the
input file.
Here split option is used in Outfil to seperate the input
file into 2, that means it will write the alternate records
into the files specified in fnames.
Other syntax of Outfill would be

//step1 exec pgm=sort
//sortin dd dsn=Inputfile
//sortof01 dd dsn=file1
//sortof02 dd dsn=file2
//sysin dd *
option copy
outfil files=(01,02),split
/*
Here we are giving 01,02 which indicates the DDnames that
are prefixed with sortof.

Hope this makes sense in understanding satish answer

@All: Do correct me if i'm wrong.

Thank u

Is This Answer Correct ?    5 Yes 0 No

I have a file in which I have 20 records. I want my first record to go into file 1 and second reco..

Answer / bala

we can add seqnum to each record in the file using SORT
command and copy then use INCLUDE & EXCLUDE COND of SORT
for this.

Is This Answer Correct ?    1 Yes 3 No

I have a file in which I have 20 records. I want my first record to go into file 1 and second reco..

Answer / ksingla.vikas

IDCAMS might be helpful for same.

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More JCL Interview Questions

if we want to use a gdg which is already created by some job, then how to use the reference of the last generation in a jcl?

0 Answers   IBM,


Hi, Please clear me when COND=ONLY and COND=EVEN. Explain me with example.

2 Answers   GJ,


List in order the hierarchical levels of jcl?

0 Answers  


At what stage, operator can change the class and priority of a submitted job?

2 Answers  


Explain how can an in-stream dataset be terminated?

0 Answers  






if my GDG limit has been kept as 50 and if am trying to put 60 records.what would happen. will there be any abend for this scenario

4 Answers  


what is A-MODE and R-MODE?

2 Answers  


what are the options in file-aid to edit vsam dataset and to compare data sets.

2 Answers   Ocwen,


i have 10steps and i want run step3 and based on step3 i want execute step7,8,9,10?in jcl

1 Answers  


What are isolation levels? Where do we need to specify them in compiling JCL?

3 Answers  


what are the technical terms for // /* in jcl

3 Answers   Cap Gemini,


If a JOBSTEP abends, AND without using COND also, all the subsequent steps execute, then what is the use of using EVEN ? Why do we use EVEN when without it also all the JOBSTEPs execute ?

2 Answers   IBM,


Categories