1, If both the FILE key matches --> and IF NAME1 and PHONE NO1 matches -> FILE1 values will be written in output. (EG: AAC3)
2, If both the FILE key matches --> and IF NAME1 and PHONE NO1 NOT matches -> Update NAME and PHONE NO of FILE2 file. (EG: AAD)
3, If both the FILE key matches --> and IF NAME1 and PHONE NO1 is spaces, check for NAME2 and PHONE NO2. (EG: AAD3)
4, If both the FILE key matches --> and IF NAME1 and PHONE NO1 is spaces and NAME2 and PHONE NO2 is also spaces --> move spaces in NAME and PHONE NO in output file (EG: AA121)
5, If Key is present in File1 but not present in File2 --> Check for the upperbound*. (EG: AAD1, ACB)
6, If Key is present in File1 but not present in File2 --> and the upperbound is also not present in File2 --> File1 value should be written in output file. (EG: BB45)
7, IF Key is not present in File1 but present in File2 --> Just ignore it. (EG: AA192)
Eg: 'AAD1' is present in File1, but not present in File2. So the upperbound will be elimination of the last char of the KEY word. So it is 'AAD'. Now check this 'AAD' in File2 and replace with that corresponding value of File2 in output file.
Another EG: 'ACD' is not present in File2. So elimination of the last char, will give you 'AC' and this should be checked in file2. This is also not found. So eliminate the last char. So it will be 'A'. This is found in the File2. so corresponding value if 'A' in File2 is written in the output file.
NOTE: WE DON'T HAVE (NEW z/OS DFSORT V1R5 PTF UK90013 (July, 2008)) IN OUR SHOP.
The following DFSORT/ICETOOL JCL will give you the desired results. The tricky part is to validate Upperbound case. I assumed that your file2 has NO duplicates on the key. I also assumed that your Name2 is 17 bytes as name1 is 17 bytes. you showed only 16 bytes for name2. The comparision would fail when checking for name1,phone1 combo.
The job is typical file match with expception that you need to implement upperbound case. So what we do is split the file1 key into 7 records, so that we will find a match for the upperbound case
ex if you have a key as follows
we would create 7 records like this
Once we create it like this it is easy for us to match with the key in file2. once matched we use a couple of include and get rid of the unnecessary records