PROGRAM TO DEMONSTRATE SORT VERB:
The file for which a record having 2 fields, viz., Account Number and Name is already available. Sort the file based on the ascending order of the Account Number.
identification division.
program- id.
environment division.
input-output section.
file-control.
select o1- file assign to disk
organization is line sequential.
select s1-file assign to disk
organization is line sequential.
select w- file assign to disk.
data division.
file section.
fd o1- file
label records are standard
value of file- id is "o1.dat".
01 o1-rec.
02 o1-acc-no pic 9(2).
02 o1-name pic x(4).
fd s1-file
label records are standard
value of file- id is "s1.dat".
01 s1-rec.
02 s1-acc-no pic 9(2).
02 s1-name pic x(4).
sd w-file.
01 w-rec.
02 w-acc-no pic 9(2).
02 w-name pic x(4).
procedure division.
p-1.
sort w-file on ascending key w-acc-no using o1-file
giving s1- file.
stop run.