Problem:
How to SORT a table in storage. Can this be done?
Resolution:
Yes, here is a sample program that illustrates how to do this:
$set mf charset"ascii"
Identification Division.
Program-Id. LORINCE.
Environment Division.
Data Division.
Working-Storage Section.
* Sorted Numeric Values : 111 112 121 122 211 212 221 222
1 MixNumVals.
2 Pic 9(12) Value 222221112121.
2 Pic 9(12) Value 212211122111.
* Sorted Alphanumeric Values : 1A1 1B1 1C1 AAA B1A CA1 D21 EEE
1 MixAlphNumVals.
2 Pic X(12) Value 'EEE1A1AAA1C1'.
2 Pic X(12) Value 'CA1B1AD211B1'.
1 TblOne.
2 T1Tbl Occurs 8 Times.
3 T1 Pic 9(3).
1 TblTwo.
2 T2Tbl Occurs 8 Times.
3 T2 Pic X(3).
Procedure Division.
P1.
Move MixNumVals to TblOne
Sort T1Tbl on Ascending Key T1 Duplicates
Display ' Table One = ' TblOne
Move MixAlphNumVals to TblTwo
Sort T2Tbl on Ascending Key T2 Duplicates
Display ' Table Two = ' TblTwo
Goback.