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 and numbers

Former Member
0 Likes
415

dear all,

lets say if my data coming is with numbers and strings e.g. "123 ABC XYZ"... how can i just get the number out? because the number can be "123" for now and the next "999999" which means the length for number will always change.

and once i do get my number out... do i need to convert it from string into number? thanks for the advice.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
368

Hi,

Pls. use the sample code below to resolve your issue....

DATA: w_char1 TYPE string,
      w_char2 TYPE string,
      w_temp TYPE string.

w_char1 = '12345 ABC DEF 12345'.

w_temp = w_char1.

WHILE w_temp IS NOT INITIAL.
  IF w_temp+0(1) CO '0123456789'.
    CONCATENATE w_char2 w_temp+0(1) INTO w_char2.
  ENDIF.
  SHIFT w_temp LEFT.
ENDWHILE.

WRITE w_char2.

Thanks,

Sid

1 REPLY 1
Read only

Former Member
0 Likes
369

Hi,

Pls. use the sample code below to resolve your issue....

DATA: w_char1 TYPE string,
      w_char2 TYPE string,
      w_temp TYPE string.

w_char1 = '12345 ABC DEF 12345'.

w_temp = w_char1.

WHILE w_temp IS NOT INITIAL.
  IF w_temp+0(1) CO '0123456789'.
    CONCATENATE w_char2 w_temp+0(1) INTO w_char2.
  ENDIF.
  SHIFT w_temp LEFT.
ENDWHILE.

WRITE w_char2.

Thanks,

Sid