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 

How to merge 2 files with some indicator in output file as ?

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


Joined: 07 Jun 2006
Posts: 11
Topics: 7
Location: India

PostPosted: Thu Aug 03, 2006 1:07 am    Post subject: How to merge 2 files with some indicator in output file as ? Reply with quote

How to merge 2 files with some indicator in output file as it differentiate from 2 files input is merged using sort or Icetool ?
_________________
Raki
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Thu Aug 03, 2006 5:30 am    Post subject: Reply with quote

vraki,

Can you be more clear in your requirement as what exactly you are looking for ? Post some example data along with file DCB properties
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
vraki
Beginner


Joined: 07 Jun 2006
Posts: 11
Topics: 7
Location: India

PostPosted: Fri Aug 04, 2006 5:09 am    Post subject: Reply with quote

This is the code need to be updated
Code:

//SEQNUM01 EXEC PGM=SORT                       
//SYSPRINT DD SYSOUT=*                         
//SYSOUT   DD SYSOUT=*                         
//INPUT1   DD *                                 
AAA 1                                           
BBB 2                                           
CCC 3                                           
//INPUT2   DD *                                 
AAA 4                                           
BBB 1                                           
CCC 2                                           
//SORTOUT  DD DSN=TPLB.MERGE.OUTPUT,DSN=SHR     
//SYSIN   DD *                                 
  SORT FIELDS=COPY                             
/*                                             
//                                             


Output should get as below -- 1 indicates from first input file & 2 indicates from second input file in the last byte of the ouput records.
Code:

AAA 1 1
AAA 4 2 
BBB 1 2                                       
BBB 2 1
CCC 2 2                                           
CCC 3 1

_________________
Raki
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Aug 04, 2006 5:24 am    Post subject: Reply with quote

vraki,

Try this.

Code:

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                         
AAA 1                                                   
BBB 2                                                   
CCC 3                                                   
//SORTOUT DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN   DD *                                         
  SORT FIELDS=COPY                                     
  OUTREC FIELDS=(1,6,C'1')                             
/*                                                     
//STEP0200 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *
AAA 4                                                   
BBB 1                                                   
CCC 2                                                   
//SORTOUT DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                       
  OUTREC FIELDS=(1,6,C'2')                               
/*                                                       
//STEP0300 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DSN=&T1,DISP=SHR                           
//         DD DSN=&T2,DISP=SHR                           
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  SORT FIELDS=(1,3,CH,A,7,1,CH,A)                       
/*   


Hope this helps...

Cheers

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


Joined: 07 Jun 2006
Posts: 11
Topics: 7
Location: India

PostPosted: Sun Aug 06, 2006 11:31 pm    Post subject: Reply with quote

I know it's working in 3 steps but my requirement is in single step.Please guide me on this?
_________________
Raki
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Aug 07, 2006 5:22 am    Post subject: Reply with quote

vraki wrote:

I know it's working in 3 steps but my requirement is in single step.Please guide me on this?


Well did you mean 1 pass of data or just 1 step ?. Using Icetool you can cram 3 passes of data in a single step.

As far as I know you CANNOT get the desired results with a single pass of data using SORT. However if easytrieve is an option then you can get the desired results with a single pass of data.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Mon Aug 07, 2006 11:34 am    Post subject: Reply with quote

Raki,

Here's a DFSORT/ICETOOL job that will do what you asked for. Note that I'm sorting on 1,3 and then 5,1 (rather than 7,1) to get the output you asked for.

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1  DD *
AAA 1
BBB 2
CCC 3
/*
//IN2  DD *
AAA 4
BBB 1
CCC 2
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SORT FROM(T1) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(7:C'1')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(7:C'2')
/*
//CTL3CNTL DD *
  SORT FIELDS=(1,3,CH,A,5,1,CH,A)
/*

_________________
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
vraki
Beginner


Joined: 07 Jun 2006
Posts: 11
Topics: 7
Location: India

PostPosted: Tue Aug 08, 2006 1:13 am    Post subject: Reply with quote

Thank you Frank.It's working fine........
_________________
Raki
Back to top
View user's profile Send private message
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Tue Aug 08, 2006 3:23 am    Post subject: Reply with quote

kolusu wrote:
As far as I know you CANNOT get the desired results with a single pass of data using SORT.

Kolusu,
It is possible if you 'merge' Frank's solution with the group keys technique treating the 2 files as 2 groups. There is only 1 hdr to concat in front of each file. I think Frank knows this method but doesn't post it because of a MVS restriction about concatenation problem.

Alain
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Aug 08, 2006 5:35 am    Post subject: Reply with quote

Quote:

It is possible if you 'merge' Frank's solution with the group keys technique treating the 2 files as 2 groups.There is only 1 hdr to concat in front of each file.


Alain,

Something like this ?

Code:

//SORTIN DD DSN=HDR1,
//       DD *
AAA 1
BBB 2
CCC 3
/*
//       DD DSN=HDR2,
//       DD *
AAA 4 
BBB 1
CCC 2
/*



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


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Tue Aug 08, 2006 9:17 am    Post subject: Reply with quote

Kolusu,

Exactly.
In fact I posted something similar on other forum. That's why I didn't put the link here for convenience...
Of course it will not work when recfm=FB & lrecl are different

Alain
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Aug 08, 2006 10:16 am    Post subject: Reply with quote

Good one Alain,

I just tried it and got the desired result. The header file is also FB dataset with an lrecl of 80 and has just 1 rec as follows
Code:

HDR



Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN=Header file,DISP=SHR                         
//         DD *                                                 
AAA 1                                                           
BBB 2                                                           
CCC 3                                                           
//         DD DSN=header file,DISP=SHR                         
//         DD *                                                 
AAA 4                                                           
BBB 1                                                           
CCC 2                                                           
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  SORT FIELDS=(1,3,CH,A,11,8,CH,A)                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(11:SEQNUM,8,ZD)),           
        IFTHEN=(WHEN=(1,3,CH,NE,C'HDR'),                       
                OVERLAY=(19:SEQNUM,8,ZD,                       
                         11:11,8,ZD,SUB,19,8,ZD,M11,LENGTH=8)),
        IFTHEN=(WHEN=NONE,                                     
                OVERLAY=(11:SEQNUM,8,ZD))                       
 OUTFIL OMIT=(1,3,CH,EQ,C'HDR'),                               
 OUTREC=(1,6,18,1)                                             
/*                           


The output from this job is

Code:

AAA 1 1
AAA 4 2
BBB 2 1
BBB 1 2
CCC 3 1
CCC 2 2


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


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Wed Sep 06, 2006 9:51 am    Post subject: Reply with quote

What if I need the output as

AAA 1 4
BBB 2 1
CCC 3 2

- Martin
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: Wed Sep 06, 2006 10:59 am    Post subject: Reply with quote

Then you could use a DFSORT/ICETOOL job like this:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1  DD *
AAA 1
BBB 2
CCC 3
/*
//IN2  DD *
AAA 4
BBB 1
CCC 2
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,3,CH) WITH(7,1)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(7:X)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(7:5,1)
/*

_________________
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
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