Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

About select options.

Former Member
0 Likes
636

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.

5 REPLIES 5
Read only

Sandra_Rossi
Active Contributor
0 Likes
604

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

Read only

Former Member
0 Likes
604

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.

Read only

Former Member
0 Likes
604

A mugs game

What if you have ranges or patterns or exclusions?

Rob

Read only

0 Likes
604

Ups! What is such thing as an (exclude) pattern?

Regards,

Clemens

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
604

Ups! What is such thing as an (exclude) pattern?

If the HIGH column is initial then exclude pattern is the 'NP' OPTION