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

Compare two files and write 3 output files..


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

New User


Joined: 24 Mar 2012
Posts: 17
Location: pune

PostPosted: Tue Mar 27, 2012 10:08 pm
Reply with quote

Hi,

I have below requirements..
There are 2 seq files..having comparing filed say of 5 places,numeric...but it start for first file is from 10-14 and for 2nd file from 20-24..
i.e

file 1

12345
22222
14852
78965

file2
12345
78965
98745
56987

so I need 3 output file having:

output1: Present only in first file i.e

22222
14852

output2: Present only in second file i.e

98745
56987

output3:Present in both file i.e

12345
78965

Regards,
-Ravi
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: Tue Mar 27, 2012 10:20 pm
Reply with quote

It it required to be in that output order?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Mar 27, 2012 10:21 pm
Reply with quote

Ravi Kirti,

Use the following DFSORT JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//INA      DD *                                                 
----+----1----+----2----+----3----+----4----+----5----+----6----
         12345                                                 
         22222                                                 
         14852                                                 
         78965                                                 
//INB      DD *                                                 
                   12345                                       
                   78965                                       
                   98745                                       
                   56987                                       
//ONLYF1   DD SYSOUT=*                                         
//ONLYF2   DD SYSOUT=*                                         
//BOTH     DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  JOINKEYS F1=INA,FIELDS=(10,5,A)                               
  JOINKEYS F2=INB,FIELDS=(20,5,A)                               
  JOIN UNPAIRED                                                 
  REFORMAT FIELDS=(F1:1,80,F2:1,80,?)     
                     
  OUTFIL FNAMES=ONLYF1,BUILD=(01,80),INCLUDE=(161,1,CH,EQ,C'1')
  OUTFIL FNAMES=ONLYF2,BUILD=(81,80),INCLUDE=(161,1,CH,EQ,C'2')
  OUTFIL FNAMES=BOTH,BUILD=(1,80),SAVE                         
//*
Back to top
View user's profile Send private message
Ravi Kirti

New User


Joined: 24 Mar 2012
Posts: 17
Location: pune

PostPosted: Tue Mar 27, 2012 11:05 pm
Reply with quote

Bill Woodger wrote:
It it required to be in that output order?


Hi Bill,

I need the comparing filed in respective files.

Thanks!
-Ravi
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Mar 27, 2012 11:13 pm
Reply with quote

Quote:
I need the comparing filed in respective files.


Huh? What does that mean?

A better answer to Bill's question would be "Yes" or "No".
Back to top
View user's profile Send private message
Ravi Kirti

New User


Joined: 24 Mar 2012
Posts: 17
Location: pune

PostPosted: Tue Mar 27, 2012 11:21 pm
Reply with quote

Skolusu wrote:
Ravi Kirti,

Use the following DFSORT JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//INA      DD *                                                 
----+----1----+----2----+----3----+----4----+----5----+----6----
         12345                                                 
         22222                                                 
         14852                                                 
         78965                                                 
//INB      DD *                                                 
                   12345                                       
                   78965                                       
                   98745                                       
                   56987                                       
//ONLYF1   DD SYSOUT=*                                         
//ONLYF2   DD SYSOUT=*                                         
//BOTH     DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  JOINKEYS F1=INA,FIELDS=(10,5,A)                               
  JOINKEYS F2=INB,FIELDS=(20,5,A)                               
  JOIN UNPAIRED                                                 
  REFORMAT FIELDS=(F1:1,80,F2:1,80,?)     
                     
  OUTFIL FNAMES=ONLYF1,BUILD=(01,80),INCLUDE=(161,1,CH,EQ,C'1')
  OUTFIL FNAMES=ONLYF2,BUILD=(81,80),INCLUDE=(161,1,CH,EQ,C'2')
  OUTFIL FNAMES=BOTH,BUILD=(1,80),SAVE                         
//*


Thanks Skolusu for prompt!

I just need some clarifications:

"
REFORMAT FIELDS=(F1:1,80,F2:1,80,?)

OUTFIL FNAMES=ONLYF1,BUILD=(01,80),INCLUDE=(161,1,CH,EQ,C'1')

"

why we should quote

REFORMAT FIELDS=(F1:1,80,F2:1,80,?)
BUILD=(01,80)
And in INCLUDE, why we will compare one character position from 161 with char is '1' or '2'.

Will the JCL affect(other than in JOINKEYS statement) if I say my comparing field start from 567 position for first and 678 for 2nd file?
Back to top
View user's profile Send private message
Ravi Kirti

New User


Joined: 24 Mar 2012
Posts: 17
Location: pune

PostPosted: Tue Mar 27, 2012 11:27 pm
Reply with quote

Frank Yaeger wrote:
Quote:
I need the comparing filed in respective files.


Huh? What does that mean?

A better answer to Bill's question would be "Yes" or "No".


Sorry, I mean to say Yes.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Mar 27, 2012 11:38 pm
Reply with quote

Ravi Kirti wrote:
Thanks Skolusu for prompt!

I just need some clarifications:

"
REFORMAT FIELDS=(F1:1,80,F2:1,80,?)

OUTFIL FNAMES=ONLYF1,BUILD=(01,80),INCLUDE=(161,1,CH,EQ,C'1')

"

why we should quote

REFORMAT FIELDS=(F1:1,80,F2:1,80,?)
BUILD=(01,80)
And in INCLUDE, why we will compare one character position from 161 with char is '1' or '2'.


Start reading about JOINKEYS which is explained in detail here

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA60/4.0

Ravi Kirti wrote:

Will the JCL affect(other than in JOINKEYS statement) if I say my comparing field start from 567 position for first and 678 for 2nd file?


Depends what the RECFM of the input files is. Why do you have to lead us on a wild goose chase? How hard is it post the actual requirement ? Post detailed information on what you're trying to accomplish. Do not make people guess what you mean. This will give you a much better chance of getting a good answer to your question.
Back to top
View user's profile Send private message
Ravi Kirti

New User


Joined: 24 Mar 2012
Posts: 17
Location: pune

PostPosted: Wed Mar 28, 2012 4:37 pm
Reply with quote

Hi Skolusu,

I tested the code as per your suggestion. Getting abend..
Below is the SYSOUT result.

[
SYNCSORT LICENSED FOR CPU SERIAL NUMBER 41BA6, MODEL 2817 602
SYSIN :
OPTION COPY
JOINKEYS F1=INA,FIELDS=(10,5,A)
*
JOINKEYS F2=INB,FIELDS=(20,5,A)
*
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,80,F2:1,80,?)
*

OUTFIL FNAMES=ONLYF1,BUILD=(01,80),INCLUDE=(161,1,CH,EQ,C'1')
OUTFIL FNAMES=ONLYF2,BUILD=(81,80),INCLUDE=(161,1,CH,EQ,C'2')
OUTFIL FNAMES=BOTH,BUILD=(1,80),SAVE
WER268A JOINKEYS STATEMENT: SYNTAX ERROR
WER268A JOINKEYS STATEMENT: SYNTAX ERROR
WER268A REFORMAT STATEMENT: SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
]

I appologies for insufficiet details I povided earlier.

Actual file details is as follow:

file1

Organization . . . : PS
Record format . . . : FB
Record length . . . : 678
Block size . . . . : 27798

and the comparing field start from position 459.

file2

Organization . . . : PS
Record format . . . : FB
Record length . . . : 847
Block size . . . . : 9317

and the comparing field starts from position 496.


In output files i need comparing fields as requested above.

Please let me know where the code needs to be changed.

Thanks!
Ravi
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Wed Mar 28, 2012 4:55 pm
Reply with quote

Hello,

Quote:
WER268A


Indicates Syncsort is installed at your site. icon_exclaim.gif
Back to top
View user's profile Send private message
Ravi Kirti

New User


Joined: 24 Mar 2012
Posts: 17
Location: pune

PostPosted: Wed Mar 28, 2012 5:04 pm
Reply with quote

xknight wrote:
Hello,

Quote:
WER268A


Indicates Syncsort is installed at your site. icon_exclaim.gif


So Can you please suggest any thing to resolve it... icon_neutral.gif
Back to top
View user's profile Send private message
Ravi Kirti

New User


Joined: 24 Mar 2012
Posts: 17
Location: pune

PostPosted: Wed Mar 28, 2012 5:07 pm
Reply with quote

I missed one thing to say that the input files may have different counts of records...

say file 1 has 10,000.
file2 has 50,000.

Thanks!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Mar 28, 2012 5:13 pm
Reply with quote

Quote:
So Can you please suggest any thing to resolve it...

Kolusu and Frank are DSFORT developers,
they are happy to give advice on DFSORT, it is improper to expect their help on a competitor' s product!

topic moved where it belongs... JCL

it would be a demonstration of good manners and intelligence to find out, before posting, the sort product being used
JCL for SYNCSORT issues ( WER... messages )
DFSORT for IBM DFSORT ( ICE... messages )

in order to post in the proper section of the forum
and in order not to have people waste time on topics they are not <supposed> to answer!
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Wed Mar 28, 2012 6:01 pm
Reply with quote

You can try this code Ravi. Change it according to your requirement.

Code:

//S1    EXEC  PGM=SORT                     
//SYSPRINT DD SYSOUT=*                     
//SYSOUT  DD SYSOUT=*                                           
//SORTJNF1 DD *                             
         12345                             
         22222                             
         14852                             
         78965                             
//SORTJNF2 DD *                             
                   12345                   
                   78965                   
                   98745                   
                   56987                   
//ONLYF1   DD SYSOUT=*                     
//ONLYF2   DD SYSOUT=*                     
//ONLYF3   DD SYSOUT=*                     
//SYSIN    DD *                             
  OPTION COPY                               
  JOINKEYS FILE=F1,FIELDS=(10,5,A)                                 
  JOINKEYS FILE=F2,FIELDS=(20,5,A)                                 
  REFORMAT FIELDS=(F1:1,80,F2:1,80)                                 
  JOIN UNPAIRED                                                     
  OUTFIL FNAMES=ONLYF1,BUILD=(01,80),INCLUDE=(10,1,CH,NE,C' ',AND, 
         101,1,CH,NE,C' ')                                         
  OUTFIL FNAMES=ONLYF2,BUILD=(81,80),INCLUDE=(10,1,CH,EQ,C' ',AND, 
         101,1,CH,NE,C' ')                                         
  OUTFIL FNAMES=ONLYF3,BUILD=(1,80),SAVE                           


Thanks
-3nadh
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 Write line by line from two files DFSORT/ICETOOL 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
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
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
Search our Forums:

Back to Top