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

Formatting Tel Number

Former Member
0 Likes
2,057

I need to format ADRC-TEL_NUMBER and intiliaze it into my variable

It should be 10 digits, no spaces, dashes etc , only numbers

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,962

Hello,

Try like this:


data: l_in_string type SP_TELNO.  
      l_in_string =  ADRC-TEL_NUMBER .
      call function 'TELNUMBER_REMOVE_SPECIAL_CHAR'
           changing  telnumber = l_in_string.
write: l_in_string.

Regards,

vasanth

I need to format ADRC-TEL_NUMBER and intiliaze it into my variable

It should be 10 digits, no spaces, dashes etc , only numbers

12 REPLIES 12
Read only

Former Member
0 Likes
1,962

Hi

use the FM TELNUMBER_REMOVE_SPECIAL_CHAR

Thanks,

Naren

Read only

Former Member
0 Likes
1,962

Hi,

You can try something like this.


DATA: FIELD1(30) TYPE C VALUE '(905) 123-4567',
      FIELD2(10) TYPE C,
      LENGTH TYPE I.
                                                                        
LENGTH = STRLEN( FIELD1 ).
                                                                        
DO LENGTH TIMES.
  IF FIELD1(1) NA '1234567890'.
    MOVE SPACE TO FIELD1(1).
    SHIFT FIELD1 LEFT CIRCULAR.
  ELSE.
    SHIFT FIELD1 LEFT CIRCULAR.
  ENDIF.
ENDDO.
                                                                        
CONDENSE FIELD1 NO-GAPS.
WRITE FIELD1 TO FIELD2.

Also please check this function modules.

TELNUMBER_REMOVE_SPECIAL_CHAR

SX_NUMBER_REMOVE_CHAR


data: v_number type SP_TELNO.

v_number = '(905) 123-4567'.

CALL FUNCTION 'TELNUMBER_REMOVE_SPECIAL_CHAR'
  CHANGING
    telnumber = v_number.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
1,962

I dont know the syntax to that

new_ADRC-TEL_NUMBER = something (ADRC-TEL_NUMBER)

is it something like that

Message was edited by:

Megan Flores

Read only

Former Member
0 Likes
1,962

where should I go to get more information on these function modules. Thanks !

Read only

Former Member
0 Likes
1,963

Hello,

Try like this:


data: l_in_string type SP_TELNO.  
      l_in_string =  ADRC-TEL_NUMBER .
      call function 'TELNUMBER_REMOVE_SPECIAL_CHAR'
           changing  telnumber = l_in_string.
write: l_in_string.

Regards,

vasanth

Read only

Former Member
0 Likes
1,962

Hi

Check this example

DATA: V_TEL TYPE SP_TELNO.

V_TEL = '999-999-9999'.

CALL FUNCTION 'TELNUMBER_REMOVE_SPECIAL_CHAR'

CHANGING

telnumber = V_TEL

.

WRITE: / V_TEL.

Thanks

Naren

Read only

Former Member
0 Likes
1,962

'TELNUMBER_REMOVE_SPECIAL_CHAR'

does not reduce it to 10 digits

Read only

0 Likes
1,962

Hello,

Hello,

Try like this:


data: l_in_string type SP_TELNO.  
      l_in_string =  ADRC-TEL_NUMBER .
      call function 'TELNUMBER_REMOVE_SPECIAL_CHAR'
           changing  telnumber = l_in_string.
write: l_in_string(10)

.

Regards,

Vasanth

Read only

Former Member
0 Likes
1,962

Hi,

Have you tried my custom sample code above?

What is the value of your ADRC-TEL_NUMBER?

Regards,

Ferry Lianto

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,962
data: new_tele(10) type c.

translate ADRC-TEL_NUMBER using '- '.
condense ADRC-TEL_NUMBER no-gaps.
new_tele = ADRC-TEL_NUMBER.

Regards,

RIch Heilman

Read only

Former Member
0 Likes
1,962

Vasanth, your code works, almost. But it takes the first 10 digits from the left, I need the first 10 digits from the right as some of my numbers are more than 10 digits cos they have 0's before them and chopping them from the left is dropping the numbers from the right. For eg. I have a number 01977-554411, This becomes 0197755441. But it should actually become 1977554411

Thanks

Read only

Former Member
0 Likes
1,962

Hi,

Please try this.


data: l_in_string type SP_TELNO,
      l_phone(10) type c. 

l_in_string =  ADRC-TEL_NUMBER .

call function 'TELNUMBER_REMOVE_SPECIAL_CHAR'
  changing  telnumber = l_in_string.

if l_in_string(1) = '0'.
  move space to l_in_string(1)
  condense l_in_string no-gaps.
endif.

write l_in_string to l_phone.