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

How to sort a custom database table ?

Former Member
0 Likes
2,938

Hi,

how do I sort/order a custom (Z) database table (not internal table) ? Couldn't find a suiting option with F1 for the SORT statement.

Thanks,

Avraham

9 REPLIES 9
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,913

SORT --> Do you mean sort the o/p display?

Read only

0 Likes
1,913

I have a database table, just like, say MARA or VBAK, but it's not SAP, it's mine.

Was it an internal table, I would work this out with SORT. But I didn't do this yet to a database table.

Read only

0 Likes
1,913

that is wat i am telling...

now go to se16 ..

give youer table name ...

give F8

THEN you follow the steps of ,my before post you can get it...

Read only

0 Likes
1,913

I have to do this within my program.

Read only

0 Likes
1,913

Hi,

If you just wanted to VIEW the data in a standard SAP table in a sorted order,

then go to the transaction SE16.

GIve the table name.

Press Enter Button.

Then press F8 (Execute button).

In the screen to folow, yo will get the records of the table.

Put the cursor on the column by which you want to sort, then click on the SORT Button(Acending : CTRLSHIFTF5) or Descendin(CTRLSHIFTF6)

Regards,

Ravi

Read only

0 Likes
1,913

hiii,

hey no ...

in se16 ...

Read only

0 Likes
1,913

>

> I have to do this within my program.

Use ORDER BY in your select. Or just select your data into an itab and use SORT. I don't see the problem.

If you mean that you want to sort your table in the database itself, then you can't. Database table rows are not held in any specific order; the order is applied when you select the data out of the table.

Read only

0 Likes
1,913

Hi,

By default system database table will be sorted based on the primary key fields. So you can change that sequence now. If you want to sort some other field also, which is not primary key, then make that field to primary key.

In the program, it is normal way of sorting by mentioning the required fields. If you don't mention any thing means, it is again based on the primary keys.

Regards,

Santhosh.

Read only

Former Member
0 Likes
1,913

yes you cansort...

just make it display in alv format..

go to SETTING -> USER PARAMETERS ...now select alv grid...now you can sort your tables output.

with regrads

janani