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

Regarding problem on Sorting

Former Member
0 Likes
1,015

Hello Experts,

Please clarify this problem

i have create a internal table as below

BEGIN OF i_oia05 OCCURS 0,

vbeln LIKE oia05-vbeln,

schddt LIKE oia05-schddt,

intqty LIKE oia05-intqty,

END OF i_oia05,

i got the entries in the internal table as below,

vbeln schddt intqty

----


0040230354 20080101 515463.864

0040230354 20080101 0.170

0040230354 20080201 0.159

0040230354 20080301 0.170

0040230354 20080401 0.165

0040230354 20080501 0.170

0040230354 20080601 0.166

I have done like this sorting

sort i_oia05 by VBELN.

after the sorting i m getting internal table as below

vbeln schddt intqty

----


0040230354 20080601 0.166

0040230354 20080501 0.170

0040230354 20080401 0.165

0040230354 20080301 0.170

0040230354 20080101 515463.864

0040230354 20080101 0.170

0040230354 20080201 0.159

Can i know the reason y it sort like this, it should have been nor mal asending only know..

Please advise me on this..

thanks,

Suresh

10 REPLIES 10
Read only

Former Member
0 Likes
993

Hi suresh,

This is kiran.G.A. U better to sort on vbeln and schddt fields.Then ur problem is resolved ok..

Reward points if helpful..

Kiran Kumar.G.A

Read only

0 Likes
993

Hi kiran,

thanks for the reply, but i wanted to know y it is hapening like that and reason for that..

Thanks suresh

Read only

Former Member
0 Likes
993

well you told him to sort by vbeln and so he did.

the VBELN are ascending sorted, you just cant see it since you have just one vbeln.

better implement a second sort criteria. like schddt.

Read only

0 Likes
993

Hi Florian Kemmer ,

I have few VBELN's , but for example i have given only one.

Read only

0 Likes
993

Hi,

I think the question is: why have the rows in the table changed although the table was already sorted by vbeln?

I found nothing special in the help except the addition STABLE in the SORT statement, although I don't understand exact the meaning of it....

Read only

0 Likes
993

hmmm if you want it in a certain sort order, then you need to sort it that way by using the desired sort criteria.

its the same Problem when you use a select single statement whichs where conditions match more than one record.

you will not be able to forecast which record will be drawn.

Read only

Former Member
0 Likes
993

hi,

sort ur table like this.

sort i_oia05 by VBELN schddt intqty.

why it is coming like this means, in ur internal tabel the data is sorted based on vbeln. so there is only one vbeln, then it will sort only vbeln.

Do this and reward points if helpful.

regards,

ravi shankar reddy

Read only

0 Likes
993

hi ravi,

I have few VBELN documents , but for example i have given one

Read only

peter_ruiz2
Active Contributor
0 Likes
993

hi suresh,

this is taken from the ABAP Keyword Documentation explaining about the keyword sort.

The sort process is only stable if you use the STABLE addition. Otherwise, a predefined sequence of fields used to sort a list is not usually retained.

regards,

peter

Read only

Former Member
0 Likes
993

BTW who cares?

this doesnt touch anything and you as well know how to do it correct.

Not every question needs an answer.