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

Extruct numbre from string

Former Member
0 Likes
1,401

Hi,

Please I wont to check if my line(string) content a numbre and after that I wont to extruct it.

Have u some ABAP instruction to extruct numbre from a string.

Thanks

Best regard

1 ACCEPTED SOLUTION
Read only

former_member222860
Active Contributor
0 Likes
1,364

Use this:

data: v_str type string value 'SAPABAP123'.
data: v_num(3) type n.

v_num = v_str.
write:/ v_num.

12 REPLIES 12
Read only

former_member222860
Active Contributor
0 Likes
1,365

Use this:

data: v_str type string value 'SAPABAP123'.
data: v_num(3) type n.

v_num = v_str.
write:/ v_num.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,364

Hello,

Try this code:

DATA:
      v_string TYPE string,
      v_temp   TYPE char1,
      v_number TYPE string,
      v_len TYPE i,
      v_cnt TYPE i.

v_string = 'ABCD123EF456GH'.

v_len = STRLEN( v_string ).

DO v_len TIMES.
  v_temp = v_string+v_cnt(1).
  v_cnt = v_cnt + 1.

  IF v_temp CA '0123456789'.
    CONCATENATE v_number v_temp INTO v_number.
    CONDENSE v_number.
  ENDIF.
ENDDO.

WRITE: v_number.

Hope this helps.

Br,

Suhas

Read only

Former Member
0 Likes
1,364

Hi,

The below code will solve your problem;

Data : lv_str TYPE string,
        tmp_str TYPE string.

lv_Str = 'ASFSsd123ASDF3$#s23187'.
tmp_str = lv_str.
REPLACE ALL OCCURRENCES OF REGEX '\D' IN tmp_str WITH ''.

tmp_str will contain the numbers only. If it is empty mean there is no numbers in the given string.

Regards

Karthik D

Code Edited by: Karthik D on Jun 18, 2009 2:32 PM

Read only

0 Likes
1,364

hi Karthik D.

I have a erreor message :

The word "REGEX" is reserved.

have a solution for this.

Thanks for your help.

Issam

Read only

0 Likes
1,364

Hi,

What server you are working on, i dont get any error in my ECC 6.0 system. REGEX may not be supported in previous versions i guess.

Regards

Karthik D

Read only

0 Likes
1,364

I m working in version 4.7

Issam

Read only

0 Likes
1,364

Hi ,

Try using this Function module

'FIEB_EXTRACT_NUMBERS'

Hope this helps. Let me know if the probelm still persist.

Regards,

Janaki.

Read only

0 Likes
1,364

>

> I m working in version 4.7

>

> Issam

Sorry, i fear its not supported in version 4.7. You have to go with any of the other solutions given above.

Regards

Karthik D

Read only

Former Member
0 Likes
1,364

Hi,

check this link.

link:[;

hope it'll help u.

Regards,

Sneha.

Read only

Former Member
0 Likes
1,364

DATA:

v_string TYPE string,

v_temp TYPE char1,

v_number TYPE string,

v_len TYPE i,

v_cnt TYPE i.

v_string = 'ABCD123EF456GH'.

v_len = STRLEN( v_string ).

DO v_len TIMES.

v_temp = v_string+v_cnt(1).

v_cnt = v_cnt + 1.

IF v_temp ne sy-abcd..

CONCATENATE v_number v_temp INTO v_number.

CONDENSE v_number.

ENDIF.

ENDDO.

WRITE: v_number.

Read only

0 Likes
1,364

Hi every bady,

Thank you for your help mey problem is resolved with solution of M "Mahesh Reddy" and also "Janaki Nair with FM : FIEB_EXTRACT_NUMBERS"

Thank you.

Best regard.

Issam

Read only

Former Member
0 Likes
1,364

Hi,

try using 'Contains Any' CA...