Skip to Content
0
Former Member
Apr 25, 2007 at 05:11 PM

Sort table by field position?

24 Views

Hello,

Is it possible to sort a table by field position? For example, I have table ITAB with a 4 character field F1. I want to sort the table first by the 3rd position ( itab-f12(1) ) ascending then the 4th position ( itab-f13(1) ) descending.

data: begin of itab occurs 0,

f1(4),

end of itab.

itab-f1 = '01AC'.

append itab.

itab-f1 = '02AB'.

append itab.

itab-f1 = '01CD'.

append itab.

itab-f1 = '02CA'.

append itab.

sort itab...

I thought about using TRANSLATE with a rule and converting each position to a numeric value (then transfer the value to a new 'sort' field), but I wasn't sure if there was an easier way.

The sorted table should read: '01AC' ; '02AB' ; '01CD' ; '02CA'

Any help is appreciated.