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

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

mainframesara
Member
Posts: 13
Joined: Mon Oct 26, 2009 12:00 pm

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

Post by mainframesara » Tue Dec 15, 2009 9:13 am

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.

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Tue Dec 15, 2009 2:49 pm

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
/*

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Dec 15, 2009 8:08 pm

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
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Wed Dec 16, 2009 1:32 pm

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.
Regards,
Anuj

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Wed Dec 16, 2009 1:32 pm

is that because that would need a specific ptf?
Regards,
Anuj

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Wed Dec 16, 2009 10:05 pm

"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.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Mon Dec 21, 2009 4:05 pm

I see, thanks for your time Frank. :)
Regards,
Anuj

raguliit
Member
Posts: 2
Joined: Thu Jul 19, 2012 6:55 pm

CRISP and CLEAR Answer

Post by raguliit » Thu Jul 19, 2012 7:03 pm

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...
---------
RAGHUL

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Jul 19, 2012 7:24 pm

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.
Last edited by dbzTHEdinosauer on Thu Jul 19, 2012 7:33 pm, edited 1 time in total.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

raguliit
Member
Posts: 2
Joined: Thu Jul 19, 2012 6:55 pm

Post by raguliit » Thu Jul 19, 2012 7:28 pm

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?
---------
RAGHUL

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Thu Jul 19, 2012 7:36 pm

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?

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Thu Jul 19, 2012 11:33 pm

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

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Fri Jul 20, 2012 12:13 am

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.......
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Jul 20, 2012 1:16 am

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 . . .
Have a good one

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Fri Jul 20, 2012 4:55 pm

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.
Regards,
Anuj

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others