cancel
Showing results for 
Search instead for 
Did you mean: 

how to make first character of an input field capitalized?

siongchao_ng
Contributor
0 Kudos

Hi all,

How to make an input field automatically capitalized after user enters a value? Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

you can do this by using FM.. 'SWA_STRING_TO_UPPERCASE'

DATA: OUTPUT TYPE STRING.
CALL FUNCTION 'SWA_STRING_TO_UPPERCASE'
 EXPORTING
   INPUT_EXPRESSION                 = 'WEBDYNPRO'
*   INPUT_STRING                     =
   PRESERVE_EXISTING_CAPITALS       = ''
   CAPITALIZE_AFTER_SPACE           = 'X'
   LANGUAGE                         = SY-LANGU
 IMPORTING
   OUTPUT_STRING                    = OUTPUT
*   OUTPUT_EXPRESSION                =
 EXCEPTIONS
   EXPRESSION_TRUNCATED             = 1
  OTHERS                           = 2
          .
IF sy-subrc  0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

OR

You can do by using TRANSLATE Command, you need to use some logic.

data : TEXT(10) type C.

data : T type C.

TEXT = kris'.

move TEXT+0(1) to T.

translate T to upper case.

concatenate T TEXT+1(9) into TEXT.

write : TEXT.

Cheers,

Kris.

Edited by: kissnas on Jun 1, 2011 7:06 AM

Answers (1)

Answers (1)

sahai
Contributor
0 Kudos

hi,

it depends on the data element of the attribute to which you bind the input field.

regards,

sahai.s

siongchao_ng
Contributor
0 Kudos

Hi Sahai,

Data element either make all lower case letters or all capitalized letters. I just want the first character of a string capitalized while the rest stay as lower case. Thanks.

Abhinav_Sharma
Contributor
0 Kudos

Hi Siong,

If you want to convert the first character in to the Uppercase you have to write a logic by your own. It is very simple.

You can try out following code:

data : in_str(50) value 'sample test'.

data : itab(50) occurs 0 with header line.

data : out_str(50).

split in_str at space into table itab.

loop at itab.

translate itab+0(1) to upper case.

concatenate out_str itab into out_str separated by space.

endloop.

write : / out_str.

It will return the sample test as Sample Test. You can use this code in your application and can change the case of the context attribute

Regards

Abhinav