on 10-26-2007 5:27 PM
Hi,
I wanted ti sort Itable by XBLNR and KUNNR, but it is sorting the MATNR also. Please help me why it is happening like this.
SORT gt_zprice BY xblnr DESCENDING kunnr.
For Ex:
kunnr matnr xblnr
1002 11111 SA-07-009
1002 22222 SA-07-009
1002 33333 SA-07-009
1001 11111 SA-07-008
1001 22222 SA-07-008
1001 33333 SA-07-008
I want the result to be like this
kunnr matnr xblnr
1001 11111 SA-07-008
1001 22222 SA-07-008
1001 33333 SA-07-008
1002 11111 SA-07-009
1002 22222 SA-07-009
1002 33333 SA-07-009
But it is comming like the following, material is also sorting.
kunnr matnr xblnr
1001 22222 SA-07-008
1001 11111 SA-07-008
1001 33333 SA-07-008
1002 22222 SA-07-009
1002 11111 SA-07-009
1002 33333 SA-07-009
Thanks,
Veni.
Does this not work? Adding the word STABLE?
SORT gt_zprice STABLE BY xblnr DESCENDING kunnr ASCENDING
Regards,
Rich Heilman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Veni,
From online help.
You can use STABLE to ensure a stable sort order. This means that the order of lines, which is the same in the sort key, remains unchanged after sorting. Without the STABLE addition, the order is not preserved and repeated sorting of a table by the same sort key changes the order each time the table is sorted.
Regards,
Ferry Lianto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use
SORT gt_zprice BY xblnr kunnr matnr.
Hope it works.
Lokesh
<b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada Galindo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If your see the result, it is basically not sorting on Matnr at all. Matnr field values are neither in ascending nor in descending order.
But yes it did change the sequence of your input. Dont know the reason why?
Does sorting on the 3rd field affect your output, if yes then you might have to try some crude way of sorting rather than using the SORT statement.
Hope it helps.
Lokesh
Message was edited by:
Lokesh Aggarwal
Check the below program :
data : begin of gt_zprice occurs 0,
kunnr like kna1-kunnr,
matnr like mara-matnr,
xblnr like vbrk-xblnr,
end of gt_zprice.
start-of-selection.
gt_zprice-kunnr = '1002'.
gt_zprice-matnr = '11111'.
gt_zprice-xblnr = 'SA-07-009'.
append gt_zprice.
clear gt_zprice.
gt_zprice-kunnr = '1002'.
gt_zprice-matnr = '22222'.
gt_zprice-xblnr = 'SA-07-009'.
append gt_zprice.
clear gt_zprice.
gt_zprice-kunnr = '1002'.
gt_zprice-matnr = '33333'.
gt_zprice-xblnr = 'SA-07-009'.
append gt_zprice.
clear gt_zprice.
gt_zprice-kunnr = '1002'.
gt_zprice-matnr = '11111'.
gt_zprice-xblnr = 'SA-07-009'.
append gt_zprice.
clear gt_zprice.
gt_zprice-kunnr = '1001'.
gt_zprice-matnr = '11111'.
gt_zprice-xblnr = 'SA-07-008'.
append gt_zprice.
clear gt_zprice.
gt_zprice-kunnr = '1001'.
gt_zprice-matnr = '22222'.
gt_zprice-xblnr = 'SA-07-008'.
append gt_zprice.
clear gt_zprice.
gt_zprice-kunnr = '1001'.
gt_zprice-matnr = '33333'.
gt_zprice-xblnr = 'SA-07-008'.
append gt_zprice.
clear gt_zprice.
<b>SORT gt_zprice BY xblnr ASCENDING kunnr DESCENDING matnr ascending.</b>
loop at gt_zprice.
endloop.
Now you get output as you expected.
Thanks
Seshu
Hello Veni,
Add ASCENDING after the kunnr.
Like:
SORT gt_zprice BY xblnr DESCENDING kunnr ASCENDING
.
Regards,
Naimesh Patel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.