‎2011 Jul 08 7:33 PM
Hi there;
Is there any chance to sort an internal table (it_result) comparing an internal range table (s_ktorr) ?
Example :
Select-Options on screen
s_ktorr =
DESK9A56KS
DESK9AU634
DESK9A53JD
DESK9A7878
Then when I select those tkorr from e071 table, the final result is :
SELECT trkorr obj_name object
FROM e071
INTO CORRESPONDING FIELDS OF TABLE it_result
WHERE trkorr IN s_ktorr.
it_result =
DESK9A7878 OBJ1
DESK9A7878 OBJ2
DESK9A56KS OBJ1
DESK9A56KS OBJ2
DESK9A56KS OBJ3
DESK9A53JD OBJ1
DESK9AU634 OBJ1
DESK9AU634 OBJ2
As you can see the final result is out of order comparing the s_ktorr order on the screen..
My question is.. Is there any syntax or some SORT method to do not lose the original sort?
Thanks in advance.
E.
‎2011 Jul 08 8:05 PM
Hi,
SQL do not sort data, except if you use ORDER BY. But it is not advised with a SAP system (because of its scalable architecture, i.e. to do load balancing on several application servers), prefer to use SORT statement after the SELECT.
BR
Sandra
‎2011 Jul 08 8:07 PM
No, but it the arrangement of data must match the original input list, one could loop at the input ranges table, then loop at the result looking for those values and increment a counter defined in the results table, then resort by that counter no.
for example something like this (not very efficient, to be sure):
data: lv_counter(4) type n value 1.
loop at ranges table.
loop at result table where <fieldname> = ranges-low.
result-counter = lv_counter.
lv_counter = lv_counter + 1.
endloop.
endloop.
sort result table by counter.
But, I don't understand why this would be important....a simple sort statement, as Sandra noted, would be desirable.
‎2011 Jul 08 9:09 PM
A mugs game
What if you have ranges or patterns or exclusions?
Rob
‎2011 Jul 08 10:51 PM
Ups! What is such thing as an (exclude) pattern?
Regards,
Clemens
‎2011 Jul 08 10:55 PM
Ups! What is such thing as an (exclude) pattern?
If the HIGH column is initial then exclude pattern is the 'NP' OPTION