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

Merge two files without comparing


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

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 03, 2013 1:39 pm
Reply with quote

Hi,

I need to merge two columns from couple of files without comparing, I know files are in same sequence , I need to overlay some values from file2.

I tried with joinkey, but it asking me for joinkey and its comparing and changing the sequence of the file.

Requirement is to concatenate/merge (F1:1,93,F2:94,25,F1:119,13)
F1 is file1
F2 is File2

need not compare, need not sort, just overlay these F2 records

Please help me on this.

Code:


//S1   EXEC  PGM=SORT                                         
//SYSOUT DD SYSOUT=*                                           
//SORTJNF1 DD DSN=zxttdd.a1,DISP=SHR   
//SORTJNF2 DD DSN=zxttdd.b1,DISP=SHR   
//SORTOUT DD DSN=zxttdd.c1,DISP=OLD       
//SYSIN DD *                                                   
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION                 
  JOINKEYS FILE=F1,FIELDS=(67,17,A)                           
  JOINKEYS FILE=F2,FIELDS=(67,17,A)                           
  REFORMAT FIELDS=(F1:1,93,F2:94,25,F1:119,13)                 
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)           
  SORT FIELDS=COPY                                             
/*                                                             
         


regards,
Magesh
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jul 03, 2013 1:46 pm
Reply with quote

Why do you dont want to use Joinkeys?

Is that the requirement to be done without Joinkeys?
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 03, 2013 1:51 pm
Reply with quote

Joinkeys is sorting the file, hence sequence of the file is affected , I don't want to compare actually and I don't know the way to directly concatenate two columns. Hence I tried joinkey, Is there any way to just concatenate two columns from two different files, Sequence should be same as the input file.

Regards,
Magesh
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jul 03, 2013 1:59 pm
Reply with quote

What you could do is

use JNFCNTLn

To Add sequence number to both the files and join based on the sequence

Or

Did you try SORTED??

Code:
  JOINKEYS FILE=F1,FIELDS=(67,17,A),SORTED                           
  JOINKEYS FILE=F2,FIELDS=(67,17,A),SORTED
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 03, 2013 2:04 pm
Reply with quote

How do I do this, It would be great if you could share the code.
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 03, 2013 2:06 pm
Reply with quote

JOINKEYS FILE=F1,FIELDS=(67,17,A),SORTED is failed because joinkey I mentioned is out of sequence
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Jul 03, 2013 2:25 pm
Reply with quote

Not sure if it will override the sequence checking, but you could try

SORTED,NOSEQCK instead of SORTED
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 03, 2013 2:34 pm
Reply with quote

Still the sequence of the output file is changed icon_sad.gif

I think it is because of =(67,17,A) is there any way to avoid this 'A'
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jul 03, 2013 2:49 pm
Reply with quote

Check this example

Code:
//INA      DD *
DDD FIL1
AAA FIL1
BBB FIL1
CCC FIL1
//INB      DD *
DDD FIL2
AAA FIL2
BBB FIL2
CCC FIL2
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  JOINKEYS F1=INA,FIELDS=(81,3,A)
  JOINKEYS F2=INB,FIELDS=(81,3,A)
  REFORMAT FIELDS=(F1:1,10,F2:1,10)
//JNF1CNTL DD *
  INREC OVERLAY=(81:SEQNUM,3,ZD)
//JNF2CNTL DD *
  INREC OVERLAY=(81:SEQNUM,3,ZD)


Output

Code:
DDD FIL1  DDD FIL2
AAA FIL1  AAA FIL2
BBB FIL1  BBB FIL2
CCC FIL1  CCC FIL2
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 03, 2013 2:57 pm
Reply with quote

You example will work, if we have an empty column, Both of my files have complete data, no empty column, I cant give the length beyond the file RECL.

Regards,
Magesh
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Jul 03, 2013 3:01 pm
Reply with quote

I suggest that you try the code before saying it will not work for you.

Why do you think that you need a "empty column" ?
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jul 03, 2013 3:14 pm
Reply with quote

Quote:
You example will work, if we have an empty column, Both of my files have complete data, no empty column, I cant give the length beyond the file RECL.


Can you please try to make the code as per your input data using my example?

Let us know the output that you got

Please do not comment without trying it icon_sad.gif
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 03, 2013 3:15 pm
Reply with quote

Got the solution

From File1 I don't requires 94,25 hence I can overlay the sequence number for file1 in 94th position, llly for file2 1 to 93 I can use for overlay.

Created the below code, It worked fine, Thanks Expat and Pandora-Box
Code:

//SYSIN DD *                                                     
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION                   
  JOINKEYS FILE=F1,FIELDS=(94,7,A),SORTED,NOSEQCK               
  JOINKEYS FILE=F2,FIELDS=(1,7,A),SORTED,NOSEQCK                 
  REFORMAT FIELDS=(F1:1,93,F2:94,25,F1:119,13)                   
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)             
  SORT FIELDS=COPY                                               
/*                                                               
//JNF1CNTL DD *                                                 
   INREC OVERLAY=(94:SEQNUM,7,ZD)                               
//JNF2CNTL DD *                                                 
   INREC OVERLAY=(1:SEQNUM,7,ZD)                                 
/*
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jul 03, 2013 9:01 pm
Reply with quote

Hello,

You still do not understand . . .

You Need to try the posted code. Not just throw something else together. Your "solution" will not work in every case. The sample posted will.

The example builds a sequence number beyond the end of the input record and discards this in the reformat.

If you are unwilling to try the code provided, why ask in the first place?

If you intend to use the "works for this format only" code you showed, you have wasted everyone's time . . . icon_sad.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 04, 2013 5:29 am
Reply with quote

Well done for spotting that you can re-use part of the F1 record.

You can further cut down your F1 and your F2 just to the minimum (only the data you need). Might not make much difference this time, but it is a good habit to get in to, as if you needed to have the JOINKEYS do a SORT (for a different requirement), the less data the better.
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 Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top