The input in the code is 20 but the saample input data is longer?
When i code an internal sort, i identify the sort-key in a level-05 at the front of the sort record and the data to be sorted by the key in another level-05. Under each i name the individual fields.
I believe you want to release all of the records to the sort, there will be differences in the data portion.
The code initializes ws-sort-rec but this is not defined.
There's at least one typo that the compiler will catch if it isn't changed.
Suggest you make the small test copy of some data and have a go