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

Combining of different records via a common key


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

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Fri Feb 01, 2008 9:28 pm
Reply with quote

Hi All,
My input file has in thsi format

1001 M1
1001 M2
1001 M3
1002 M1
1002 M4

My output file should be in the below format
1001 M1 M2 M3
1002 M1 M4

Can we do this thru SORT?

Bipin Peter
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 Feb 01, 2008 10:35 pm
Reply with quote

What is the maximum possible number of occurrences of the key (e.g. 1001 has 3 occurrences - is that the maximum you expect)?

What is the RECFM and LRECL of the input file?
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Sat Feb 02, 2008 8:33 am
Reply with quote

i'm expecting maxumum 10 occurences
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sat Feb 02, 2008 11:19 am
Reply with quote

Assuming the file is FB, try the below DFSORT/ICETOOL solution
Code:
//*******************************************************               
//STEP001  EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN1      DD *                                                         
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
1001 M0                                                                 
1001 M1                                                                 
1001 M2                                                                 
1001 M3                                                                 
1001 M4                                                                 
1001 M5                                                                 
1001 M6                                                                 
1001 M7                                                                 
1001 M8                                                                 
1001 M9                                                                 
1002 M1                                                                 
1002 M4                                                                 
1003 M4
/*                                                                     
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                       
 SPLICE FROM(IN1) TO(OUT) ON(1,4,CH) WITHEACH -                       
 WITH(9,3) -                                                           
 WITH(12,3) -                                                         
 WITH(15,3) -                                                         
 WITH(18,3) -                                                         
 WITH(21,3) -                                                         
 WITH(24,3) -                                                         
 WITH(27,3) -                                                         
 WITH(30,3) -                                                         
 WITH(33,3) -                                                         
 USING(CP01) KEEPNODUPS                                               
/*                                                                     
//CP01CNTL DD   *                                                     
  INREC  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,3,ZD,RESTART=(1,4))),   
         IFTHEN=(WHEN=(81,3,ZD,EQ,+2),BUILD=(1,5,9:6,3)),             
         IFTHEN=(WHEN=(81,3,ZD,EQ,+3),BUILD=(1,5,12:6,3)),             
         IFTHEN=(WHEN=(81,3,ZD,EQ,+4),BUILD=(1,5,15:6,3)),             
         IFTHEN=(WHEN=(81,3,ZD,EQ,+5),BUILD=(1,5,18:6,3)),             
         IFTHEN=(WHEN=(81,3,ZD,EQ,+6),BUILD=(1,5,21:6,3)),             
         IFTHEN=(WHEN=(81,3,ZD,EQ,+7),BUILD=(1,5,24:6,3)),             
         IFTHEN=(WHEN=(81,3,ZD,EQ,+8),BUILD=(1,5,27:6,3)),             
         IFTHEN=(WHEN=(81,3,ZD,EQ,+9),BUILD=(1,5,30:6,3)),             
         IFTHEN=(WHEN=(81,3,ZD,EQ,+10),BUILD=(1,5,33:6,3))             
  OUTFIL FNAMES=OUT,BUILD=(1,35)                                                   
/*                                                                     


OUT contains
Code:
1001 M0 M1 M2 M3 M4 M5 M6 M7 M8 M9
1002 M1 M4                       
1003 M4
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: Sat Feb 02, 2008 9:41 pm
Reply with quote

Here's a slightly simpler version of the DFSORT/ICETOOL job:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN1      DD *
1001 M0
1001 M1
1001 M2
1001 M3
1001 M4
1001 M5
1001 M6
1001 M7
1001 M8
1001 M9
1002 M1
1002 M4
1003 M4
/*
//OUT      DD SYSOUT=*
//TOOLIN   DD *
SPLICE FROM(IN1) TO(OUT) ON(1,4,CH) KEEPNODUPS -
 WITHEACH WITH(9,3) WITH(12,3) WITH(15,3) WITH(18,3) WITH(21,3) -
 WITH(24,3) WITH(27,3) WITH(30,3) WITH(33,3) USING(CTL1)
/*
//CTL1CNTL DD   *
  INREC IFTHEN=(WHEN=INIT,
          OVERLAY=(1,8,81:SEQNUM,3,ZD,RESTART=(1,4))),
    IFTHEN=(WHEN=(81,3,ZD,EQ,+2),OVERLAY=(9:6,3)),
    IFTHEN=(WHEN=(81,3,ZD,EQ,+3),OVERLAY=(12:6,3)),
    IFTHEN=(WHEN=(81,3,ZD,EQ,+4),OVERLAY=(15:6,3)),
    IFTHEN=(WHEN=(81,3,ZD,EQ,+5),OVERLAY=(18:6,3)),
    IFTHEN=(WHEN=(81,3,ZD,EQ,+6),OVERLAY=(21:6,3)),
    IFTHEN=(WHEN=(81,3,ZD,EQ,+7),OVERLAY=(24:6,3)),
    IFTHEN=(WHEN=(81,3,ZD,EQ,+8),OVERLAY=(27:6,3)),
    IFTHEN=(WHEN=(81,3,ZD,EQ,+9),OVERLAY=(30:6,3)),
    IFTHEN=(WHEN=(81,3,ZD,EQ,+10),OVERLAY=(33:6,3))
  OUTFIL FNAMES=OUT,BUILD=(1,35)
/*
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 Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top