Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

string conversion

Former Member
0 Likes
924

Hi all,

I have one phone number field. and the numbers are like 123-456-7891.

Now i need convert this so that it should not allow to contain spaces, hyphen, slash etc. while downloading it to a file.

It should contain only numbers.

How can we do this.

can anybody please help me?

Thanks,

sudheer

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
897

HI,

First replace '-' by space using REPLACE

then use CONDENSE to remove spaces.

Try this .

8 REPLIES 8
Read only

Former Member
0 Likes
898

HI,

First replace '-' by space using REPLACE

then use CONDENSE to remove spaces.

Try this .

Read only

Former Member
0 Likes
897

Use replace all occurrences ..

replace all occurrences of '-' in v_phone with ''.

condense v-phone.

Read only

Former Member
0 Likes
897

Hi,

try this...

declar a variable type of N.

move the values to that variable.

var1 type N.

loop at itab.

move itab-telno to var1.

move var1 to itab-telno.

modify itab.

endloop.

Edited by: prabhu p on Jul 16, 2008 1:07 PM

Read only

asik_shameem
Active Contributor
0 Likes
897

Hi

Do in this way.

REPLACE ALL OCCURRENCES OF '-' IN gv_number WITH ''.

Read only

Former Member
0 Likes
897

Hi,

Please check this,

DATA:
w_num(15) type c value '123-456-7891' .
CONSTANT : c_hypen type value '-'.

REPLACE ALL OCCURRENCES OF c_hypen
IN w_num WITH space.

CONDENSE w_num .

Regards

Adil

Read only

former_member787646
Contributor
0 Likes
897

Hi

Try this...

Data: str1(20) type c, str(2) type c, char1 type c.

Data: len type i, cnt type i value 0.

str1 = '123-456-7891'.

str2 = ''.

len = STRLEN( str1 ).

While ( i <= len )

char1 = str1+i(1).

IF char1 CO '123456789'.

CONCATENATE str2 char1 into STR2.

ENDIF.

i = i + 1.

EndWhile

WRITE:/ STR2.

Hope this would help you.

Murthy

Edited by: Kalyanam Seetha Rama Murthy on Jul 16, 2008 1:17 PM

Read only

Former Member
0 Likes
897

Hello


data: str1(10),
      str2(10),
      str3,
      len type i.

str1 = '123-456+09'.

len = strlen( str1 ).

do len times.

str3 = str1(1).
if str3 co '0123456789'.
  concatenate str2 str3 into str2.
endif.
shift str1 left.
enddo.

write: str2.

Read only

Clemenss
Active Contributor
0 Likes
897

Hi sudheer,

if you are on ECC600 (ABAP640) or higher, you can use regular expressions


DATA: LV_PHONE TYPE STRING VALUE '123-456-7891' .
REPLACE ALL OCCURENCES OF REGEX [^0-9] IN LV_PHONE WITH ''.

should remove all non-numeric characters.

Regards,

Clemens

Edited by: Clemens Li on Jul 16, 2008 2:08 PM