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 sequence disturbed

Former Member
0 Likes
563

Hello Friends,

I am sorting an internal table like

sort ITAB by F1 F3 F4.

but after this sort I lost my sequence and grouping of VBELN PONR. which is as below:

VBELN-----POSNR---F1


F2
F3
--


F4

80011864- 40


300730---- V100----- GER--


CSL

80011866- 10


300730---- V110----- GER--


CSL

80011866- 20


300730---- V110----- GER--


CSL

80011864- 10


300730---- V100----- GER--


CSL

80011864- 20


300730---- V100----- GER--


CSL

80011867- 10


300730---- V150----- GER--


CSL

80011864- 30


300730---- V100----- GER--


CSL

80011865- 10


300730---- V000 <<< GER----


CSL

I can't add VBELN and POSNR in the sort statment coz it ll make my o/p like

VBELN-----POSNR---F1


F2
F3
--


F4

80011864- 10


300730---- V100----- GER--


CSL

80011864- 20


300730---- V100----- GER--


CSL

80011864- 30


300730---- V100----- GER--


CSL

80011864- 40


300730---- V100----- GER--


CSL

80011865- 10


300730---- V000 <<< GER----


CSL

80011866- 10


300730---- V100----- GER--


CSL

80011866- 20


300730---- V100----- GER--


CSL

80011867- 10


300730---- V150----- GER--


CSL

Here F2 with value 'V000' is placed in between the 80011864 and 80011866 data which is useless as we have to sort on only F1 F3 and F4. So i can't add F2 in sort sequence.

i want my output like

VBELN-----POSNR---F1


F2
F3
--


F4

80011864- 10


300730---- V100----- GER--


CSL

80011864- 20


300730---- V100----- GER--


CSL

80011864- 30


300730---- V100----- GER--


CSL

80011864- 40


300730---- V100----- GER--


CSL

80011866- 10


300730---- V100----- GER--


CSL

80011866- 20


300730---- V100----- GER--


CSL

80011865- 10


300730---- V000----- GER--


CSL

80011867- 10


300730---- V150----- GER--


CSL

Please Help to solve this sorting problem.

-Maharshi

3 REPLIES 3
Read only

Former Member
0 Likes
512

HI,

SORT ITAB by F1 F3 F4 F2 VBELN POSNR.

You get the out as follows
VBELN-------POSNR-------F1------------- F2-------------F3-------------F4 
80011865--- 10----------- 300730------ V000------- GER--------- CSL 
80011867--- 10----------- 300730------ V150------- GER--------- CSL 
80011864--- 10----------- 300730------ V100------- GER--------- CSL 
80011864--- 20----------- 300730------ V100------- GER--------- CSL 
80011864--- 30----------- 300730------ V100------- GER--------- CSL 
80011864--- 40----------- 300730------ V100------- GER--------- CSL 
80011866--- 10----------- 300730------ V100------- GER--------- CSL 
80011866--- 20----------- 300730------ V100------- GER--------- CSL

Read only

Former Member
0 Likes
512

F2, F3, F4 have same value through out.. how will the sort work???

and on what basis 80011865 is coming between 80011866 and 80011867

Read only

Former Member
0 Likes
512

Please read the help on SORT. You will see that one of the options is STABLE. That will preserve the order for fields that are not in the SORT field list.

Rob