Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

fetch 1st and 3rd record in a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
charavind17

New User


Joined: 24 Sep 2008
Posts: 30
Location: chennai

PostPosted: Tue Oct 21, 2008 7:49 pm    Post subject: fetch 1st and 3rd record in a file
Reply with quote

i have file in which i want to fetch 1st 3rd records using jcl..
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Oct 21, 2008 7:54 pm    Post subject:
Reply with quote

Using which program in your JCL, anything specific, or any utility that can do that ?

Is the file a VSAM file or non VSAM, tape or DASD ?
Back to top
View user's profile Send private message
charavind17

New User


Joined: 24 Sep 2008
Posts: 30
Location: chennai

PostPosted: Tue Oct 21, 2008 7:58 pm    Post subject: fetch 1st and 3rd record in a file
Reply with quote

VSAM file..any utility is also ok..
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Oct 21, 2008 8:01 pm    Post subject:
Reply with quote

From experience, you can either use IDCAMS or SORT.

This has been discussed a few times, selecting certain records, so may I suggest a search of the forum or google and then some trial and error, and let us know which utility you have chosen and any problems that you need help with.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Oct 21, 2008 8:39 pm    Post subject: Reply to: fetch 1st and 3rd record in a file
Reply with quote

charavind17,

The below might help...

Code:

//STEP0001 EXEC PGM=SORT
//SORTOUT  DD SYSOUT=* 
//SYSOUT   DD SYSOUT=* 
//SORTIN   DD *         
1                       
2                       
3                       
4                       
5                       
6                       
7                       
//SYSIN    DD *         
 SORT FIELDS=COPY       
 OUTFIL SAMPLE=2       
/*                     


Output:

Code:

1
3
5
7


Thanks.
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 287
Location: Basel, Switzerland

PostPosted: Tue Oct 21, 2008 8:57 pm    Post subject: Reply to: fetch 1st and 3rd record in a file
Reply with quote

Hy charavind17,

it's not that difficult: make an IDCAMS REPRO

//* allocate first an empty file
//REPRO EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//IN1 DD DSN=INPUT,DISP=SHR
//OUT1 DD DSN=OUTPUT,DISP=MOD
//SYSIN DD *
REPRO INFILE(IN1) OUTFILE(OUT1) COUNT(1)
REPRO INFILE(IN1) OUTFILE(OUT1) COUNT(1) SKIP(2)
/*

regards,
martin9
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Oct 21, 2008 9:18 pm    Post subject: Reply to: fetch 1st and 3rd record in a file
Reply with quote

martin9,

I tried IDCAMS approach but it gave output like below:

Code:

1
3


Thanks.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Oct 21, 2008 9:18 pm    Post subject:
Reply with quote

You can do this kind of thing quite easily using the new SUBSET operator of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:

Code:

//S1  EXEC  PGM=ICETOOL                                           
//TOOLMSG   DD  SYSOUT=*                                           
//DFSMSG    DD  SYSOUT=*                                           
//IN DD DSN=...  input file                                       
//OUT DD DSN=...  output file         
//TOOLIN DD *                                                     
SUBSET FROM(IN) TO(OUT) KEEP INPUT RRN(1) RRN(3)
/*     



For complete details on the new SUBSET function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2238
Location: @my desk

PostPosted: Tue Oct 21, 2008 9:24 pm    Post subject:
Reply with quote

Ramsri,
Quote:
i have file in which i want to fetch 1st 3rd records using jcl..

It's not quite clear which one do you want.

1) 1st and 3rd records.
2) 1st 3 records.

In either case you can achieve by experimenting on what you have right now. Goodluck.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Oct 21, 2008 9:27 pm    Post subject: It is not me.
Reply with quote

Hi, arcvns.

I posted the SORT solutio and tried the IDCAMS to just check icon_smile.gif

I prefer using SORT only.

Thanks.
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 287
Location: Basel, Switzerland

PostPosted: Tue Oct 21, 2008 9:34 pm    Post subject:
Reply with quote

Hy ramsri,

it's just what charavind17 actually wants...

"i have file in which i want to fetch 1st 3rd records using jcl.."

now with my example, there is a new file with the first and the
third record. like in the SORT from Frank Yaeger, you will also get
a new file with the first and third record.
What is now really the intention of charavind17?????????????????

regards,
martin9
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Oct 21, 2008 9:47 pm    Post subject:
Reply with quote

The Subject line seems clear:

Quote:
fetch 1st and 3rd record in a file
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 5 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us