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 : conditions

nisha_vinod
Product and Topic Expert
Product and Topic Expert
0 Likes
1,775

I have an internal tab that I need to sort by comparing it to another itab.

For eg:

ITAB1 has values aaa,bbb,ccc,ddd.

ITAB2 will have a subset or the complete valueset of ITAB1 and has to be sorted by values in ITAB1. How can I achieve this?

Thanks,

Nisha

I have an internal tab that I need to sort by comparing it to another itab.

For eg:

ITAB1 has values aaa,bbb,ccc,ddd.

ITAB2 will have a subset or the complete valueset of ITAB1 and has to be sorted by values in ITAB1. How can I achieve this?

Thanks,

Nisha

7 REPLIES 7
Read only

dev_parbutteea
Active Contributor
0 Likes
1,138

Hi,

Why don't you sort both tables by the same field?

Read only

awin_prabhu
Active Contributor
0 Likes
1,138

Hi friend,

Just use

SORT itab2 BY F1. (Where 'F1' is common field present in ITAB1and ITAB2)

Edited by: Sap Fan on Apr 13, 2009 6:58 AM

Read only

nisha_vinod
Product and Topic Expert
Product and Topic Expert
0 Likes
1,138

ITAB1 and ITAB2 do not have any field/fieldnames in common. Only the values are same.

Read only

0 Likes
1,138

Hi,

In that case you should sort by the columns which refer to these values.

e.g:

Itab1-col1 = 'aaa'

Itab2-col2 = 'aaa'

sort itab1 by col1.

sort itab2 by col2.

Read only

0 Likes
1,138

hi,,

PLs explain ur requirement with example pls.....

Thanks and Regards

Suraj S Nair

Read only

Former Member
0 Likes
1,138

Hi NIsha,

Internal table are sorted for the fields based on the scenarions not for the values.

if you want to sort the INT2 for the common values of the INT1..so why don't you take the fields common fields of INT1 in the INT2. and do the sort.

Thanks!

Read only

Former Member
0 Likes
1,138

Hi,

code:

sort itab1.

select <fields> from <tablename> 
                      into table itab2
                      for all entries in itab1
                      order by <fieldname> [desc ]               " Asc by default
                     where <fieldname> = itab1-fieldname.

or

try using some common fields between the two tables

thanks

ravi