MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Number or records selection from a file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
bprasanna
Beginner


Joined: 05 Sep 2003
Posts: 119
Topics: 33
Location: Hyderabad

PostPosted: Fri Jul 22, 2005 1:17 pm    Post subject: Number or records selection from a file Reply with quote

Hi,
How can we achive the below o/p from the i/p file of length 80 of FB.

My i/p file is having the records like below.

02 1234
02 1234
02 1235
02 1235
02 1235
02 1236
03 1237
03 1237
03 1237
03 1238
03 1238

I need to create an o/p file with a key as first field and second field.The number of records to my o/p file should be 4 of the key.
the o/p should come as

02 1234----------->record1
02 1234
02 1235------------>record2
02 1235
02 1235
02 1236------------>record3
03 1237------------>record4
03 1237
03 1237

I have shown the record1 ,record2 etc.. for a better understanding of my problem.

Thanks in advance.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Jul 22, 2005 6:15 pm    Post subject: Reply with quote

Assuming that you actually want 03 1238 as output record 5, you can use the following DFSORT job to get the output you want:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
02   1234
02   1234
02   1235
02   1235
02   1235
02   1236
03   1237
03   1237
03   1237
03   1238
03   1238
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  SORT FIELDS=(1,2,CH,A,6,4,CH,A)
  SUM FIELDS=NONE
/*


SORTOUT would have:

Code:

02   1234
02   1235
02   1236
03   1237
03   1238

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bprasanna
Beginner


Joined: 05 Sep 2003
Posts: 119
Topics: 33
Location: Hyderabad

PostPosted: Sat Jul 23, 2005 12:52 am    Post subject: Reply with quote

Frank,
thanks for u r reply.But my requirement is diffrent.
I need to have the o/p in my file as below.
02 1234
02 1234
02 1235
02 1235
02 1235
02 1236
03 1237
03 1237
03 1237

here the number of total recors are 9(with duplicates) but the actual records of the key are 4 only(ie.. 02 1234,02 1235,02 1236 and 03 1237.

suppose if i say i need to have the o/p file with key field of 3 then my o/p should look like,,

02 1234
02 1234
02 1235
02 1235
02 1235
02 1236

Thank you
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sat Jul 23, 2005 10:16 am    Post subject: Reply with quote

Hmmm ... I think I understand what you're trying to do now. You want to get all of the records with the first n keys.

Is 4 the maximum number for n or can it be more? If it can be more, what is the maximum number for n?
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bprasanna
Beginner


Joined: 05 Sep 2003
Posts: 119
Topics: 33
Location: Hyderabad

PostPosted: Sat Jul 23, 2005 1:21 pm    Post subject: Reply with quote

Hi Frank,
The number 'n' is 50.

Thanks
Bprasanna
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sat Jul 23, 2005 2:39 pm    Post subject: Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for (actually, this method is better than the original one I was thinking of since it doesn't matter how large n is):

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file
//CTL2CNTL DD DSN=&&C1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file
//TOOLIN   DD    *
* Generate a DFSORT INCLUDE statement as follows:
*  INCLUDE COND=(1,9,CH,LE,C'keyn')
* where keyn is the character string for
* the nth key (e.g. '02   1236').
 SORT FROM(IN) USING(CTL1)
* Use the generated INCLUDE statement to only include the records
* with a key less than or equal to the nth key.
 COPY FROM(IN) TO(OUT) USING(CTL2)
//CTL1CNTL DD *
  SORT FIELDS=(1,9,CH,A)
  SUM FIELDS=NONE
***>>>>  Replace n with the number of the needed key (e.g. 3).
  OUTFIL ENDREC=n,
    FNAMES=CTL2CNTL,REMOVECC,NODETAIL,
    OUTREC=(80X),
    TRAILER1=(' INCLUDE COND=(1,9,CH,LE,C''',1,9,C''')')
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group