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

Sorting

Former Member
0 Likes
468

Hi,

I have an internal table itab1

itab1:

f1

400

200

700

for that entries i am selecting data from another db table using FOR ALL ENTRIES and i am getting data in sorted manner as below:

f1          f2

200       545

400       222      

700       845

So how to get my original order back.

1 ACCEPTED SOLUTION
Read only

paul_bakker2
Active Contributor
0 Likes
446

Hi,

You'll have to sort Table2 the same way you sorted Table1.

The database table doesn't hold rows in any defined order, so you'll never know what you'll get - you have to sort the result yourself.

cheers

Paul

2 REPLIES 2
Read only

paul_bakker2
Active Contributor
0 Likes
447

Hi,

You'll have to sort Table2 the same way you sorted Table1.

The database table doesn't hold rows in any defined order, so you'll never know what you'll get - you have to sort the result yourself.

cheers

Paul

Read only

VijayaKrishnaG
Active Contributor
0 Likes
446

Hi Krishna,

After getting data into second internal table move the data into another (third) internal table and refresh the second table. When you are moving the data into new table, loop the first table and read the second table with key as 'f1'.

LOOP AT TABLE1 INTO WA1.

READ TABLE TABLE2 INTO WA2 WITH KEY F1 = WA1-F1.

IF SY-SUBRC = 0.

APPEND WA2 TO TABLE3.

ENDIF.

ENDLOOP.

REFRESH TABLE2.

Regards,

Vijay