View previous topic :: View next topic
|
Author |
Message |
Vidya Bhama
New User
Joined: 17 Sep 2008 Posts: 41 Location: Chennai
|
|
|
|
Hi,
I have the below scenario, Can anyone please help me with this,
I have 2 input files (with no duplicates) in the below format,
Code: |
$$TEST 01 C AAAAAAAA
03 00001000
$$TEST 01 C ABBBBBBB
03 00000000
$$TEST 01 C ACCCCCCC
03 00000000
$$TEST 01 C AFFFFFFF
03 00101000
04 11111111
$$TEST 01 C VVVVVVVV
03 00101000
04 11111111
$$TEST 01 C XXXXXXXX
03 00000000 |
The number of records under the $$TEST record can vary.
Now, I have to compare both the files for $$TEST and the records below it with the 2nd file. Please note both the files are not in sorted order.
Kindly suggest.
Thanks |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
Now, I have to compare both the files for $$TEST and the records below it with the 2nd file. Please note both the files are not in sorted order
|
Your requirement is rather vague...
What to do you mean by compare? Compare can be of many type\level..
Does order of internal records under $$TEST matters?
explain more..
show sample input files(BOTH)... and corresponding output you want... or do you want just specific return code if files dont match etc...You have to be bang on with your requirement to get good answer...
Also What is the DFSORT PTF level at your shop... |
|
Back to top |
|
|
Vidya Bhama
New User
Joined: 17 Sep 2008 Posts: 41 Location: Chennai
|
|
|
|
Hi Sambhaji,
Both my files are of same format i mentioned as sample. i wanted to write all the matching records in File1 with File2 to a new file.
Both the files do not have any duplicates and are not in sorted order.
For eg:
Code: |
File 1
$$TEST 01 C AAAA$AAA
03 00001000
$$TEST 01 C VVVVVVVV
03 00101000
04 11111111
$$TEST 01 C ASFGJHRSB
03 10001000
File 2
$$TEST 01 C ABBBBBBB
03 00000000
$$TEST 01 C AAAA$AAA
03 00001000
$$TEST 01 C AFFFFFFF
03 00101000
04 11111111
$$TEST 01 C XXXXXXXX
03 00000000
$$TEST 01 C ACCCCCCC
03 00000000
$$TEST 01 C VVVVVVVV
03 00101000
04 11111111
The Output File
$$TEST 01 C AAAA$AAA
03 00001000
$$TEST 01 C VVVVVVVV
03 00101000
04 11111111
|
Please let me know if the above is not clear.
Thanks |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Code: |
File 1
$$TEST 01 C VVVVVVVV
03 00101000
04 11111111
$$TEST 01 C VVVVVXXX
03 00101000
File 2
$$TEST 01 C VVVVVVVV
04 11111111
03 00101000
$$TEST 01 C VVVVVXXX
04 00101000
|
What should be output in this case? Is these case possible first of all? |
|
Back to top |
|
|
Vidya Bhama
New User
Joined: 17 Sep 2008 Posts: 41 Location: Chennai
|
|
|
|
The case mentioned above is not possible, (i.e) 03 and 04 wil always be in order in both the files.
Output should be empty file. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
What about second case? even that is not possible?
Code: |
File 1
$$TEST 01 C VVVVVXXX
03 00101000
File 2
$$TEST 01 C VVVVVXXX
04 00101000 |
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Vidya,
You need a better example of input and expected output. Show us different variations of groups that are possible but DO NOT MATCH (Sambhaji has asked about one such example, but there are probably others).
Give the RECFM and LRECL of each input file. Give the starting position, length and format of each relevant field.
Are you comparing on the entire record, or on some part of the record (which part)? |
|
Back to top |
|
|
Vidya Bhama
New User
Joined: 17 Sep 2008 Posts: 41 Location: Chennai
|
|
|
|
Hi,
Sorry for the delayed reply.
Sambhaji,
Yes the second case might be possible.
Frank,
The original requirement is as below,
The entries in the File1 (displayed below)
Code: |
$$TEST 01 C VVVVVXXX |
should be first checked in the File2. If present then the records below it must be checked if same in both files.
If yes then you have to write the above 2 lines from File1 onto a new file.
I hope its clearer now.
Thanks |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Vidya Bhama,
What is the LRECL and RECFM? Are you comparing only key fields or entire record?
Thanks, |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
I hope its clearer now |
Why would it be? You didn't actually answer any of my questions or show the example I asked for. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Vidya,
You have a dataset containing groups of records defined as starting with record $$TEST and including all the records before the next $$TEST (or end-of-file).
You have a second dataset grouped in a similar manner to the first.
For each group on the first dataset you need to search the second dataset for a full match, including the order and number of records, of the entire group. For each full match encountered, write the entire group to the output file.
Any and all other groupings fail the match test.
Is that about it?
Also, you will need to review the previous replies and ensure that you answer all the questions. No-one is going to go counting characters for you. |
|
Back to top |
|
|
|