‎2007 Oct 02 10:32 AM
Dear all,
I'm having a problem sorting an internal table. The table declaration is something like this
DATA: BEGIN OF ITAB OCCURS 0,
DOKNR LIKE DRAW-DOKNR,
DOKAR LIKE DRAW-DOKAR,
DOKVR LIKE DRAW-DOKVR,
DOKTL LIKE DRAW-DOKTL,
DKTXT LIKE DRAT-DKTXT,
DTCRI LIKE DRAP-DATUM,
DATA LIKE ZDMS_T_DOC-DATA,
HORA LIKE ZDMS_T_DOC-HORA,
...
END OF ITAB.
I'm trying to sort the table by doknr
SORT ITAB BY DOKNR DESCENDING.
The result after the sort command is
703000000009
2000022608
2000022607
2000022196
2000005193
100054788
100054787
10002039975
10002039968.
Thanks in advance,
sb.
‎2007 Oct 02 10:44 AM
If u want sort to work.....take a field of type N and move this value to that field and sort by that field in descending order.
U'll get required output.
Regards
Vasu
‎2007 Oct 02 10:36 AM
Hi Sara,
everything is correct, what's the problem - want do you want to get ?
if you want have ist the other way round you have to code.
sort itab by doknr.
regards henner
‎2007 Oct 02 10:42 AM
HI,
DRAW-DOKNR is a char field, so the sort is correct, no problem.
bye
‎2007 Oct 02 10:50 AM
Hi Henner,
if you see the sort from CV04N, the output is different and just like I need. In fact, for a char type the result that I get is correct.
Thanks,
sb.
‎2007 Oct 02 10:56 AM
hi Sara,
what is the order you want to have? Can you copy it here? Probably not everyone has data in transaction CV04N
thanks
ec
‎2007 Oct 02 11:03 AM
Hi Eric,
I want something like
703000000009
10002039975
10002039968
2000022608
2000022607
2000022196
2000005193
100054788
100054787
Thanks,
sb.
‎2007 Oct 02 11:08 AM
thanks,
than check the values in debug and if they are not right aligned (in the field), than do what I suggested:
SHIFT doknr RIGHT DELETING TRAILING SPACE (of course in a LOOP on each single line)
than the SORT itab BY ... DESCENDING.
‎2007 Oct 02 10:44 AM
If u want sort to work.....take a field of type N and move this value to that field and sort by that field in descending order.
U'll get required output.
Regards
Vasu
‎2007 Oct 02 10:54 AM
Hi Vasu,
with the N type I get the following result
10002039975
10002039968
703000000009
2000022608
2000022607
2000022196
2000005193
100054788
100054787
Any idea?
Thanks,
sb.
‎2007 Oct 02 10:59 AM
Other thing I would try is :
SHIFT doknr RIGHT DELETING TRAILING SPACE (of course in a LOOP on each single line)
than the SORT
‎2007 Oct 02 10:47 AM
hi
good
rather than using one field in the sorting statement try to use two field name in the sorting statement but you have to check in the debug mode that with two field ll give you the exact output as per your requirement.
thanks
mrutyun^
‎2007 Oct 02 11:12 AM