cancel
Showing results for 
Search instead for 
Did you mean: 

Formatting input field from 123456789 to 123-45-6789

siongchao_ng
Contributor
0 Kudos

Hi all,

I need to format an input field. When the user enters a value like 123456789, I need to default it to looks like 123-45-6789. After that I need to save the 123-45-6789 back as 123456789. Anyone have any ideas? Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Always you want to do in that format?

write code in on enter of that input field. Get value entered in that input field, split that in 3 parts and do cancatnation with ' -'. Again while saving just

use previous data, what you enter in input field. you get using get_attribute.

Cheers,

Kris.

Former Member
0 Kudos

Hi,

try to create a Conversion Routine and assign it to its domain, is should work...

or you can create and event OnEnter to this field, and do the conversion manually.

siongchao_ng
Contributor
0 Kudos

Hi Krisna,

Can you elaborate how you split '123456789' into 3 parts and concatenate it back into 1 part by adding in '-'?

Abhinav_Sharma
Contributor
0 Kudos

Hi Siong,

You can try out following statement

DATA: input(9) type c,

output(11) type c.

input = '123456789'.

concatenate input(3) '-' input3(2) '-' input5 into output.

write:/ output.

The output should be

123-45-6789

Regards

Abhinav Sharma

Former Member
0 Kudos

Hi,

try like this...

*   navigate from <CONTEXT> to <NODE> via lead selection
    lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).


*   get single attribute
    lo_el_node->get_attribute(
      EXPORTING
        name =  `VALUE1`
      IMPORTING
        value = lv_value1 ).

data : val1 type char20,
       val2 type char20,
       val3 TYPE char20.


     move  lv_value1+0(3) to val1.
     MOVE  lv_value1+3(2) to val2.
     MOVE  lv_value1+5(4) to val3.

CONCATENATE val1 '-' val2 '-' val3 into lv_value1.

*   get single attribute
    lo_el_node->set_attribute(
      EXPORTING
        name =  `VALUE1`
        value = lv_value1 ).

Cheers,

Kris.

Answers (0)