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

select query

Former Member
0 Likes
1,431

SELECT SINGLE * FROM pa0028 WHERE pernr = pa0000-pernr.

Now i need to sort the std table :

SORT DESCENDING BY endda.

How can i do sooooooooo plz guide

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
936

instead of using sorted by in where clause, better fetch data first and then sort like below

select * from pa0028 into table itab WHERE pernr = pa0000-pernr.

sort itab descending by endda.

if u are looking for a single record from database do like this.

SELECT * FROM pa0028

into wa_itab

upto 1 rows

sorted descending by endda

WHERE pernr = pa0000-pernr.

endselect.

7 REPLIES 7
Read only

former_member156446
Active Contributor
0 Likes
936

SELECT SINGLE * FROM pa0028 WHERE pernr = pa0000-pernr.

I dont see a table in the above select...

if it was say Itab

sort table itab by erdat descending.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
936

You are just placing the data in Pa0028 header...so how can you sort it....sorting mechanism can be only performad in a itab....

If u want to fetch the last record form pa00028 then do this way.

SELECT SINGLE * FROM pa0028 WHERE pernr = pa0000-pernr order by pernr descending .

Read only

0 Likes
936

this is giving error........

The SELECT SINGLE statement cannot contain the clause ORDER BY.

Read only

0 Likes
936

that error is valid.. when u say to select single and say order by what ill it order,, it has only one... so better get data into internal table and use sort descending

SELECT * FROM pa0028

into table itab_pernr

WHERE pernr = pa0000-pernr.

sort table itab_pernr descending..

or as said in previous posts

SELECT * FROM pa0028

into table itab_pernr

WHERE pernr = pa0000-pernr

order by erdat.

Edited by: jackandjay on Dec 20, 2007 1:25 AM

Read only

former_member194669
Active Contributor
0 Likes
936

SELECT SINGLE * FROM pa0028 WHERE pernr = pa0000-pernr
 order by pernr descending.

a®

Read only

Former Member
0 Likes
937

instead of using sorted by in where clause, better fetch data first and then sort like below

select * from pa0028 into table itab WHERE pernr = pa0000-pernr.

sort itab descending by endda.

if u are looking for a single record from database do like this.

SELECT * FROM pa0028

into wa_itab

upto 1 rows

sorted descending by endda

WHERE pernr = pa0000-pernr.

endselect.

Read only

former_member386202
Active Contributor
0 Likes
936

Hi,

Do like this

select * from pa0000 into table it_pa0000.

if not it_pa0000[] is initial.

select * from pa0028 into table it_pa0028

for all entries in it_pa0000

where pernr eq it_pa0000-pernr.

endif.

Regards,

Prashant