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

Extract the first 11 records with the same key


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Absinthia

New User


Joined: 10 Jan 2008
Posts: 36
Location: CHINA

PostPosted: Fri Aug 01, 2008 1:30 pm
Reply with quote

Hello,everyone,I just met with a very delicate problem.
Input file is below.
The key column is from 1 to 7.(in this file,the key is NA94T21 and NA95T23)

I just want to extract the first 11 records with the same key.
Could anyone help me to do it?
Thanks in advance.
Code:
NA94T21     333QSPP           359  ¯*07001200
NA94T21     444QSHP           330    06001200
NA94T21     555QNLS                -         
NA94T21     NR46SPP           359  ¯*07001200
NA94T21     NR54SPP           330    06001200
NA94T21     NR7GSPP           330   *06001200
NA94T21     AAA0000           330  ¢*06001200
NA94T21     BBB1111           330  ª*06001200
NA94T21     CCC2222                -         
NA94T21     GA7GUNB           330    01000000
NA94T21     GB7HUNB           330  ¢<01000000
NA94T21     GD80UN2           330  ½%01000000
NA94T21     GE22UNB           330    01000000
NA94T21     444QSHP           330    06001200
NA94T21     555QNLS                -         
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
NA95T23     555QNLS
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Aug 01, 2008 2:23 pm
Reply with quote

Absintia,

Check the below JCL

Code:
//STEPS200 EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN1      DD *                                                         
NA94T21     333QSPP                                                     
NA94T21     444QSHP                                                     
NA94T21     555QNLS                                                     
NA95T23     555QNLS                                                     
NA95T23     555QNLS                                                     
/*                                                                     
//TEMP1   DD DSN=&&WERP1,DISP=(MOD,PASS),                               
//      DSORG=PS,RECFM=FB                                               
//TOOLIN   DD *                                                         
  COPY FROM(IN1) TO(TEMP1) USING(SRT1)                                 
  SORT FROM(TEMP1) TO(OUT1) USING(SRT2)                                 
/*                                                                     
//SRT1CNTL DD *                                                         
  SORT FIELDS=(1,7,CH,A)                                               
   OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(41:SEQNUM,6,ZD,RESTART=(1,7))),   
           IFTHEN=(WHEN=(41,6,ZD,LT,2),OVERLAY=(61:C'1'))               
/*                                                                     
//SRT2CNTL DD *                                                         
  OPTION COPY                                                           
  INCLUDE COND=(61,1,CH,EQ,C'1')                                       
  OUTREC BUILD=(1,40)                                                   
/*                                                                     
//OUT1     DD SYSOUT=*                                                 


change this IFTHEN=(WHEN=(41,6,ZD,LT,2), to 12 for your reqt. Test and let us know if it works.

output
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Aug 01, 2008 2:30 pm
Reply with quote

Abs,

What if you have less than 11 records for a particular key???

I have assumed that u need all the records, the maximum of which can be 11 for a key.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Aug 01, 2008 3:08 pm
Reply with quote

Hi,

this might be another way
Code:
//* ONLY TOP 11 OCCURENCE OF A FIELD                                   
//**********************************************************************
//S1       EXEC  PGM=ICEMAN                                             
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=INPUT-DSN                                             
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  SORT FIELDS=(1,7,CH,A)                                               
  OUTREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,7))                         
  OUTFIL INCLUDE=(81,8,ZD,LE,+11),BUILD=(1,80)                         
/*                                                                     




Gerry
Back to top
View user's profile Send private message
Absinthia

New User


Joined: 10 Jan 2008
Posts: 36
Location: CHINA

PostPosted: Fri Aug 01, 2008 3:24 pm
Reply with quote

Thanks a lot .It works.but there is a small problem.
Code:
//TEMP1   DD DSN=&&WERP1,DISP=(MOD,PASS),                               
//      DSORG=PS,RECFM=FB


This step,the space parameter should be added.
I thought about the method before.However,
I didn't know RESTART parameter before.
It is so tricky. icon_biggrin.gif
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Aug 01, 2008 3:39 pm
Reply with quote

Abs,

Quote:
This step,the space parameter should be added.


Do add that step, If your shop requires SPACE parameter to be added for all output datasets.
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: Fri Aug 01, 2008 8:46 pm
Reply with quote

Absinthia,

If you have z/OS DFSORT V1R5 PTF UK90013 (July, 2008) you can do this more easily with the DFSORT/ICETOOL job below. If you don't have this PTF, ask your System Programmer to install it (it's free).

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//OUT DD DSN=...  output file
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,7,CH) FIRST(11)
/*


For complete details on the new SELECT FIRST(n) 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
Absinthia

New User


Joined: 10 Jan 2008
Posts: 36
Location: CHINA

PostPosted: Sat Aug 02, 2008 5:40 pm
Reply with quote

Frank,thanks a lot.that function is so good.I tried it ,our shop has not installed it yet.I will later advise our system programmer to install it.
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: Sun Aug 03, 2008 1:56 am
Reply with quote

I'm glad you like DFSORT's new SUBSET function. Note that PTF UK90013 is available for installation now.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Aug 06, 2008 11:40 am
Reply with quote

Frank,

Quote:
I'm glad you like DFSORT's new SUBSET function.


Had a look at the links for the new operators introduced. I am pretty much sure that it is going to make our work even more easier. Great work.
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: Wed Aug 06, 2008 9:52 pm
Reply with quote

Aaru,

Thanks. I'm glad you like the new DFSORT/ICETOOL functions. We aim to please. icon_biggrin.gif
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top