Joined: 21 Mar 2007 Posts: 66 Location: Chennai, Tamilnadu, India
Hi All,
I have two files of LRECL=80 with records as below,
Stucture of both the files:
Columns 1 to 9 - Constant literals (Wild card & All value)
Column 10 - Blank
Columns 11 to 18 - Value 1
Column 19 - Blank
Column 20 to 21 - Value 2
Column 22 - Blank
Column 23 to 80 - Value 3
Code:
File 1 records:
Wild card AAAA**** M 19960801
Wild card MMMMM*** X 19960707
File 2 records:
All value AAAA123 L1 19980203
All value AAAA222 K1 19980203
All value KKKK555 M2 19990105
The output file should contain records as below,
Code:
Wild card AAAA123 M 19960801
Wild card AAAA222 M 19960801
Wild card MMMMM*** X 19960707
Wild card KKKK555 M2 19990105
The following are the possible cases,
Case 1:
If expanded value of wildcard is found in File 2 then the output file should have all possible values of Value 1( E.g., for AAAA*** possible values are AAAA123 and AAAA222) with constant literal, Value 2 & Value 3 from file 1.
Case 2:
If no expanded value of wildcard is found in File 2 then write that File 2 record to output (E.g, Pls see output record 3)
Case 3:
If Value 1 of File 2 doesn't match with any of the Value 1 of File 1 then write the record of File 2 to output with first 10 bytes constant literal from File 1 (E.g, Pls see output record 4)
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You haven't given enough information about the possible "wildcard" (*)variations.
Can only value1 have *s?
Are the *s always the last three characters of value1 or can they be the last n characters, e.g. A*******, AA******, etc, or anywhere, e.g. A*B*C*D*? Can a value1 not have any wildcards, e.g. AAAAAAAA? Can a value1 have blanks?
It would help if you'd give a more extensive example with more of the possible variations.
Joined: 21 Mar 2007 Posts: 66 Location: Chennai, Tamilnadu, India
Frank,
1. Can only value1 have *s?
Yes, only Value1 can have *s.
2. Are the *s always the last three characters of value1?
In my file, the last three characters of all Value1 are *s but it would be better to take all characters of Value1 before *s and check against File2.
i.e like A*******, AA******.
3. Can *s be found anywhere, e.g. A*B*C*D*?
No *s can only be found at the end of wildcard i.e cannot be like A*B*C*D*
4. Can a value1 not have any wildcards?
Ya, Value1 can also be without wildcards like AAAAAAAA. In that case this record needs to be written in outfile.
5. Can a value1 have blanks?
No Value1 cannot have blanks
Please find the below example with all possible cases.
File 1:
Wild card AAAA**** M 19960801
Wild card MMM***** X 19960707
Wild card LL****** X 19960909
Wild card PPPPPPPP Q 19960405
File 2 records:
All value AAAA123 L1 19980203
All value AAAA222 K1 19980203
All value LLAA222 P1 19970506
All value KKKK555 M2 19990105
Then the outfile should have
Wild card AAAA123 M 19960801
Wild card AAAA222 M 19960801
Wild card MMM***** X 19960707
Wild card LLAA222 X 19960909
Wild card PPPPPPPP Q 19960405
Wild card KKKK555 M2 19990105
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Here's a DFSORT/ICETOOL job that will give the output records you asked for (it's not clear to me what order you want the output records in - it seems to be some strange combination of the order of the records in fileA and the records in fileB).
Wild card AAAA123 M 19960801
Wild card AAAA222 M 19960801
Wild card LLAA222 X 19960909
All value KKKK555 M2 19990105
Wild card MMM***** X 19960707
Wild card PPPPPPPP Q 19960405
Joined: 21 Mar 2007 Posts: 66 Location: Chennai, Tamilnadu, India
Fantastic Frank ,
The output is fine except , the order of output records is from FileA (Input1) then from FileB(Input2) and all output records should have first 10 characters with constant literal 'Wild Card'.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
the order of output records is from FileA (Input1) then from FileB(Input2) and all output records should have first 10 characters with constant literal 'Wild Card'.
Do you need me to show you how to do that or can you figure it out yourself?