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

JOIN KEYS to Compare two files using


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

New User


Joined: 24 Jan 2007
Posts: 59
Location: Texas

PostPosted: Wed Sep 03, 2008 9:26 pm
Reply with quote

I have a sort code that compares 2 files using JOIN KEYS and I create a reformatted output file that would take some fields from file 1 and some from file 2. Following is the code that I am using:

Code:
//JS001   EXEC PGM=SORT,REGION=0M                               
//*                                                             
//SYSOUT   DD SYSOUT=*                                               
//*                                                             
//SORTJNF1 DD DISP=SHR,DSN=Qual1.file1
//SORTJNF2 DD DISP=SHR,DSN=Qual2.file2
//*                                                             
//SORTOUT  DD DISP=SHR,DSN=Qual3.file3               
//*                                                             
//SYSIN    DD *                                                 
  JOINKEYS FILE=F1,FIELDS=(3,4,A,7,6,A,1,2,A)                   
  JOINKEYS FILE=F2,FIELDS=(1,4,A,5,6,A,11,2,A)                 
  REFORMAT FIELDS=(F1:1,31,F2:13,19,F1:51,692)   
  SORT FIELDS=COPY                               
/*   



In the above mentioned code I am taking a 19 byte field from the 13th position of file2 and all the remaining bytes from file1. But I have an extra condition to be added:

If the 19th byte starting from the 13th position in file2 is spaces then I need to take the same position from file1

Can somebody please help me in adding the condition
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Sep 04, 2008 9:24 am
Reply with quote

Quote:
If the 19th byte starting from the 13th position in file2 is spaces then I need to take the same position from file1
Hello rarvins,

When the above condition satisifes, do you want to copy the entire 19 bytes from file2 or just the 19th byte alone starting from 13th position?

Thanks,
Arun
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: Thu Sep 04, 2008 10:11 am
Reply with quote

Hello,

Please post a small amount of sample input and the output you want from that input.
Back to top
View user's profile Send private message
rarvins

New User


Joined: 24 Jan 2007
Posts: 59
Location: Texas

PostPosted: Thu Sep 04, 2008 8:42 pm
Reply with quote

File1:
Code:

====
(1-2)         (3-6)            (7-12)             (13-31)             
1------------ 2--------------- 3----------------- 4-------------------
           90        116088625            37448446 374314012010768   
           90        128187385          160318665 374314012032267   


File2:
Code:

====
(1-4)            (5-10)             (11-12)       (13-31)             
1--------------- 2----------------- 3------------ 4-------------------
        116088625          37448446            90 4444444444444444   
        128187385        160318665            90 ________________

Where __ stands for blanks in file2

The output of my code would be as follows:
Code:

============================

(1-2)         (3-6)            (7-12)             (13-31)             
1------------ 2--------------- 3----------------- 4-------------------
           90        116088625            37448446 4444444444444444   
           90        128187385          160318665 ________________

If you see the output of my existing code bytes 13-31 alone have been taken from file2 irrespective of it containing a value or a blank.

What I need help on is to populate the 13-31 bytes from file2 only if there is a valid value present. IF positions 13-31 in file2 is spaces then i have to populate the output file from file1 positions 13-31. So the output should be
Code:

(1-2)         (3-6)            (7-12)             (13-31)             
1------------ 2--------------- 3----------------- 4-------------------
           90        116088625            37448446 444444444444444   
           90        128187385          160318665 374314012032267 

Hope this helps.

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

Moderator


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

PostPosted: Thu Sep 04, 2008 8:55 pm
Reply with quote

rarvins,

Its really difficult for somebody to understand the data positions in your sample data. Can you please post the data using the "Code" tag.

Thanks,
Arun
Back to top
View user's profile Send private message
rarvins

New User


Joined: 24 Jan 2007
Posts: 59
Location: Texas

PostPosted: Thu Sep 04, 2008 10:02 pm
Reply with quote

I think its been changed now arcvns. Please let me know if I need to do anything else
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: Thu Sep 04, 2008 10:06 pm
Reply with quote

Hello,

Please re-post the input and output data without all of the dashes. Also, make sure the data is the proper length. The data posted does not always appear to match the specified length.

If you both "Code" the data as well as present it similar to data shown with COLS in tso/ispf, you can get something like:
Code:

         1         2         
....+....0....+....0
903456more


Use the Preview to check how your post will appear to toe forum. After you Preview and are satisfied with the post, click Submit.
Back to top
View user's profile Send private message
rarvins

New User


Joined: 24 Jan 2007
Posts: 59
Location: Texas

PostPosted: Fri Sep 05, 2008 1:39 am
Reply with quote

Code:
 File 1:                       
 9012347891021111111111111111111
 9034567891122222222222222222222
                               
 File 2:                       
 1234789102903333333333333333333
 345678911290                   
                               
 Current output:               
 9012347891023333333333333333333
 903456789112                   
                               
 Expected output:               
 9012347891023333333333333333333
 9034567891122222222222222222222


I have changed the sample input and output so that it matches the lengths and the positions properly. Sorry for the inconvenience caused.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Fri Sep 05, 2008 10:17 am
Reply with quote

Hello rarvins,

The below SYNCSORT card will do what you asked for. I have also considered the 692 bytes from the file-1 as posted in your original requirement.
Code:
//SYSIN    DD *                                           
  JOINKEYS FILE=F1,FIELDS=(3,10,A,1,2,A)                   
  JOINKEYS FILE=F2,FIELDS=(1,10,A,11,2,A)                 
  REFORMAT FIELDS=(F1:1,31,F2:13,19,F1:51,692)             
  INREC IFTHEN=(WHEN=(32,19,CH,EQ,C' '),OVERLAY=(32:13,19))
  SORT FIELDS=COPY                                         
  OUTREC BUILD=(1,12,32,711)                               
/* 

Thanks,
Arun
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 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