2009 Oct 14 8:12 AM
Hi Experts,
MSEG contains data (se16) in the order 1 , 2, 3
but if i write select query on it is coming as 2 1 5 ...3 like that
Shortly ..data is coming in different order in the select query even thoug it is in sorted order in the data base.
Thanks in advacne
Hi Experts,
MSEG contains data (se16) in the order 1 , 2, 3
but if i write select query on it is coming as 2 1 5 ...3 like that
Shortly ..data is coming in different order in the select query even thoug it is in sorted order in the data base.
Thanks in advacne
2009 Oct 14 8:17 AM
Hi Krishna,
Generally when a select query is executed, the selection depends on the WHERE condition and the INDEX on the database table. So, we cannot expect the select statement to retreive the values in the same order as we see in se16.
That is the reason, we use SORT statement generally, after selecting the values in to an internal table, as per our requirement.
Best Regards,
Ram.
2009 Oct 14 8:18 AM
2009 Oct 14 8:29 AM
Try with the addition of ORDER BY PRIMARY KEY with your SELECT statement
Check this:
tables: mseg.
data: begin of t_mseg occurs 0.
include structure mseg.
data: end of t_mseg.
select * into table t_mseg up to 50 rows
from mseg order by primary key.
loop at t_mseg.
write:/ t_mseg-mblnr, t_mseg-matnr.
endloop.
2009 Oct 14 8:40 AM
Hi,
Try with the addition of ORDER BY PRIMARY KEY with your SELECT statement
for eg select from mseg into table <itab> where <condition> order by mblnr.
Rgds
Siva
2009 Oct 14 9:55 AM
Hi,
For sorting your data,
1. Use a SORT statement after your select statement
2. Use aORDER BY PRIMARY KEY along with the statement
3. Create a Primary Index/Secondary index in the database table.
Thanks,
harini
2009 Oct 15 5:35 AM
Thank you All,
For your reply. But i want to know how and why it is coming in different order.