IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

fetch 1st and 3rd record in a file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Tue Oct 21, 2008 7:54 pm
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
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: 8797
Location: Welsh Wales

PostPosted: Tue Oct 21, 2008 8:01 pm
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
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: 290
Location: Basel, Switzerland

PostPosted: Tue Oct 21, 2008 8:57 pm
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
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 Developer


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

PostPosted: Tue Oct 21, 2008 9:18 pm
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:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Oct 21, 2008 9:24 pm
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
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: 290
Location: Basel, Switzerland

PostPosted: Tue Oct 21, 2008 9:34 pm
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 Developer


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

PostPosted: Tue Oct 21, 2008 9:47 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top