Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Merge two files without comparing

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Wed Jul 03, 2013 1:39 pm    Post subject: Merge two files without comparing
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

Moderator


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

PostPosted: Wed Jul 03, 2013 1:46 pm    Post subject:
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: 159
Location: Chennai

PostPosted: Wed Jul 03, 2013 1:51 pm    Post subject: Reply to: Merge two files without comparing
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

Moderator


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

PostPosted: Wed Jul 03, 2013 1:59 pm    Post subject:
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: 159
Location: Chennai

PostPosted: Wed Jul 03, 2013 2:04 pm    Post subject: Reply to: Merge two files without comparing
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: 159
Location: Chennai

PostPosted: Wed Jul 03, 2013 2:06 pm    Post subject: Reply to: Merge two files without comparing
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: 8593
Location: Back in jolly old England

PostPosted: Wed Jul 03, 2013 2:25 pm    Post subject:
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: 159
Location: Chennai

PostPosted: Wed Jul 03, 2013 2:34 pm    Post subject: Reply to: Merge two files without comparing
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

Moderator


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

PostPosted: Wed Jul 03, 2013 2:49 pm    Post subject:
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: 159
Location: Chennai

PostPosted: Wed Jul 03, 2013 2:57 pm    Post subject: Reply to: Merge two files without comparing
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: 8593
Location: Back in jolly old England

PostPosted: Wed Jul 03, 2013 3:01 pm    Post subject:
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

Moderator


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

PostPosted: Wed Jul 03, 2013 3:14 pm    Post subject:
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: 159
Location: Chennai

PostPosted: Wed Jul 03, 2013 3:15 pm    Post subject: Reply to: Merge two files without comparing
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

Site Director


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

PostPosted: Wed Jul 03, 2013 9:01 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Jul 04, 2013 5:29 am    Post subject: Re: Reply to: Merge two files without comparing
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Adding records from two files into on... shiitiizz SYNCSORT 4 Mon Sep 19, 2016 8:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us