MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Combinig two files

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
shashank.sharma
Beginner


Joined: 18 Apr 2007
Posts: 16
Topics: 10

PostPosted: Mon Aug 18, 2008 4:07 am    Post subject: Combinig two files Reply with quote

Hi have two files:

File 1:

Code:
AAA
BBB
CCC


File 2:

Code:
001D 123 D123
012D 158 D453
213D 433 D423
765D 475 D234
469D 234 D856
. . . .. . . . . . ..


I need:

File 3:

Code:
001D AAA D123
012D BBB D453
213D CCC D423
765D AAA D234
469D BBB D856
. . . .. . . . . . ..


Is it possible using jcl?
Back to top
View user's profile Send private message
Bill Dennis
Advanced


Joined: 03 Dec 2002
Posts: 579
Topics: 1
Location: Iowa, USA

PostPosted: Mon Aug 18, 2008 8:27 am    Post subject: Reply with quote

shashank,

1. JCL does nothing by itself, it calls programs such as ICETOOL

2. Are the record counts of the two files equal, or do the values get repeated?

3. What is the length of each record?
_________________
Regards,
Bill Dennis

Disclaimer: My comments on this foorum are my own and do not represent the opinions or suggestions of any other person or business entity.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon Aug 18, 2008 10:40 am    Post subject: Reply with quote

shashank.sharma,

The following DFSORT JCL will give you the desired results. We create 3 symbols from file1 and later use them to populate the file 2 records. The first constant 'AAA' is updated on the first record of file 2 and the second constant 'BBB' is updated on the second record of file 2 and the third constant 'CCC' is updated on the third record of the file2 and the cycle repeats for every 3 records till the end of the file. I assumed your file is FB recfm and 80 bytes in length

Code:

