2008 Nov 27 6:58 AM
Hi,
I need to convert letter, example : UNITED KINGDOM into United Kingdom
what is your suggested method?
The best FM i can find is string_upper_lower_case but the result will be United kingdom, only the first letter is translated to capital.
Please help. Thanks.
2008 Nov 27 7:01 AM
Hi,
Try this.
v_str = 'UNITED KINGDOM'.
Split v_str at space into itab.
Loop at itab.
Call your FM.
Concatenate new_str itab-str into new_str separated by space.
endloop.
Regards,
Bhupal
Hi,
Try this.
v_str = 'UNITED KINGDOM'.
Split v_str at space into itab.
Loop at itab.
Call your FM.
Concatenate new_str itab-str into new_str separated by space.
endloop.
Regards,
Bhupal
2008 Nov 27 7:01 AM
Hi,
Where did u maintain UNITED KINGDOM, there u can maintain United Kingdom.
2008 Nov 27 7:01 AM
Hi,
Try this.
v_str = 'UNITED KINGDOM'.
Split v_str at space into itab.
Loop at itab.
Call your FM.
Concatenate new_str itab-str into new_str separated by space.
endloop.
Regards,
Bhupal
2008 Nov 27 7:02 AM
2008 Nov 27 8:24 AM
Hello,
You can use the FM SWA_STRING_TO_UPPERCASE to convert the string to a title case (initials of each word in capitals). Have a look at the below code:
SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS: p_input TYPE swaexpdef-expr.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
DATA: v_output_string TYPE swaexpdef-expr.
WRITE: / 'The input string is: ', p_input.
CALL FUNCTION 'SWA_STRING_TO_UPPERCASE'
EXPORTING
input_expression = p_input
INPUT_STRING =
preserve_existing_capitals = ' '
capitalize_after_space = 'X'
IMPORTING
OUTPUT_STRING =
output_expression = v_output_string
EXCEPTIONS
expression_truncated = 1
OTHERS = 2.
IF sy-subrc EQ 0.
WRITE: 'The converted string in title case is: ', v_output_string.
ENDIF.
END-OF-SELECTION.
Regards,
Namrata
2008 Nov 27 8:41 AM
Hello,
You can use the FM SWA_STRING_TO_UPPERCASE to convert the string to a title case (initials of each word in capitals). Have a look at the below code:
SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS: p_input TYPE swaexpdef-expr.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
DATA: v_output_string TYPE swaexpdef-expr.
WRITE: / 'The input string is: ', p_input.
CALL FUNCTION 'SWA_STRING_TO_UPPERCASE'
EXPORTING
input_expression = p_input
INPUT_STRING =
preserve_existing_capitals = ' '
capitalize_after_space = 'X'
IMPORTING
OUTPUT_STRING =
output_expression = v_output_string
EXCEPTIONS
expression_truncated = 1
OTHERS = 2.
IF sy-subrc EQ 0.
WRITE: 'The converted string in title case is: ', v_output_string.
ENDIF.
END-OF-SELECTION.
Regards,
Namrata
2008 Nov 27 10:08 AM
hi ,
just Create a Z funciton module with the Below Code , its working Fine
Import Param:
STRING1
Export Param :
STRING
Exceptions
NOT_VALID
TOO_LONG
TOO_SMALL
----
DATA :
IT_TXTS TYPE TABLE OF STRING, "Tabel for data storing
WA_TXTS(100) TYPE C, "Getting each words
CP_TEXT TYPE STRING, "Copying text
NN_TEXT TYPE STRING. "Result text
*
CP_TEXT = STRING1.
SPLIT CP_TEXT AT SPACE INTO: TABLE IT_TXTS.
LOOP AT IT_TXTS INTO WA_TXTS.
PERFORM CHANGE_CASE USING WA_TXTS.
CONCATENATE NN_TEXT WA_TXTS INTO NN_TEXT SEPARATED BY SPACE.
ENDLOOP.
CONDENSE NN_TEXT.
*
CASE SY-SUBRC.
WHEN 0.
STRING = NN_TEXT.
EXIT.
WHEN 2.
RAISE NOT_VALID.
WHEN 3.
RAISE TOO_LONG.
WHEN 4.
RAISE TOO_SMALL.
ENDCASE.
2008 Nov 27 3:46 PM
Not sure why, but I get blank from the output.
this FM has obsoleted?
FM -> CALL FUNCTION 'SWA_STRING_TO_UPPERCASE'
2008 Nov 27 4:29 PM
This works:
REPORT ztest LINE-SIZE 80 MESSAGE-ID zc.
DATA: text TYPE string VALUE 'UNITED KINGDOM'.
WRITE: / 'Before -', text.
CALL FUNCTION 'SWA_STRING_TO_UPPERCASE'
EXPORTING
input_string = text
preserve_existing_capitals = ' '
capitalize_after_space = 'X'
language = sy-langu
IMPORTING
output_string = text
EXCEPTIONS
expression_truncated = 1
OTHERS = 2.
WRITE: / 'After -', text.Output:
Before - UNITED KINGDOM
After - United KingdomRob
Edited by: Rob Burbank on Nov 27, 2008 11:42 AM
2008 Nov 27 4:37 PM
HI,
I think this cannot be possible...sap either convert's to upper case or lower case but not as per your requirement. you need to develop your onw functionality for this.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |