identification
division.
program-id.
sort-merge-test.
environment
division.
input-output
section.
file-control.
select
sortfile1 assign to "sortfile1.dat"
organization is line sequential.
select
sortfile2 assign to "sortfile2.dat"
organization is line sequential.
select
sortfile3 assign to "sortfile3.dat"
organization is line sequential.
select
sortwork assign to "sortwork.dat".
select
sorted1 assign to "sorted1.dat"
organization is line sequential.
select
sorted2 assign to "sorted2.dat"
organization is line sequential.
select
sorted3 assign to "sorted3.dat"
organization is line sequential.
select
merged assign to "merged.dat"
organization is line sequential.
data
division.
file
section.
fd
sortfile1.
01 sortrec1
pic x(48).
fd
sortfile2.
01 sortrec2
pic x(48).
fd
sortfile3.
01 sortrec3
pic x(48).
sd sortwork.
01
sortrecwork.
05 fran-num-in pic 99.
05 empl-num-in pic 9999.
05 filler pic x(42).
fd sorted1.
01
sortedrec1 pic x(48).
fd sorted2.
01
sortedrec2 pic x(48).
fd sorted3.
01
sortedrec3 pic x(48).
fd merged.
01 mergedrec
pic x(48).
procedure division.
100-main.
sort
sortwork
on
ascending key fran-num-in
empl-num-in
using sortfile1
giving sorted1.
sort
sortwork
on
ascending key fran-num-in
empl-num-in
using sortfile2
giving sorted2.
sort
sortwork
on
ascending key fran-num-in
empl-num-in
using sortfile3
giving sorted3.
merge
sortwork
on
ascending key fran-num-in empl-num-in
using sorted1 sorted2 sorted3
giving merged.
********************************************************
merge
sortwork
on
ascending key fran-num-in
empl-num-in
using sortfile1 sortfile2 sortfile3
giving
sorted1.
sort
sortwork
on
ascending key fran-num-in empl-num-in
using sorted1
giving sorted2.
********************************************************
sort
sortwork
on ascending key fran-num-in empl-num-in
using sortfile1 sortfile2 sortfile3
giving sorted1.
stop
run.