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

report

Former Member
0 Likes
257

I have string "AA000PGS01901 , the string may be userdefined also

and i want to print only the numeric ....

plz help me....

1 REPLY 1
Read only

Former Member
0 Likes
237

Hi,

If for sure know the number of numeric values in the string then you can simply define a NUMC variable and move the string to it.. like...

data : num(8) type n.

data : str(13) type c.

num = str.

then num will be 00001901.

or you can write a simple subroutine to ignore all the alphabets...

PARAMETERS : p_str(25) TYPE c DEFAULT 'AA000PGS01901'.

DATA : l_len TYPE i.

DATA : l_num(25).

START-OF-SELECTION.

PERFORM get_num USING p_str CHANGING l_num .

WRITE : / p_str, / l_num.

FORM get_num USING value(str)

CHANGING value(num).

CONDENSE str. l_len = STRLEN( str ).

WHILE l_len > 0..

l_len = l_len - 1.

IF str+l_len(1) CA '0123456789'.

CONCATENATE str+l_len(1) num INTO num.

ENDIF.

ENDWHILE.

ENDFORM. " get_num

Let me know if you come across any simple method.

Thanks,

Pavan