‎2008 Jul 18 6:48 PM
I need to do the following sort:
SORT it_header BY lifnr xblnr belnr ASCENDING.Only I also want it sorted by CHECF descending. Basically, I need it to be ascending except I want all records, with a blank CHECF, last (within it's own vendor, lifnr, section).
Example:
LIFNR XBLNR BELNR CHECF
00001 001000 000100
00002 012000 000111
00002 012340 012300 000034
00001 001100 000110 000001
Would be, after all sorts:
LIFNR XBLNR BELNR CHECF
00001 001100 000100 000001
00001 001000 000100
00002 012340 012300 000034
00002 012000 000111 "If no CHECF then it should be the last entry for the vendor, no matter the other fields.
Is there a way to do this without looping through the table?
‎2008 Jul 18 6:57 PM
Hi,
Try this way...
SORT it_header BY lifnr xblnr belnr ASCENDING
CHECF DESCENDING.Hope this would solve your issue.
Regards
Narin Nandivada.
‎2008 Jul 18 6:57 PM
Hi,
Try this way...
SORT it_header BY lifnr xblnr belnr ASCENDING
CHECF DESCENDING.Hope this would solve your issue.
Regards
Narin Nandivada.
‎2008 Jul 18 7:00 PM
Oh wow, thanks! I had no idea that I could do two different sorts (Directions) in one sort.
Thanks a lot!
Davis
This is the piece of code I ended up using:
SORT it_header BY lifnr ASCENDING checf DESCENDING xblnr belnr ASCENDING.Edited by: Davis on Jul 18, 2008 2:05 PM
‎2008 Jul 18 7:30 PM
Davis,
I have question .
i used as you suggested by your last reply. but i am thinking the output is not coming as per your first reply
Here is code
report zaRs.
data : begin of it_header occurs 0,
field1(5) type c,
field2(6) type c,
field3(6) type c,
field4(6) type c.
data : end of it_header.
move '00001001000000100' to it_header. append it_header.
move '00002012000000111' to it_header. append it_header.
move '00002012340012300000034' to it_header. append it_header.
move '00001001100000110000001' to it_header. append it_header.
sort it_header by field1 ascending field4 descending field2 field3 ascending.
loop at it_header.
write :/ it_header.
endloop.
After running this report i got the output like the following
00001001100000110000001
00001001000000100
00002012340012300000034
00002012000000111
a®
‎2008 Jul 18 7:32 PM
Thanks for your diligence but it does exactly as I want.
Thanks,
Davis
‎2008 Jul 18 7:33 PM
‎2008 Jul 18 6:57 PM
Try like:
SORT it_header BY lifnr ASCENDING
xblnr ASCENDING
belnr ASCENDING
CHECF descending.
Regards,
Naimesh Patel