Well, good luck. . .What I am saying is that I am developing a program able to any file types, record lenght and record type, for this the attributes are looked for at moment of processing.
As i mentioned previously:
What you describe does not sound like a job for a cobol program - with or without invoking the sort. . .
While i believe this could be better served with assembler or possibly by generating run-specific code and compiling "on the fly", you could use the following approach. It works, several places, but . . .
To set up a generic internal sort, you could define 10 sort keys (alternating ascending and descending) and make the data area the largest of any record you intend to support - hopefully, this process will not be intended for very large (multi-k) records. Hopefully, this will not need to deal with ODO entries either. The sort keys would be moved into the appropriate sort key field(s) and the required data would be moved in piece by piece using reference modification. The SORT statement in the program would always be the same, but the key and data content would change dynamically from run to run.