‎2008 Aug 07 3:08 PM
Hello experts,
If have an Internal table it_test having data.
romm_no name
53 Anil
40 Michael
40 Alex
40 Matheaw
40 Ringo
67 Lex
I want to sort the name of room 40 without sorting the room_no.
e.i.
i want the data in the order
romm_no name
53 Anil
40 Alex
40 Matheaw
40 Michael
40 Ringo
67 Lex
how do i acheive that?
Thanks in advance.
‎2008 Aug 07 3:15 PM
Hi,
there is no direct sort command to achieve this type of result. Though you can do it and fill your internal table in the loop.
Transfer the data of romm_no = 40 to another internal table and sort it by name.
loop at first_table where romm_no <> 40.
fill new table here
at last.
loop at second_table ( which onatin record of room number 40 )
fill new table here for sorted records of room number 40
endloop.
endat.
endloop.
thanks,
Kamesh
‎2008 Aug 07 3:15 PM
Hi,
there is no direct sort command to achieve this type of result. Though you can do it and fill your internal table in the loop.
Transfer the data of romm_no = 40 to another internal table and sort it by name.
loop at first_table where romm_no <> 40.
fill new table here
at last.
loop at second_table ( which onatin record of room number 40 )
fill new table here for sorted records of room number 40
endloop.
endat.
endloop.
thanks,
Kamesh
‎2008 Aug 07 3:15 PM
Add a column containing the sequence the rooms will show, the sort by the sequence and then by the name
1 53 Anil
2 40 Michael
2 40 Alex
2 40 Matheaw
2 40 Ringo
3 67 Lex
‎2008 Aug 07 3:17 PM
You need to have 2 tables of same type.
Suppose 1st table is IT_TAB and the sorted data will be in IT_SORT.
it_sort = it_tab.
sort it_sort by name.
Loop at it_tab.
it_sort-room = it_tab-room.
modify it_tab.
endloop.
This will keep the room no. as it is but name will be sorted.
Hope this helps.
‎2008 Aug 07 3:20 PM
Hi,
I would suggest to change the table type description, splitting roomnumber and prename in two fields. Afterwards it will me much easier to sort the table by several fields.
‎2008 Aug 08 8:19 AM
‎2008 Aug 08 3:46 PM
Hi,
Could you please tell what did you do finally to resolve your issue?
Thanks,
Kamesh Bathla