2008 Jul 10 1:53 PM
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
2008 Jul 10 1:56 PM
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.
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
2008 Jul 10 1:56 PM
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.
2008 Jul 10 1:57 PM
2008 Jul 10 2:10 PM
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
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |