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
 

 

Copy to output only if two occurences found.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Copy to output only if two occurences found.
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: 2275
Location: @my desk

PostPosted: Fri Feb 06, 2009 2:22 am    Post subject:
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    Post subject: Reply to: Copy to output only if two occurences found.
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: 2275
Location: @my desk

PostPosted: Fri Feb 06, 2009 7:38 pm    Post subject:
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    Post subject: Reply to: Copy to output only if two occurences found.
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: 2275
Location: @my desk

PostPosted: Fri Feb 06, 2009 10:53 pm    Post subject:
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    Post subject: Reply to: Copy to output only if two occurences found.
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    Post subject:
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    Post subject:
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: 2275
Location: @my desk

PostPosted: Sat Feb 07, 2009 9:04 am    Post subject:
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    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 find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts copy SEQ to PDS and create stats steve-myers JCL & VSAM 5 Thu Apr 27, 2017 1:15 am
No new posts Copy load modules and alias vasanthz IBM Tools 5 Thu Apr 20, 2017 6:31 am
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm


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