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

Help needed on grouping and filtering using SORT


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

New User


Joined: 03 Nov 2009
Posts: 19
Location: chennai

PostPosted: Thu Sep 02, 2010 10:27 pm
Reply with quote

My input file contains the below,

Code:

Field 1       Field 2
A                   1
A                   1
B                   1
B                   2
C                   1
C                   1
C                   2
D                   1


My output file should contain,

Code:

Field 1        Field 2
A                    1
A                    1
D                    1


I do not want records in my output which have DIFFERENT values in Field 2.

Please help on this using SORT/ICETOOL. Thanks in advance.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Sep 02, 2010 10:31 pm
Reply with quote

veeramanimurugesan,

How many different values does FIELD2 have? is it always just 1 and 2?
Back to top
View user's profile Send private message
veeramanimurugesan

New User


Joined: 03 Nov 2009
Posts: 19
Location: chennai

PostPosted: Fri Sep 03, 2010 1:39 am
Reply with quote

Field 2 could have multiple values. 1 and 2 was just a sample to understand the requirement. Field 2 values are unpredictable. It is actually a 9 character
field.

For example,
Field 1 - Client Number
Field 2 - Account Number

A single client can have multiple accounts. If he has DIFFERENT multiple accounts, then i need to eliminate those records. If he has 2 records with same accounts, then i can have him in output. Only clients with DIFFERENT accounts need to be filtered out.
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Fri Sep 03, 2010 2:59 pm
Reply with quote

i got the output as u suggested, now check with ur actual data



Code:
//S020        EXEC PGM=ICETOOL                       
//FILE1   DD  *                                     
A    1                                               
A    1                                               
B    1                                               
B    2                                               
C    1                                               
C    1                                               
C    2                                               
D    1                                               
/*                                                   
//TEMP1    DD DSN=TEMP.TEST.DELETE,             
//             DISP=(NEW,CATLG),UNIT=DISK,           
//             SPACE=(27998,(400,100),RLSE)         
//FILEOUT  DD DSN=TEMP.TEST.FILEOUT,             
//             DISP=(NEW,CATLG),UNIT=DISK,           
//             SPACE=(27998,(400,100),RLSE)         
//SYSOUT   DD  SYSOUT=*                             
//TOOLIN   DD  *                                     
   COPY FROM(FILE1) TO(TEMP1) USING(CTL1)           
   COPY JKFROM TO(FILEOUT) USING(CTL2)               
/*                                                   
//CTL1CNTL DD  *                                     
   SORT FIELDS=(1,1,CH,A)                     
  OUTFIL REMOVECC,NODETAIL,SECTIONS=(1,1,     
    TRAILER3=(1,2,MIN=(6,1,ZD),MAX=(6,1,ZD))) 
/*                                             
//CTL2CNTL DD  *                               
   JOINKEYS F1=FILE1,FIELDS=(1,1,A)           
   JOINKEYS F2=TEMP1,FIELDS=(1,1,A),SORTED     
   REFORMAT FIELDS=(F1:1,6,F2:1,6)             
   OPTION COPY                                 
   OUTREC FIELDS=(1,6)                         
/*                                             
//JNF2CNTL DD  *                               
  OMIT COND=(3,1,CH,NE,5,1,CH)                 
/*                                             
//DFSMSG   DD  SYSOUT=*                       
//TOOLMSG  DD  SYSOUT=*                       
Back to top
View user's profile Send private message
veeramanimurugesan

New User


Joined: 03 Nov 2009
Posts: 19
Location: chennai

PostPosted: Fri Sep 03, 2010 4:27 pm
Reply with quote

Hi smijoss

Thanks for your response.

JOINKEYS wont work in my version of DFSORT. The sort version on mainframe here is Z/OS DFSORT V1R10.

Error :
COPY JKFROM TO(FILEOUT) USING(CTL2) 00240001
DFSORT CALL 0002 FOR COPY FROM JOINKEYS TO FILEOUT USING CTL2CNTL TERMINATED
OPERATION RETURN CODE: 16

Please advise.
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Fri Sep 03, 2010 5:50 pm
Reply with quote

Code:
//S020        EXEC PGM=ICETOOL                                   
//FILE1   DD  DSN=TEMP.TEST.INDATA,DISP=SHR                   
//TEMP1    DD DSN=TEMP.TEST.TEST1,DISP=(NEW,CATLG),UNIT=DISK,
//             SPACE=(27998,(4000,1000),RLSE)                                       
//CONCAT   DD DSN=*.TEMP1,VOL=REF=*.TEMP1,DISP=OLD               
//         DD DSN=TEMP.TEST.INDATA,DISP=SHR                   
//FILEOUT  DD DSN=TEMP.TEST.FILEOUT,                         
//             DISP=(NEW,CATLG),UNIT=DISK,                       
//             SPACE=(27998,(400,100),RLSE)                       
//SYSOUT   DD  SYSOUT=*                                           
//TOOLIN   DD  *                                                 
   COPY FROM(FILE1) TO(TEMP1) USING(CTL1)                         
   SPLICE FROM(CONCAT) TO(FILEOUT) ON(1,1,CH) -                   
   WITH(6,1) WITHALL  USING(CTL2)                                 
/*                                                               
//CTL1CNTL DD  *                                                 
   SORT FIELDS=(1,1,CH,A)                                         
   OUTFIL REMOVECC,NODETAIL,SECTIONS=(1,1,                       
    TRAILER3=(1,1,20:MIN=(6,1,ZD),MAX=(6,1,ZD),80:X))             
/*                                                               
//CTL2CNTL DD  *                                       
   OUTFIL OMIT=(20,1,CH,NE,22,1,CH),OUTREC=(1,10)       
/*                                                     
//DFSMSG   DD  SYSOUT=*                                 
//TOOLMSG  DD  SYSOUT=*                                 


INFILE :
Code:
----+----1----+----2--
**********************
A    1               
A    1               
B    1               
B    2               
C    1               
C    1               
C    2               
D    1   
Back to top
View user's profile Send private message
veeramanimurugesan

New User


Joined: 03 Nov 2009
Posts: 19
Location: chennai

PostPosted: Fri Sep 03, 2010 9:08 pm
Reply with quote

Thanks ! I will test this with my actual data.

It would be very helpful if you could explain the logic in TOOLIN, CTL1CNTL, CTL2CNTL control cards OR some short notes on how did you arrive at the output.
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Fri Sep 03, 2010 9:43 pm
Reply with quote

i knew u would ask the icon_smile.gif

TOOLIN :
you code the commands here for ICETOOL as you do in SYSIN for sortcard

to understand the purpose of CTL1CNTL -
check the output file TEMP.TEST.TEST1


download DFSORT getting started pdf, its explained very well
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top