Page 1 of 2

Retrieve Odd(1st,3rd..) records from file- SORT JCL OUTFIL

Posted: Tue Dec 15, 2009 9:13 am
by mainframesara
Hi,

I have been asked in one interview that, how to retrieve the odd (1st,3rd,5th....) records from the PS file using DFSORT.

I dont know the answer for this question. If anybody knows the answer means, please help me.

Thanks.

Posted: Tue Dec 15, 2009 2:49 pm
by MrSpock
The best way I can think of is the SPLIT command:

OUTFIL Control Statements:

Code: Select all

//ODD DD DSN=...
//EVEN DD DUMMY
//SYSIN DD *
  OPTION COPY
  OUTFIL FNAMES=(ODD,EVEN),SPLIT
/*

Posted: Tue Dec 15, 2009 8:08 pm
by Frank Yaeger
This DFSORT job would be the "best" way:

Code: Select all

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=... output file
//SYSIN    DD    *
  OPTION COPY
  OUTFIL SAMPLE=2
/*
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080

Posted: Wed Dec 16, 2009 1:32 pm
by Anuj Dhawan
Hey Frank,

Just being little picky today, why do you call that job as "best"...I've been using "ODD, EVEN" approach since quite long by now...

Hope I don't bother you.

Posted: Wed Dec 16, 2009 1:32 pm
by Anuj Dhawan
is that because that would need a specific ptf?

Posted: Wed Dec 16, 2009 10:05 pm
by Frank Yaeger
"Best" (in my opinion) because it doesn't need the extra DUMMY DD statement and doesn't need to write the even records. With the SPLIT method, DFSORT has to write the odd and even records. With SAMPLE, DFSORT only has to write the odd records. So there's less I/O with the SAMPLE method.

Posted: Mon Dec 21, 2009 4:05 pm
by Anuj Dhawan
I see, thanks for your time Frank. :)

CRISP and CLEAR Answer

Posted: Thu Jul 19, 2012 7:03 pm
by raguliit
MrSpock wrote:The best way I can think of is the SPLIT command:

OUTFIL Control Statements:

Code: Select all

//ODD DD DSN=...
//EVEN DD DUMMY
//SYSIN DD *
  OPTION COPY
  OUTFIL FNAMES=(ODD,EVEN),SPLIT
/*
Thank u for the effort...

Posted: Thu Jul 19, 2012 7:24 pm
by dbzTHEdinosauer
raquliit,

if your desire is to split 1 file into 2,
then you have your answer,
though you would have to modify the dd statement for the second file
and add the necessary dd parms.

but, if you want only 1 output file containing every other record
you managed to mis-read the complete thread
and arrive at the incorrect conclusion.

you do realize that Frank was a DFSORT developer for IBM?
and I would value his answer over anyone else.
especially, since he went to the trouble to explain his answer
and provide the technical reasons for his comment.

Posted: Thu Jul 19, 2012 7:28 pm
by raguliit
dbzTHEdinosauer wrote:raquliit,

for your first post,
you managed to mis-read the complete thread
and arrive at the incorrect conclusion.

though you titled your post CRISP and CLEAR Answer
the only thing that is CRISP and CLEAR
is that your skills are rather dull and disappointing.
"though you titled your post CRISP and CLEAR Answer
the only thing that is CRISP and CLEAR
is that your skills are rather dull and disappointing."


Could not get the above lines clearly?

Posted: Thu Jul 19, 2012 7:36 pm
by William Collins
raguliit wrote:Could not get the above lines clearly?
To be expected. If you could, you wouldn't have made your initial post the initial post that you made.

Clear enough?

What is "CRISP and CLEAR" anyway? You advertising something? One symptom is the dumb pointless "positive" message tagged on to an old thread. Certainly fits your post.

Clear enough?

Posted: Thu Jul 19, 2012 11:33 pm
by DikDude
This has gotten rather out of hand. . .

RAGHUL's first post was just a thank you for the CRISP and CLEAR reply(ies) to the original question - posted a while back.

Due to our ever present language challange, this
"though you titled your post CRISP and CLEAR Answer
the only thing that is CRISP and CLEAR
is that your skills are rather dull and disappointing."
was not clear to RAGHUL and was so noted.

fwiw,

d

Posted: Fri Jul 20, 2012 12:13 am
by dbzTHEdinosauer
DikDude,

who cares if it is CLEAR and CRISP if it is wrong????

there is no language problem,

his disappointing and dull skills are being able to read and comprehend.

he liked the idea of a quick answer, even though it was the wrong solution to use.......

Posted: Fri Jul 20, 2012 1:16 am
by DikDude
who cares if it is CLEAR and CRISP if it is wrong????
How is a "thank you" wrong?

Unless i have missed something this is all that was posted (other than quoting the post the thanks was for):
Thank u for the effort...
The CRISP and CLEAR referred to the quality of the "solution", nothing else.

Unless i am completely misunderstanding something . . .

Posted: Fri Jul 20, 2012 4:55 pm
by Anuj Dhawan
If I think practically, when would one need to split any given file in to two halves or just to get the old/even records?

Possibly, never required in producation, in "real life" requirements. Possibly just one time requirement or/and a test-data-creation kinda exercise. Personally, if this is needed for such an exercise - I'd not be botherd about I/O in this age of Mainframe computing unless I'm dealing with billions of input-records.