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

Sorting?

Former Member
0 Likes
531

Hi Experts,

I hv code like,

1 Code) :

<i><b> sort itab by charg.

sort itab by invnr.</b></i>

2 Code):

<i><b>sort itab by charg invnr.</b></i>

Is that the above two codes wuld yields the same result? Or not?

ThanQ.

Message was edited by:

Sridhar

1 ACCEPTED SOLUTION
Read only

suresh_datti
Active Contributor
0 Likes
510

Not necessarily the same result as in the two cases, the sort order is different ie

when u sort by only one field, the itab is sorted by that field.. in the first case, the second sort overrides the first sort ie the itab will be sorted by invnr.

whereas in the second case the itab is sorted first by charg & then by invnr.

~Suresh

4 REPLIES 4
Read only

suresh_datti
Active Contributor
0 Likes
511

Not necessarily the same result as in the two cases, the sort order is different ie

when u sort by only one field, the itab is sorted by that field.. in the first case, the second sort overrides the first sort ie the itab will be sorted by invnr.

whereas in the second case the itab is sorted first by charg & then by invnr.

~Suresh

Read only

0 Likes
510

OK, ThanQ.

So, here, the following 2 statements r immediately written,

1 Case):

sort itab by charg.

sort itab by invnr.

So, instead, programmer can write only one statement as blow,

2 Case):

sort itab by invnr.

by expecting the same result!

R the above 2 cases wuld yield the same result?

ThaNQ.

Read only

0 Likes
510

In this case, those statements would yeild the same results. Because, in number 1, the last statement is the same as the statement in number 2. So in number 1, the table is sorted by the last SORT statement.

In your original post, the statement with boths fields will sort by the first, and then by the second collectively, when you separate the fields into two separate SORT statements, you are simply sorting by that field.

Regards,

Rich Heilman

Read only

0 Likes
510

ThanQ Rich.