MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
suresh_d Beginner Joined: 20 Sep 2006 Posts: 33 Topics: 9
Posted: Thu Sep 20, 2007 6:02 am Post subject: 2 recs in different files to be merged to single record.
Hi All,
I have 1-1 record each in 2 files. Now I want to megre them to single record in another file. Can some one pls tell how to do this.
EX:
file1 :
0011
file2:
0022
expected o/P:
0011<space>0022
thanks,
Suresh
Back to top
shankar.v Beginner Joined: 04 Sep 2007 Posts: 4 Topics: 0
Posted: Thu Sep 20, 2007 7:35 am Post subject:
Please check with the following code for your requirement.
The below code is for files with record length 4
Code: // EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//FILE1 DD *
0011
/*
//FILE2 DD *
0022
/*
//T DD DSN=&&T,DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(FILE1) TO(T) USING(CTL1)
COPY FROM(FILE2) TO(T) USING(CTL2)
SPLICE FROM(T) TO(OUT) ON(10,9,ZD) WITH(6,4) USING(CTL3)
/*
//CTL1CNTL DD *
INREC OVERLAY=(10:SEQNUM,9,ZD)
/*
//CTL2CNTL DD *
INREC BUILD=(6:1,4,SEQNUM,9,ZD)
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,BUILD=(1,9)
/*
//
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12357 Topics: 75 Location: San Jose
Posted: Thu Sep 20, 2007 7:47 am Post subject:
suresh_d ,
Try this untested 1 pass DFSORT JCL which will give you the desired results. Concatenate both files to sortin and run the following job
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=FILE 1,
// DISP=SHR
// DD DSN=FILE 2,
// DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION EQUALS
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,4,X,4Z,SEQNUM,1,ZD)),
IFTHEN=(WHEN=(10,1,ZD,EQ,2),
OVERLAY=(6:1,4))
SORT FIELDS=(5,1,CH,A)
SUM FIELDS=(6,4,BI)
OUTREC BUILD=(1,9)
/*
Hope this helps...
Cheers
Kolusu _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
www.linkedin.com/in/kolusu
Back to top
Frank Yaeger Sort Forum Moderator Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Sep 20, 2007 11:15 am Post subject:
Here's a way to do it with DFSORT's SPLICE in one pass:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD *
0011
/*
// DD *
0022
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
SPLICE FROM(CON) TO(OUT) ON(5,1,CH) WITH(6,4) USING(CTL1)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(10:SEQNUM,1,ZD)),
IFTHEN=(WHEN=(10,1,ZD,EQ,2),OVERLAY=(6:1,4))
OUTFIL FNAMES=OUT,BUILD=(1,9)
/*
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
suresh_d Beginner Joined: 20 Sep 2006 Posts: 33 Topics: 9
Posted: Fri Sep 21, 2007 3:14 am Post subject:
Hi,
My apologies for all for not giving the exact i/p. All you codes worked for the i/P i gave.. then I chaged to put my exact i/p's which led me to errors. Here I am giving my exact i/p's and my errors. pls bare with me
I/P:
Code:
file1 : 000111106.980000000 -> data length 19, file length 31
file2 : 9 -> data length 10, file length 31
expected o/P file :
Code:
000111106.980000000<space> 9 -> file length 31
Kolusu,
I tried exactly the code below assuming few places as file length related.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=file1,
// DISP=SHR
// DD DSN=file2,
// DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION EQUALS
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,19,X,4Z,SEQNUM,1,ZD))
IFTHEN=(WHEN=(10,1,ZD,EQ,2),
OVERLAY=(21:1,19))
SORT FIELDS=(20,1,CH,A)
SUM FIELDS=(21,10,BI)
OUTREC BUILD=(1,30)
/*
O/P error :
Code:
ICE109A E SUM FIELD DISPLACEMENT OR LENGTH VALUE ERROR
OUTREC BUILD=(1,30)
ICE751I 0 C5-K90007 C6-K90007 C7-K90000 C8-K90007 E7-K11698
ICE052I 3 END OF DFSORT
Frank,
Here is how I changed ur I/P more I want these I/P and O/P as files..
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD *
1111111111111111111
/*
// DD *
2222222222
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
SPLICE FROM(CON) TO(OUT) ON(5,1,CH) WITH(21,10) USING(CTL1
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(10:SEQNUM,1,ZD)),
IFTHEN=(WHEN=(10,1,ZD,EQ,2),OVERLAY=(21:1,10))
OUTFIL FNAMES=OUT,BUILD=(1,30)
/*
O/P:
No error but both the records got deleted..
Code:
INSERT 0, DELETE 2
RECORDS - IN: 2, OUT: 0
All your explanations are welcome.. I am completely new to these type of sort
Thanks,
Suresh.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12357 Topics: 75 Location: San Jose
Posted: Fri Sep 21, 2007 7:41 am Post subject:
suresh_d ,
It would have helped us if you posted the real input in the first post itself. Here are the untested DFSORT JCL's for the new input.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
000111106.980000000
9
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION EQUALS
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,19,X,10Z,SEQNUM,1,ZD)),
IFTHEN=(WHEN=(31,1,ZD,EQ,2),
OVERLAY=(20:1,10))
SORT FIELDS=(20,1,CH,A)
SUM FIELDS=(21,8,BI,29,2,BI)
OUTREC BUILD=(1,30)
/*
Frank's solution using splice
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD *
000111106.980000000
/*
// DD *
9
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
SPLICE FROM(CON) TO(OUT) ON(20,1,CH) WITH(21,10) USING(CTL1)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(31:SEQNUM,1,ZD)),
IFTHEN=(WHEN=(31,1,ZD,EQ,2),OVERLAY=(20:1,10))
OUTFIL FNAMES=OUT,BUILD=(1,30)
/*
Hope this helps....
Cheers
Kolusu _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
www.linkedin.com/in/kolusu
Back to top
suresh_d Beginner Joined: 20 Sep 2006 Posts: 33 Topics: 9
Posted: Fri Sep 21, 2007 10:11 am Post subject:
Thanks Kolusu.. It worked great !!
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum