Application Development 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: 

how to sort particular field of internal table.

Former Member
0 Kudos

I have internal table which has 5 field, i want to sort particular field of int. table, which will not affect whole data of int table.

thanks

man

8 REPLIES 8

Former Member
0 Kudos

So you mean only a particular field should get re-arranged according to the sort condition without changing the order of other fields?

0 Kudos

yes

SuhaSaha
Advisor
Advisor
0 Kudos

I don't think SORT will help you achieve this. You have to write code for this req. :

IT_TEMP[] = IT_DATA[].

SORT IT_TEMP BY F2. "Field based on which you want to sort.

LOOP AT IT_DATA INTO WA_DATA.

  READ TABLE IT_TEMP INTO WA_TEMP INDEX SY-INDEX.
  IF SY-SUBRC = 0.
    MODIFY IT_DATA FROM WA_TEMP TRANSPORTING F2.
  ENDIF.

ENDLOOP.

BR,

Suhas

PS: Why do you need it anyways? You data will be messed up completely

Former Member
0 Kudos

HI,

Every field has it's relevant record in Database - which we fetch by Internal tables.

So I think Diff. display on Application server & Database server is not possible.

Why don't you try two different internal tables --

One with the field you want to sort

Other will have remainining four fields.

If you want all fields to display in o/p, then merge both ITABs using work area.

0 Kudos

my internal table is like that

matnr werks date qty lifnr

A AB 1/2/10 12 X

A AB 2/2/10 10 Y

A AB 3/2/10 9 Z

B XY 1/2/10 13 C

B XY 2/2/10 10 E

what i want is sort the date in descending order, always want latest date to pick first, nd acc to that qty nd lifnr will also sort

but keeping matnr and werks as intact, so what i will do, taking two int table, or is any way to sort particular field keeping other data intact. help me on this

0 Kudos

try this

sort it by matnr werks ascending date descending.

kesavadas_thekkillath
Active Contributor
0 Kudos

What purpose does this serve.

move teh data of required field to a internal table having only one field and then sort it

Former Member
0 Kudos

thanx