Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SORT to merge two files

Status
Not open for further replies.

gopalrathi

Programmer
Oct 21, 2003
5
0
0
US
Hi All,

I have a requirement to merge two files as following.
How Can I do this using SORT utility. Our mainframe does not support ICETOOL.

File 1 File 2
============ ===============
Id %1 Id %2
A 45 A 25
A 55 A 75
B 100 B 60
C 75 B 40
C 25 C 100

Output
===============
Id %1 %2
A 45 25
A 45 75
A 55 25
A 55 75
B 100 60
B 100 40
C 75 100
C 25 100

Thanks,
Gopal.
 
Gopal. -

I think you're going to have to write some code to do this as I doubt a standard SORT can manage it.

Regards.

Glenn
 
As you are asking in a COBOL forum, then using a COBOL solution seems reasonable to me. (Using Input procedure to process files)

If you want a non-COBOL solution, check in an IBM (or other mainframe) utility forum.

Bill Klein
 
First read File 1 one record at a time then read file 2. IF
the ID match then create your output record. You loop thru file1 until end of record. At the end of File1 you can start sorting your ouput file.

Something like this......somewhere in your cobol pgm...

SORT OUTPUT-FILE
ASCENDING KEY ID#
ASCENDING KEY ETC
INPUT PROCEDURE READ-FILE
OUTPUT PROCEDURE WHATEVER.

Is this good enough? OR Do you want us to write some logic?

 
GOPAL,

What happens if there is no match in File1 or vice versa?

You have to create a code to make it happen. I don't think
SORT or SORT/MERGE utility can do this.
 

What sort utility are you using on the mainframe and version?

Is the file already in sorted order? The Id tags at the beginning will be a problem if the the file is not already sorted.

This may be possible to do using DFSORT but need to know if you have this availble.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top