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
406

Hello SAP Experts,

I need a small doubt to be clarified.

I found one SORT statement which sorts an internal table according to SO number & posnr but this table has one more field as quantity.No order has been defined for this sorting so it should be taken default as ASCENDING.

But the issue is for some line items qty is getting displayed in descending order & for some it is in ascending order.Table has not been sorted as per qty.Its only as per vbeln & posnr.

For example,

SORT int_tab vbeln,posnr.

int_tab is

vbeln posnr qty

12345 100 4

12345 200 4

12345 200 0

12345 400 8

12345 400 0

But after sorting

vbeln posnr qty

12345 100 4

12345 200 4

12345 200 0

12345 400 0

12345 400 8

Please clarify me on this.

BR,

Nisha

2 REPLIES 2
Read only

former_member186055
Active Participant
0 Likes
360

Hi Nisha,

Add Quantity field in sort statement.

SORT int_tab vbeln posnr QTY.

Regards,

Surya

Read only

Former Member
0 Likes
360

If you want to keep the same order for fields not used in the SORT statement, you have to add the STABLE option to the SORT statement. Press F1 on SORT. It's documented.

Rob