2009 Mar 18 2:59 PM
Hi everyone.
I need to turn a sentence into initial capitals. In other words, if I get a string such as
"one thousand and forty dollars" I want a function that returns "One Thousand and Forty Dollars".
Can anyone help
Regards
Martin
2009 Mar 18 3:16 PM
Try this might help:
DATA: lv_string TYPE string VALUE 'one thousand and forty dollars',
lv_temp1(30) TYPE c, lv_temp2(30) TYPE c.
DATA: lv_fin TYPE string.
lv_temp2 = lv_string.
DO.
SPLIT lv_temp2 AT space INTO lv_temp1 lv_temp2.
IF lv_temp1 IS INITIAL.
EXIT.
ENDIF.
TRANSLATE lv_temp1+0(1) TO UPPER CASE.
CONCATENATE lv_fin lv_temp1 INTO lv_fin SEPARATED BY space.
ENDDO.
2009 Mar 18 3:05 PM
i dont know if there is a FM that does exactly THAT, but i´d have ideas how to solve it manually.
first split this string into words, use the "SPLIT" statement for that.
loop at the table in which you splitted.
use offset (1) to just get the first character of every word (record in your split table)
then call FM 2054_TRANSLATE_2_UPPERCASE.
then concatenate your split values into one string again. ready.
2009 Mar 18 3:15 PM
you'll not get function for this i think, u can achieve this through custom coding, I found a code on sdn once, but i dont have right now, will give it in a short while,(abt 1 hr).
кu03B1ятu03B9к
2009 Mar 18 3:16 PM
Try this might help:
DATA: lv_string TYPE string VALUE 'one thousand and forty dollars',
lv_temp1(30) TYPE c, lv_temp2(30) TYPE c.
DATA: lv_fin TYPE string.
lv_temp2 = lv_string.
DO.
SPLIT lv_temp2 AT space INTO lv_temp1 lv_temp2.
IF lv_temp1 IS INITIAL.
EXIT.
ENDIF.
TRANSLATE lv_temp1+0(1) TO UPPER CASE.
CONCATENATE lv_fin lv_temp1 INTO lv_fin SEPARATED BY space.
ENDDO.
2009 Mar 18 3:23 PM
Hi Martin,
you need to separte each word of the sting take it into the separete word..and try to use the TRANSLATE key word with PATTARN..
like below
DATA: text TYPE string.
text = `ADFDFDFD`.
TRANSLATE text USING 'Aasdfsd'.
write:text. "ouptu will be Adfdfdfdand do that for all your words in that string ...and merge into one your final sting...
other than this i think we don't have the option.
hope it helps...
Thanks!