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

processing internal table

Former Member
0 Likes
1,264

Hi all,

In internal table i have data with vornr matnr and other fields.

My requirement is for each material number i have to sort the internal table descending with vornr for furthur processing.

My code is working fine with one material.but with more than one its not working.

ex:

internal table itab.

vornr matnr

1200 18

1800 18

1300 18

1100 19

900 19

1800 19.

Result table should be like this:

vornr matnr

1800 18

1300 18

1200 18

1800 19

1100 19

900 19.

Please help me.

regards

Chandu.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,201

use "sort itab by vornr" statement..

oops i didn't read it throroughly..

first move the contents to another itab.

say itab1

whose structure is Matnr|Vornr

move the contents of itab to itab1.

sort itab1 by matnr vornr.

then move the contents bacl to itab.

Message was edited by: Ravi Kanth Talagana

11 REPLIES 11
Read only

Former Member
0 Likes
1,202

use "sort itab by vornr" statement..

oops i didn't read it throroughly..

first move the contents to another itab.

say itab1

whose structure is Matnr|Vornr

move the contents of itab to itab1.

sort itab1 by matnr vornr.

then move the contents bacl to itab.

Message was edited by: Ravi Kanth Talagana

Read only

0 Likes
1,201

and matnr

so -> sort itab by vornr matnr

Read only

0 Likes
1,201

hi ravi,

i used the statement but its working fine for only one material.

Read only

0 Likes
1,201

I have edited my message, just look at it again.

Cheers Ravi

data: begin of itab occurs 0,

matnr like mara-matnr,

vornr....,

end of itab.

data: begin of itab1 occurs 0,

vornr....,

matnr like mara-matnr,

end of itab.

loop at itab.

move-corresponding itab to itab1.

append itab1.

clear itab1.

endloop.

refresh itab.

sort itab1 by vornr matnr.

loop at itab1.

move-corresponding itab to itab.

append itab.

clear itab.

endloop.

Regards,

Ravi

Read only

0 Likes
1,201

Hi alexandar and federik,

If i use sort itab by vornr matnr descending.

then the result is

vornr matnr

1800 18

1800 19

1300 18

1200 18

1100 19

900 19. instead of.

vornr matnr

1800 18

1300 18

1200 18

1800 19

1100 19

900 19.

I hope you understand

Read only

0 Likes
1,201

So,

Change it to:

sort itab by matnr ascending

vornr descending .

Alexandre Nogueira

Read only

0 Likes
1,201

I don't know if SAP will like that, but you would like to do :

sort itab by matnr ascending vornr descending.

Fred

Read only

0 Likes
1,201

Hi all,

Thanks alot once again...

Read only

0 Likes
1,201

Hi Sai,

For your info. After matnr no need to give ascending..its default.

Thanks

Eswar

Read only

Former Member
0 Likes
1,201

sort itab by matnr

vornr descending .

Alexandre Nogueira

Read only

Former Member
0 Likes
1,201

Hi Sai,

Simply

sort itab by matnr vornr descending.

Thanks

eswar