05-22-2008 10:24 PM
Hello,
I would like to turn the following string '34 GOLDEN GATE BRIDGE ROAD'
into '34 Golden Gate Bridge Raod'
I've tried to look through the forum but cannot find a function which does this.
Is there an easy way of doing this?
Thanks
05-22-2008 10:35 PM
Hi,
I don't this there is easy way to achieve this.
But yes you can code for this.
Go in this way:
Convert whole string in lower case.
Search space in this string. (You can use syntax FIND or SEARCH)
This will give offset location of space in your string. Add 1 to that offset. This is location where you want to have upper case. Check that this charecter is from set (a to z)so that you will not convert any other charecters other than alphabet to upper case (Donno what will happen if you try too). If yes then Change this single alphabet to upper case and search for next space.
Finally you will get your desired result.
I don't think this logic will be too complicated.
I would prefer to develop this logic in a function module so that I can use wherever I want.
reward if useful..
Keep ABAPing..
Ags..
05-22-2008 10:35 PM
Hi,
I don't this there is easy way to achieve this.
But yes you can code for this.
Go in this way:
Convert whole string in lower case.
Search space in this string. (You can use syntax FIND or SEARCH)
This will give offset location of space in your string. Add 1 to that offset. This is location where you want to have upper case. Check that this charecter is from set (a to z)so that you will not convert any other charecters other than alphabet to upper case (Donno what will happen if you try too). If yes then Change this single alphabet to upper case and search for next space.
Finally you will get your desired result.
I don't think this logic will be too complicated.
I would prefer to develop this logic in a function module so that I can use wherever I want.
reward if useful..
Keep ABAPing..
Ags..
05-22-2008 11:19 PM
Hi Just worked it out. Thanks anyways
form toupper using p1 type mystring
changing p2 type mystring.
data v_string type string.
CONSTANTS:
sm2big(52) VALUE
'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'.
DATA:
word(255),
it_words LIKE STANDARD TABLE OF word.
CALL FUNCTION 'STRING_UPPER_LOWER_CASE'
EXPORTING
delimiter = '.'
string1 = p1
IMPORTING
string = p2.
REFRESH it_words.
SPLIT p2 AT space INTO TABLE it_words.
CLEAR p2.
LOOP AT it_words INTO word.
TRANSLATE word(1) USING sm2big.
IF sy-tabix = 1.
p2 = word.
ELSE.
CONCATENATE p2 word INTO p2
SEPARATED BY space.
ENDIF.
ENDLOOP.
endform. "toupper
05-23-2008 12:08 AM
Or you can try this... without worrying about the offset calculations...
DATA : l_string(50) VALUE 'hello dfadfasdj how r you.. WHAT'.
DATA : l_string1(50).
DATA : l_string2(50).
WRITE : l_string.
DO.
SPLIT l_string AT space INTO l_string1 l_string.
CALL FUNCTION 'STRING_UPPER_LOWER_CASE'
EXPORTING
delimiter = ''
string1 = l_string1
IMPORTING
string = l_string1
EXCEPTIONS
not_valid = 1
too_long = 2
too_small = 3
OTHERS = 4 .
IF sy-subrc = 0.
CONCATENATE l_string2 l_string1 INTO l_string2 SEPARATED BY space.
ENDIF.
IF l_string IS INITIAL.
CONDENSE l_string2.
EXIT.
ENDIF.
ENDDO.
WRITE : / l_string2.
05-24-2020 7:20 PM
This function ...
CALL FUNCTION 'ISP_CONVERT_FIRSTCHARS_TOUPPER'
EXPORTING
input_string = lv_string_input
* SEPARATORS = ' -.,;:'
IMPORTING
output_string = lv_string_output.