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

what is force complete

2 Answers   IBM,


How to remove the spaces at end of each record in the output file Via COBOL program? note: The file has a VB length ----TRY

0 Answers  


Is there GOTO and SWITCH-CASE available in JCL ? Is IF-THEN-ELSE available in JCL also just like it is available for VSAM datasets under Model Commands category ?

1 Answers   IBM,


I have GDG defined e.g. GDG.smaplegdg.base, after processing the GDG. it contains some records and which is input to the second step2. How can I use GDG to use it as input file at step2.

3 Answers   Wipro,


What is COND=ONLY ?

2 Answers  






which utility is used to update pds?

1 Answers   IBM,


What does S0C4 error mean?

8 Answers  


As PARM can supply information to a program ? Can PARM be used to supply information to a cataloged or Inline Procedure also ?

2 Answers   IBM, RS Software,


what do you mean by include statement in jcl?

1 Answers   IBM,


in step1 of a jcl,disp=(mod,delete,delete) step02 exec pgm=ccc,cond=(0,le) will step02 be executed? i)never ii)always iii) iv)... i dont remember options

4 Answers   HSBC,


We have 100 steps in a procedure and we need to run the jcl and execute only 25th step in the proc and not the remaining steps. How can we do it?

5 Answers   IBM, JPMorgan Chase,


What is DISP= (NEW,PASS,DELETE)?

3 Answers   HCL,


Categories