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

Compare 2 files based on keys and replace data in 2nd file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Kunal Surpurkar

New User


Joined: 15 Nov 2012
Posts: 47
Location: India

PostPosted: Mon Jan 27, 2014 10:01 pm
Reply with quote

Dear Team,

I have a requirement wherein, I need to sort 2 files each of RECFM=VB, LRECL=300 based on 2 key fields. These two files have different structures.

Key fields in both the files are IPAIPRO and CONTMES.

First file :

IPAIPRO starts at 1st position and its length is 7
CONTMES starts at 194 position and its length is 4.

Second file :

IPAIPRO starts at 1st position and its length is 7
CONTMES starts at 218 position and its length is 4.

I have used the join keys concept here to get the matching records.

Code:
JOINKEYS FILE=F1,FIELDS=(5,7,A,222,4,A),SORTED,NOSEQCK   
JOINKEYS FILE=F2,FIELDS=(5,7,A,198,4,A),SORTED,NOSEQCK   
OPTION COPY                                               
REFORMAT FIELDS=(F1:5,261)                               
OUTFIL FNAMES=COMMON



Apart from getting the matching records, I need to replace the data from 202 column to 216 (length=15) of second file to 192 position of first file.
Also, replace the data from 217 column (15 length) of second file to 207 position of first file.
And also, replace the data from 232 column (15 length) of second file to 177 position of first file in the matched common output file.


It would be really great if someone can provide me with the JCL which does the above functionality.

Kindly let me know incase more information is needed.

Thanks a lot in advance.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Jan 27, 2014 10:36 pm
Reply with quote

As you have posted in the JCL section of the forum I presume you want the SYNCSORT JCL. This is described in the SYNCSORT manual or you could simply look at the JCL used by other sort executions in your shop.

But...JCL cannot do what you are wanting - it will only tell the OS what program you want run and what resources it needs.

To get Syncsort to do what you want you have to give it control 'cards' which you should find in the Syncsort manual. You will also find examples throughout the JCL part of the forum and you may find that the DFSort equivalent will also work.
Back to top
View user's profile Send private message
Kunal Surpurkar

New User


Joined: 15 Nov 2012
Posts: 47
Location: India

PostPosted: Mon Jan 27, 2014 11:01 pm
Reply with quote

Dear Nic,

Thanks for the reply.

Yes, I am speaking about JOIN KEYS in SORT utility. I could get the matching records based on the keys as mentioned above. This, I could do using the example posted in the forum.

However, I could not find any example related to replacing the data from the 2nd file into 1st file based on the fields of the matched file which is obtained from JOIN KEYS SORT.

If you can let me know the syntax to include these conditions(Replacing the data) in JOIN KEYS, It would be really helpful to me.

Thanks a lot !
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Jan 28, 2014 1:55 pm
Reply with quote

Kunal,

Why not write another output file with required fields from both files.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2945
Location: NYC,USA

PostPosted: Tue Feb 04, 2014 6:25 am
Reply with quote

Kunal,

Welcome to the forum, a little search could give you close to what is expected, please have a look at the below link and see if that helps to you.. icon_smile.gif

ibmmainframes.com/about58979-0.html
Back to top
View user's profile Send private message
Kunal Surpurkar

New User


Joined: 15 Nov 2012
Posts: 47
Location: India

PostPosted: Fri Feb 07, 2014 6:57 pm
Reply with quote

Dear Team,

Thanks for the help provided. I got what I wanted using the below sort card.

Code:
JOINKEYS F1=IN1,FIELDS=(5,7,A,222,4,A),SORTED,NOSEQCK     
JOINKEYS F2=IN2,FIELDS=(5,7,A,198,4,A),SORTED,NOSEQCK     
REFORMAT FIELDS=(F1:5,172,F2:232,15,F1:192,109)           
SORT FIELDS=COPY


Thanks a lot for your time :-)
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2945
Location: NYC,USA

PostPosted: Tue Feb 11, 2014 1:30 pm
Reply with quote

Glad you have got it, but you said they are VB files also did you check the above link?
Back to top
View user's profile Send private message
Kunal Surpurkar

New User


Joined: 15 Nov 2012
Posts: 47
Location: India

PostPosted: Tue Feb 11, 2014 3:47 pm
Reply with quote

Dear Rohit,

Yes, they are VB files. Hence, I used position 5 in JOINKEYS and REFORMAT FIELDS.

And yes, I did go through the link posted by you. It was helpful too :-)

Once again, Thanks for your time !!
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Selecting the max value from a file. DFSORT/ICETOOL 3
No new posts Change history of vsam file. JCL & VSAM 3
No new posts Merge files with a key and insert a b... DFSORT/ICETOOL 6
No new posts Split large FB file based on Key coun... DFSORT/ICETOOL 4
No new posts EMPTY file check scenario JCL & VSAM 6
Search our Forums:

Back to Top