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

Copy to output only if two occurences found.


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

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Feb 05, 2009 11:44 pm
Reply with quote

Hi,

I want to match two files and copy content from file-2 only if the content from file-1 found twice in the same record in file-2.

File-1: RECFM=FB, LRECL=80
Code:

MAHIMA
RASIMA
ARULAN
RAJAHA


File-2: RECFM=FB, LRECL=80
Code:

MAHIMA 2009 10-10-08 MAHIMA
RUBENS 2009 01-10-08 RUBENS
SASTRY 2009 12-01-08 SASTRY
ARULAN 2008 24-12-08 ARULAN
CHANDI 2009 09-06-07 CHANDI


Expected output: RECFM=FB, LRECL=80
Code:

MAHIMA 2009 10-10-08 MAHIMA
ARULAN 2008 24-12-08 ARULAN


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

Moderator


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

PostPosted: Fri Feb 06, 2009 2:22 am
Reply with quote

Ramsri,

Its not quite clear, What do you mean by "content from file-1 found twice". Does it mean same values for field-1 and field-4 in file-2? What is the key for file comparison in file-2 ----> field-1 or field-4?. Your input shows same values for these fields? What if any of these has a different value.

Post all possible combinations of input and the expected output along with a proper definition of the rules.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Fri Feb 06, 2009 6:05 pm
Reply with quote

Arun,

All your assumptions are correct. The match must be done on field-1 and field-4. Both are key fields and will have same values.

fiel-1:
Code:

MAHIMA
RASIMA
ARULAN
RUBENS
RAJAHA


file-2:
Code:

MAHIMA 2009 10-10-08 MAHIMA
RUBENS 2009 01-10-08 RUBANS
SASTRY 2009 12-01-08 SASTRY
ARULAN 2008 24-12-08 ARULAN
CHANDI 2009 09-06-07 CHADNI


Output:
Code:

MAHIMA 2009 10-10-08 MAHIMA
ARULAN 2008 24-12-08 ARULAN


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

Moderator


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

PostPosted: Fri Feb 06, 2009 7:38 pm
Reply with quote

Quote:
Both are key fields and will have same values
If that is the case, would nt it be a direct SYNCSORT JOIN application matching the first 6 characters in both the files? Try this and post back if you come across any issues. Good luck. icon_smile.gif
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Fri Feb 06, 2009 10:27 pm
Reply with quote

Arun, JOIN holds good if I had to compare only the first 6 bytes as you said. But, what happens in this case where the field-1 & field-4 have different values?

Code:

RUBENS 2009 01-10-08 RUBANS
CHANDI 2009 09-06-07 CHADNI


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

Moderator


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

PostPosted: Fri Feb 06, 2009 10:53 pm
Reply with quote

Ramsri,

I m sorry. I dint notice the differences in your recent sample.

I dont have access to mainframe now. But I can show you a possible way which you can give a try. Post back if you come across any issues. Goodluck icon_smile.gif
Code:
JOINKEYS FILE=F1,FIELDS=(1,6,A)
JOINKEYS FILE=F2,FIELDS=(1,6,A),
         INCLUDE=(1,6,CH,EQ,22,6,CH)
REFORMAT FIELDS=(F2:1,27)
SORT FIELDS=COPY
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Fri Feb 06, 2009 11:01 pm
Reply with quote

Arun, wonderful.....you can never go wrong. It has worked as expected.

Thank you very much. icon_biggrin.gif
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Fri Feb 06, 2009 11:03 pm
Reply with quote

Arun, Can we have even multiple comparisons?

Code:

JOINKEYS FILE=F2,FIELDS=(1,6,A),
         INCLUDE=(1,6,CH,EQ,22,6,CH,EQ,72,6,CH)


Thanks.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Fri Feb 06, 2009 11:12 pm
Reply with quote

Ok..I got it how to get it worked for multiple occurences !

Code:

JOINKEYS FILE=F2,FIELDS=(1,6,A),
         INCLUDE=(1,6,CH,EQ,22,6,CH,AND,1,6,CH,EQ,72,6,CH)


Correct me if I am wrong.

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

Moderator


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

PostPosted: Sat Feb 07, 2009 9:04 am
Reply with quote

You're welcome. icon_smile.gif
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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts How I Found a Bug in a FORTRAN Compiler All Other Mainframe Topics 4
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
Search our Forums:

Back to Top