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

strings

Former Member
0 Likes
460

Can anyone send me a sample program to sort strings in abap

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
438

If there is an internal table with some strings in it.

then you can simply use the sort statement

data: begin of itab occurs 0,

string(20) type c,

end of itab.

itab-string = 'hchgugjk'.

append itab.

clear itab.

itab-string = 'dhhgugjk'.

append itab.

clear itab.

itab-string = 'shhgugjk'.

append itab.

clear itab.

itab-string = 'ahhgugjk'.

append itab.

clear itab.

write:/ 'Before sorting'.

loop at itab.

write:/ itab-string.

endloop.

sort itab by string.

write:/ 'After sorting'.

loop at itab.

write:/ itab-string.

endloop.

Regards,

Ravi

2 REPLIES 2
Read only

Former Member
0 Likes
439

If there is an internal table with some strings in it.

then you can simply use the sort statement

data: begin of itab occurs 0,

string(20) type c,

end of itab.

itab-string = 'hchgugjk'.

append itab.

clear itab.

itab-string = 'dhhgugjk'.

append itab.

clear itab.

itab-string = 'shhgugjk'.

append itab.

clear itab.

itab-string = 'ahhgugjk'.

append itab.

clear itab.

write:/ 'Before sorting'.

loop at itab.

write:/ itab-string.

endloop.

sort itab by string.

write:/ 'After sorting'.

loop at itab.

write:/ itab-string.

endloop.

Regards,

Ravi

Read only

former_member189631
Active Contributor
0 Likes
438

Hi Ravi,

Plz chk this Code:

data: begin of i_tab occurs 0,

str type string,

end of i_tab.

i_tab-str = 'sap'.

append i_tab.

Regards,

Ramganesan K.

i_tab-str = 'abap'.

append i_tab.

i_tab-str = 'portal'.

append i_tab.

<b> sort</b> i_tab.

loop at i_tab.

write: i_tab-str.

endloop.