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

sort internal table

Former Member
0 Likes
1,044

Hi all,

I have a requirement in which i have to sort an internal table based on field value.

suppose i have 3 fields order number , line item ,order type .

there are 5 records

1 10 zabc

20 s1

30 d2

40 f5

50 zabc

I want to sort the records on the basis of zabc.Please let me know how can i do this.

Thanks in advance

Lalit

13 REPLIES 13
Read only

Former Member
0 Likes
1,019

Hi,

Use the statement

SORT ITAB BY ORDERTYPE.

It will sort according to the ordertype.

Thanks and Best Regards,

Ruthra

Read only

former_member210123
Active Participant
0 Likes
1,019

SORT <itab> BY (otab).Otab is the field name.

This should satisfy your requirement.

Read only

Former Member
0 Likes
1,019

Hi,

If u want to sort the internal order type based on irder number

SORt itab by orderno,order_type.

or esle if u want to sort the entire internal table by order type

Sort itab by ordertype.

regards

Sheeba

Read only

vinod_vemuru2
Active Contributor
0 Likes
1,019

Hi Lalit,

Do like this.

SORT itab BY ordertype(Here give the actual field name of the internal table.

Thanks,

Vinod.

Read only

Former Member
0 Likes
1,019

Hi,

SORT ITAB BY FIELDNAME.

Example :

SORT ITAB BY ORDERTYPE.

SORT ITAB BY ORDERTYPE ASCENDING.

If its useful reward points.

Read only

Former Member
0 Likes
1,019

hI,

Data:begin of it_ord occurs o,

ord_typ,

ord_no,

ord_ln,

end of it_ord.

sort it_ord by ord_typ ord_no.

Ord_typ should be the first field of ur itab.

Reward if helpful.

Regards,

Kumar

Read only

Former Member
0 Likes
1,019

I dont want to sort on order type..i want to sort on the value of order type.if i sort it by order type it will come as

d5

f3

s1

zabc

zabc

but i want all the records with value zabc at the top.

Read only

0 Likes
1,019

Sort itab by order type Descending.

Read only

0 Likes
1,019

Hi,

You can try as below.

SORT lt_tab BY otype DESCENDING.

Regards,

Farheen

Read only

Former Member
0 Likes
1,019

Hi,

sort it_ord by ord_typ ord_no descending.

it will work.

Read only

Former Member
0 Likes
1,019

Hi,

You can use Sort like,

Sort It_vbrk by Vbeln erdat DESCENDING.

Regards,

Mehul Shah.

Read only

Former Member
0 Likes
1,019

if i will sort it by descending it will come as

zabc

zbbc

zcbc

but i want records as

zdbc

zdbc

zabc

zabc

sort on a particular field value....

could you please help...

Read only

0 Likes
1,019

Hi friend,

Use

Sort itab by order type Ascending.