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

Sort by string

Former Member
0 Likes
684

Hi,

Can we sort internal table by some string? I mean If we have materials, need to sort that by string 'R' (materials starts with 'R'). Can we do this using sort statement?

Thanks,

Sudha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
621

Hi,

When you sort the ITAB, it will internally sorted on the field you specify, you cannot sort by first character, second character...etc of the field in the internal table.

3 REPLIES 3
Read only

Former Member
0 Likes
622

Hi,

When you sort the ITAB, it will internally sorted on the field you specify, you cannot sort by first character, second character...etc of the field in the internal table.

Read only

0 Likes
621

Thanks Ravi.

Read only

Former Member
0 Likes
621

hi,

If you need the fields specifically start with 'R' ...do this way ...


loop at itab.
  if itab-field1+0(1)  = 'R' or
  itab-field1+0(1)  = 'r'.
    itab-field2 = 'X'.
  endif.
  modify itab index sy-tabix transporting field2. 
endloop.

sort itab by field2. 

Regards,

Santosh