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
528

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
506

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

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

2 REPLIES 2
Read only

Former Member
0 Likes
507

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 Member
0 Likes
506

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.