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
 

 

Compare two files and write 3 output files..

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Compare two files and write 3 output files..
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Mar 27, 2012 10:20 pm    Post subject: Reply to: Compare two files and write 3 output files..
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    Post subject: Reply to: Compare two files and write 3 output files..
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    Post subject: Re: Reply to: Compare two files and write 3 output files..
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 Moderator


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

PostPosted: Tue Mar 27, 2012 11:13 pm    Post subject:
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    Post subject: Re: Reply to: Compare two files and write 3 output files..
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    Post subject:
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    Post subject: Re: Reply to: Compare two files and write 3 output files..
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

http://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    Post subject: Reply to: Compare two files and write 3 output files..
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    Post subject:
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    Post subject:
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    Post subject: Reply to: Compare two files and write 3 output files..
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Mar 28, 2012 5:13 pm    Post subject: Reply to: Compare two files and write 3 output files..
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    Post subject: Reply to: Compare two files and write 3 output files..
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM 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 Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 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 Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm


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