View previous topic :: View next topic
|
Author |
Message |
bipinpeter
Active User
Joined: 18 Jun 2007 Posts: 213 Location: Cochin/Kerala/India
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
bipinpeter
Active User
Joined: 18 Jun 2007 Posts: 213 Location: Cochin/Kerala/India
|
|
|
|
i'm expecting maxumum 10 occurences |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
|
|