View previous topic :: View next topic
|
Author |
Message |
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
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:
Input File-3:
Input File-4:
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
Read the "Input File-1" from 18th column |
Is this 18th or 8th? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Still I believe this is a good candidate to do some coding. |
|
Back to top |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
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
Thanks. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
is it possible to do a file to file comparision |
Nothing that I can think of now. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
Yes. Finally, I got it worked with COBOL solution only. Thanks. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Good to hear it's working. |
|
Back to top |
|
|
|