Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Extract the first 11 records with the same key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Extract the first 11 records with the same key
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: 1288
Location: Chennai, India

PostPosted: Fri Aug 01, 2008 2:23 pm    Post subject: Reply to: Extract the first 11 records with the same key
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: 1288
Location: Chennai, India

PostPosted: Fri Aug 01, 2008 2:30 pm    Post subject: Reply to: Extract the first 11 records with the same key
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: 1703
Location: Australia

PostPosted: Fri Aug 01, 2008 3:08 pm    Post subject:
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Fri Aug 01, 2008 3:39 pm    Post subject: Reply to: Extract the first 11 records with the same key
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 Moderator


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

PostPosted: Fri Aug 01, 2008 8:46 pm    Post subject:
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:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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    Post subject:
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 Moderator


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

PostPosted: Sun Aug 03, 2008 1:56 am    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Wed Aug 06, 2008 11:40 am    Post subject: Reply to: Extract the first 11 records with the same key
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 Moderator


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

PostPosted: Wed Aug 06, 2008 9:52 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Spool Extract for Z /os 1.04 version Khadhar Basha CLIST & REXX 3 Thu Sep 28, 2017 3:14 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us