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

Need to search in 3 files and write output - Syncsort v1.2.3


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: Tue Mar 24, 2009 9:35 pm
Reply with quote

Hi,

We are using SYNCSORT FOR Z/OS 1.2.3.1R. My requirement is as explained at the bottom after these files.

Input File-1:
Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7
XXX012 ACCAF8AYCCV4DT4GARJ67LXVMH8NE9QQ5T3XUDBVK8VOEVOHVORVZA 201
XXX012 W1SZ23AB1AB2AB3AB4AB5AB6AB7AB8AB9BA1BA2BA3BA4BA5ZSDX1U 202
XXX012 W1YY231SD91U                                           203
YYY013 ACCAF8AYCCV4DT4GARJ67LXVMH8NE9QQ5T3XUDBVK8VOEVOHVORVZA 201
YYY013 W1YY231SA51U                                           202


Input File-2:
Code:

ACC
AF8
J67


Input File-3:
Code:

1SA
1SB
1SD


Input File-4:
Code:

51U
91U
71U


Requirement: Read the "Input File-1" from 18th column for each 3 bytes upto 61st column and search those 3 byte string in"Input File-2", "Input File-3" & "Input File-4". If found, should write to three different output files. Means, say "ACC" & "AF8" are found in "Input File-2" then the should go to "Output File-2". If "1SA" is found in "Input File-3" then it should go to "Output File-3" and if "91U" is found in "Input File-4" then it should go to "Output File-4".

Output File-2:
Code:

XXX012 ACC AF8
YYY013 ACC AF8


Output File-3:
Code:

XXX012 1SD
YYY013 1SA


Output File-4:
Code:

XXX012 91U
YYY013 51U


Please let me know if I have explained my requirement clearly.

Thanks for all your help.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Wed Mar 25, 2009 9:22 am
Reply with quote

Quote:
Read the "Input File-1" from 18th column
Is this 18th or 8th?
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Wed Mar 25, 2009 9:29 am
Reply with quote

Ramsri,

If you have only a few values to be checked as shown above, I think it would be much easier to go for a cobol solution.
Code:
Read the file-record into a structure with an array

Evaluate each element in the array
             When 'a' or 'b' or 'c'
                      Write Output1
             When 'd' or 'e' or 'f'
                      Write Output2
............
............
............
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Mar 25, 2009 11:55 am
Reply with quote

Arun, sorry.......it is 8th column only. They are not few values they are going to be 99 unique values we get. Is it possible to achieve using Syncsort?

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

Moderator


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

PostPosted: Wed Mar 25, 2009 12:07 pm
Reply with quote

Still I believe this is a good candidate to do some coding.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Mar 25, 2009 2:46 pm
Reply with quote

Arun, would you please post some pseudo code kind of thing so that I can try to come up with some COBOL for the same...........

I thought SORT is the best and fast to achieve it icon_sad.gif

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

Moderator


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

PostPosted: Wed Mar 25, 2009 3:57 pm
Reply with quote

Ramsri,

From whatever I understood so far,

1.Load all the key values into a ws-array along with an additional field to indicate which file it belongs to.
2.Read the input file.
3.For each key from the input, do a search in the ws-array.
4.If found, Populate the output record arrays based on the indicator.
5.Write the output record for each output file only if the respective output array has at least only entry.

Let me know if I missed something.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Mar 25, 2009 4:22 pm
Reply with quote

Arun, is it possible to do a file to file comparision if I have to do look-up in only one file. I am going to combine all the three files into one file because they come from three different tables and unique values are assured.

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

Moderator


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

PostPosted: Wed Mar 25, 2009 11:41 pm
Reply with quote

Quote:
is it possible to do a file to file comparision
Nothing that I can think of now. icon_rolleyes.gif
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: Wed Mar 25, 2009 11:48 pm
Reply with quote

Hello,

Suggest you have spent much more time trying to not write the code than it would have taken to have simply written the code. . .

Keep in mind that if you write proper code, it can be easily maintained and enhanced while some "tricky" non-code solution may not work when the requirement changes. . .
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Mar 26, 2009 1:50 am
Reply with quote

You left out at least one "rule". Can input file-2, input file-3, and input file-4 share any values? If so, are records written to ALL of the matching output files or only some of them or only the 1st found? You've been given good pseudo code already. I'd also opt for a COBOL solution.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Mar 26, 2009 9:57 am
Reply with quote

Yes. Finally, I got it worked with COBOL solution only. 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 Mar 26, 2009 10:01 am
Reply with quote

Good to hear it's working. 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 Search two or more word with FILEAID Compuware & Other Tools 15
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
Search our Forums:

Back to Top