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

Internal table Modification

Former Member
0 Likes
718

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
695

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

6 REPLIES 6
Read only

Former Member
0 Likes
696

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

Read only

rainer_hbenthal
Active Contributor
0 Likes
695

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

Read only

Former Member
0 Likes
695

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.

Read only

ingo_barschow
Explorer
0 Likes
695

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.

Read only

Former Member
0 Likes
695

Thanks you all. My issue got resolve

Read only

0 Likes
695

Hi,

Could you please tell what did you do finally to resolve your issue?

Thanks,

Kamesh Bathla