‎2008 Mar 09 6:42 AM
hi,
Have an issue where special characters you can't see via se16 are at the end of a character field. I need a way to strip them off via abap. Is there a good way to do this? New to abap, so be gentle. Have tried about everything including shift. Is there a trim command that can be used?
Thanks in advance.
‎2008 Mar 09 8:17 AM
HI,
The VB "trim" sentence is CONDENSE in ABAP. But CONDENSE drops all spaces before and after the string. I think you are looking for something like mid$, Left$ or Right$ (in VB again).
You can use substrings to do that, like
Code:
DATA: chars TYPE I.
chars = strlen( yourstring ) - 1.
IF yourstring+chars = yourspecialchar.
yourstring = yourstring(chars).
ENDIF.
That mini-code sample takes the lenght of your string (minus the last character), and checks that last character. If that last one is the special one you are trying to drop, the sentence between IF-ENDIF drops it.
Substrings are used like
Code:
string+pos1(pos2)
where pos1 is the amount of characters displaced from the beguinning and pos2 the number of characters taken.
IE: string+pos1(pos2) would be the same than VB's Mid$(string, pos1, pos2)
Wish it helps,
Cheers,
Chandra Sekhar.
‎2008 Mar 09 8:34 AM
Just for correctness
in ABAP
fieldn(m) extracts m characters starting from the the character at position n1
e.g. if field contains the string 'ABCDEFG' the statement field+2(3) returns the string 'CDE'
in VB
the statement Mid$(string,n,m) extracts m characters starting from the n-th character,
e.g. if string is 'ABCDEFG' the statement Mid$(string,2,3) returns the string 'BCD'.
Bye, Antonino