1) Actually there are no keys to match in the files. file2 contains valid telephone numbers. in file1 TN's are masked. So, i need to replace these valid telephone numbers in the masking field of file1(6th-10 position).
Suppose file1 have 5 records and file2 has 2 records. i need to replace the file2 records

Code:

like 1
2
1
2
1

the o/p file result i wrote previously.

2) i ran your given code to find out the sort product. check the sysout segment in below.

you are correct. file2 values are replacing again if there are less records. Means we need to read file2 values and replace those in file1. if file2 records are finished then we need to read file2 again and start replacing.

it is not possible that file2 will always have only 2 records. But file2 will have less records than file1. So, i need to read file2 and replace file2 telephone numbers in file1(6:10 positon). if file2 records are finished and file1 is still have records then we need read file2 again and replace in file1.

Well, I could provide the JCL but it is well documented in the manual - you need a jobcard, DD cards for input file, output file and messages and a SYSIN card for where your sort control cards go. all fairly standard JCL. I cannot help with the sort control cards though.

You absolutely never "open the file again and start reading it again", even when writing a program where you could actually do that.

Look at CHANGE. Work out how to "generate" a CHANGE statement and other things necessary.

Process is to set a sequence number which will be replace by your telephone number. RESTART the sequence number according to the number of telephone numbers you have. Use CHANGE to change each successive sequence number to each successive telephone number.

file2 contains valid telephone numbers which are unloaded from a table. in file1 TN's are masked(which comes from production). So, i need to replace these valid telephone numbers in the masking field of file1(6th-10 position).

Final requirement is file1 should have the valid telephone numbers similar to file2 telephone numbers.

Note: file1 should not contain masking data for telephone number position.

Suppose if file2 has 50 telephone numbers. it is not mandatory to
replace all 50 numbers in file1. if we replace first 10 telephone numbers repeatedly also fine.

File1 should have the valid telephone numbers like fil2. this is the o/p result i am expecting.
Can anyone provide any sort card or suggest me if there is any better way to achieve this. [/code]

Can anyone provide any sort card or suggest me if there is any better way to achieve this

If you need just a first few telephone numbers from file-2, you could write some code to read and store them in an array. Read each record from file-1, attach the phone number from the array and write into output. Restart the array index to 1 upon reaching the end of array. Repeat until end-of-file-1

I already got the result through a cobol program. But, I am looking whether any sort logic is there to do this in a smart way.

Can we do this in another way like following.
compare file1(6:10 position) values with file2(1:10) position values. if no match found then replace file2 telephone number in file1(6:10 position).
As file1 has masking data like ######### match will never found.

If this is possible, can you provide any sort/icetool logic to replace when no match found.