//STEP0100 EXEC PGM=ICEMAN                                       
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                 
AAA                                                             
BBB                                                             
CCC                                                             
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)       
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                               
  OUTREC BUILD=(C'CON',SEQNUM,1,ZD,C',C''',1,3,C'''',80:X)       
/*                                                               
//STEP0200 EXEC PGM=ICEMAN                                       
//SYSOUT   DD SYSOUT=*                                           
//SYMNAMES DD DSN=&&T1,DISP=SHR                                 
//SORTIN   DD *                                                 
001D 123 D123                                                   
012D 158 D453                                                   
213D 433 D423                                                   
765D 475 D234                                                   
469D 234 D856                                                   
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                               
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,START=3,INCR=1,
             89:81,8,ZD,MOD,+3,TO=ZD,LENGTH=1))                 
                                                                 
  OUTREC IFOUTLEN=80,                                           
  IFTHEN=(WHEN=(89,1,ZD,EQ,0),OVERLAY=(6:CON1)),                 
  IFTHEN=(WHEN=(89,1,ZD,EQ,1),OVERLAY=(6:CON2)),                 
  IFTHEN=(WHEN=(89,1,ZD,EQ,2),OVERLAY=(6:CON3))                 
/*


Hope this helps...

Cheers
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Mon Aug 18, 2008 4:13 pm    Post subject: Reply with quote

Hi Kolusu,
It may sound like strange question but i am trying accomplish the same using SPLICE operator. Below is the jcl i have tried but it abends.

Code:
//S1 EXEC PGM=ICETOOL                                                   
//IN1 DD *                                                             
AAA                                                                     
BBB                                                                     
CCC                                                                     
/*                                                                     
//IN2 DD *                                                             
001D 123 D123                                                           
012D 158 D453                                                           
213D 433 D423                                                           
765D 475 D234                                                           
469D 234 D856                                                           
//*T1 DD DSN=&&T1,DISP=(MOD,PASS),UNIT=SYSDA,SPACE=(TRK,(5,5))         
//T1 DD SYSOUT=*                                                       
//OUT DD SYSOUT=*                                                       
//TOOLMSG DD SYSOUT=*                                                   
//SYSOUT  DD SYSOUT=*                                                   
//DFSMSG  DD SYSOUT=*                                                   
//TOOLIN DD *                                                           
 COPY FROM(IN1) TO(T1) USING(CTL1)                                     
 COPY FROM(IN2) TO(T1) USING(CTL2)                                     
 SPLICE FROM(T1) TO(OUT) ON(81,8,ZD) WITH(06,03)                       
/*                                                                     
//CTL1CNTL DD *                                                         
 INREC BUILD=(5X,1,3,81:SEQNUM,8,ZD)                                   
/*                                                                     
//CTL2CNTL DD *                                                         
 INREC BUILD=(1,5,4X,10:6,8,81:SEQNUM,8,ZD)                             
/*     


Could you please guide me where I am doing wrong?

Error Message :-

Code:
ICE200I 0 IDENTIFIER FROM CALLING PROGRAM IS 0003                               
ICE143I 0 BLOCKSET     SORT  TECHNIQUE SELECTED                                 
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 0 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 17:09 ON MON AUG
          DEBUG NOABEND,ESTAE                                                   
          OPTION MSGDDN=DFSMSG,LIST,MSGPRT=ALL,RESINV=0,SORTIN=T1,SORTOUT=OUT,DY
                         ALLOC,SZERO,EQUALS,NOVLSHRT,LOCALE=NONE,NOCHECK       
          SORT FIELDS=(81,8,ZD,A)                                               
          MODS E35=(ICE35DU,12288)                                             
ICE201I E RECORD TYPE IS F - DATA STARTS IN POSITION 1                         
ICE751I 0 C5-K26318 C6-K90007 C7-K90000 C8-K23476 E4-K90007 C9-BASE   E5-K31980
ICE193I 0 ICEAM2 ENVIRONMENT IN EFFECT - ICEAM2 INSTALLATION MODULE SELECTED   
ICE088I 5 USERIDC.S1      .        , INPUT LRECL = 88, BLKSIZE = 88, TYPE = FB
ICE093I 0 MAIN STORAGE = (MAX,10485760,10461184)                               
ICE156I 0 MAIN STORAGE ABOVE 16MB = (8404992,8388608)                           
ICE127I 0 OPTIONS: OVFLO=RC4 ,PAD=RC0 ,TRUNC=RC0 ,SPANINC=RC4 ,VLSCMP=N,SZERO=Y,
ICE128I 0 OPTIONS: SIZE=10485760,MAXLIM=2097152,MINLIM=450560,EQUALS=Y,LIST=Y,ER
ICE129I 0 OPTIONS: VIO=Y,RESDNT=NONE,SMF=FULL ,WRKSEC=Y,OUTSEC=Y,VERIFY=N,CHALT=
ICE130I 0 OPTIONS: RESALL=12288,RESINV=0,SVC=109 ,CHECK=N,WRKREL=Y,OUTREL=Y,CKPT
ICE131I 0 OPTIONS: TMAXLIM=10485760,ARESALL=0,ARESINV=0,OVERRGN=16384,CINV=Y,CFW
ICE132I 0 OPTIONS: VLSHRT=N,ZDPRINT=Y,IEXIT=N,TEXIT=N,LISTX=N,EFS=NONE    ,EXITC
ICE133I 0 OPTIONS: HIPRMAX=OPTIMAL,DSPSIZE=128 ,ODMAXBF=0,SOLRF=Y,VLLONG=N,VSAMI
ICE235I 0 OPTIONS: NULLOUT=RC0                                                 
ICE084I 0 BSAM ACCESS METHOD USED FOR OUT                                       
ICE084I 0 BSAM ACCESS METHOD USED FOR T1                                       
ICE750I 0 DC 500000 TC 0 CS DSVVV KSZ 9 VSZ 9                                   
ICE752I 0 FSZ=5681 RC  IGN=0 E  AVG=100 0  WSP=738 C  DYN=0 0                   
ICE751I 2 BA-K22788 BB-K24705 DA-K28804                                         
ICE185A 0 AN S001  ABEND WAS ISSUED BY DFSORT, ANOTHER PROGRAM OR AN EXIT (PHASE
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Aug 18, 2008 4:28 pm    Post subject: Reply with quote

You have:

//*T1 DD DSN=&&T1,DISP=(MOD,PASS),UNIT=SYSDA,SPACE=(TRK,(5,5))
//T1 DD SYSOUT=*

You commented out the T1 data set, so you are using the T1 SYSOUT. That won't work because the job is writing to T1 and reading back from T1. When you try to read back from the T1 SYSOUT data set, you get the S001 ABEND. You need to use the T1 data set instead of the T1 SYSOUT.

However, once you fix that you'll find that what you're trying to do with SPLICE won't work.
_________________
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


Last edited by Frank Yaeger on Mon Aug 18, 2008 4:36 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon Aug 18, 2008 4:32 pm    Post subject: Reply with quote

rajen wrote:
Hi Kolusu,
It may sound like strange question but i am trying accomplish the same using SPLICE operator. Below is the jcl i have tried but it abends.

Could you please guide me where I am doing wrong?


Rajen,

Sigh! Did you even notice that you commented the temp file T1 declaration and are routing the records to sysout? You are getting an abend when the splice is trying to read the dataset t1 and t1 is a sysout dataset.

And what are you trying to accomplish here? Do you just want the contents of file1 to be populated in the first 3 records?

If that is case then use the following JCL

Code:

//S1      EXEC PGM=ICETOOL                                       
//TOOLMSG DD SYSOUT=*                                             
//DFSMSG  DD SYSOUT=*                                             
//IN1     DD *                                                   
AAA                                                               
BBB                                                               
CCC                                                               
/*                                                               
//IN2     DD *                                                   
001D 123 D123                                                     
012D 158 D453                                                     
213D 433 D423                                                     
765D 475 D234                                                     
469D 234 D856                                                     
//T1      DD DSN=&&T1,DISP=(MOD,PASS),UNIT=SYSDA,SPACE=(TRK,(5,5))
//OUT     DD SYSOUT=*                                             
//TOOLIN  DD *                                                   
 COPY FROM(IN2) TO(T1) USING(CTL2)                               
 COPY FROM(IN1) TO(T1) USING(CTL1)                               
 SPLICE FROM(T1) TO(OUT) ON(81,8,ZD) WITH(06,03)                 
/*                                                               
//CTL1CNTL DD *                                                   
 INREC BUILD=(5X,1,3,81:SEQNUM,8,ZD)                             
/*                                                               
//CTL2CNTL DD *                                                   
 INREC BUILD=(1,5,4X,10:6,8,81:SEQNUM,8,ZD)                       
/*                                                               


This will give you

Code:

001D AAA 123 D123
012D BBB 158 D453
213D CCC 433 D423


Hope this helps...

Cheers
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Mon Aug 18, 2008 6:20 pm    Post subject: Reply with quote

Oh my Bad!!!
I was trying to debug problem and forgot that I had commented out..Really sorry for wasting your time Frank/Kolusu.

However, Is there a way to achieve the same results using SPLICE operator?
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Aug 18, 2008 6:40 pm    Post subject: Reply with quote

Quote:
However, Is there a way to achieve the same results using SPLICE operator?


Kolusu showed you a very efficient way to do what you asked for.

If you could achieve the same results with SPLICE, it would require a copy pass of file1, a copy pass of file2, and a sort pass of file1 + file2. This would be less efficient than Kolusu's method which only requires a copy pass of file1 and a copy pass of file2 without the sort pass.

Please explain why you want to do this with SPLICE instead of the more efficient way Kolusu showed you. If we understood what you were trying to accomplish and why you thought you needed to use SPLICE, then maybe we could help you accomplish it or understand why SPLICE isn't the best way to do it.
_________________
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
View user's profile Send private message Send e-mail Visit poster's website
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Mon Aug 18, 2008 8:55 pm    Post subject: Reply with quote

Well Frank,
I totally agree with you that Kolusu's solution is best tuned as always...

When I saw this post, All I was trying to do is trying different method to achieve the same result. It was just an attempt to look at things differently.

And here is why I thought I might need SPLICE.

Input File1 :
Code:

AAA
BBB
CCC

Input File2:
Code:

001D 123 D123
012D 158 D453
213D 433 D423
765D 475 D234
469D 234 D856


So I thought If I can number file1 and file 2 data and then merge it, it would be possible to achieve the same with single pass.

So,

Code:

AAA    1
BBB    2
CCC   3


Code:

001D 123 D123  1
012D 158 D453  2
213D 433 D423  3
765D 475 D234  4
469D 234 D856  5


Upon merging them and sorting on SEQNUM,

Code:
AAA    1
001D 123 D123  1
BBB    2
012D 158 D453  2
CCC   3
213D 433 D423  3
765D 475 D234  4
469D 234 D856  5


So with this data I could think of only 1 SPLICE option. I had no specific requirement to achieve the same with SPLICE but as I said before I was trying accomplish same using different method.

It was in the best interest of providing different methods for solution and I really apologize if it meant anything different.
Back to top
View user's profile Send private message
shashank.sharma
Beginner


Joined: 18 Apr 2007
Posts: 16
Topics: 10

PostPosted: Tue Aug 19, 2008 8:48 am    Post subject: Reply with quote

Thank you all for your help!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group