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

need to delete characters

Shahid
Product and Topic Expert
Product and Topic Expert
0 Likes
459

is there any fm to delete characters in a variable.

for ex: v = 12a3.

result v = 123.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
437

Hi Shahid,

One more solution.

DATA V_STRING TYPE '12a3'.

DATA V_LENGTH TYPE I.

DATA V_COUNTER TYPE I.

V_LENGTH = STRLEN( V_STRING ).

DO V_LENGTH TIMES.

IF V_STRING+V_COUNTER(1) CA SY-ABCDE.

V_STRING+V_COUNTER(1) = SPACE.

ENDIF.

V_COUNTER = V_COUNTER + 1.

ENDDO.

CONDENSE V_STRING.

Thanks,

Vinay

2 REPLIES 2
Read only

matt
Active Contributor
0 Likes
437

No, you'll have to write one yourself.

TRANSLATE var TO UPPER CASE.
TRANSLATE var USING 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z '.
CONDENSE var NO-GAPS.

Or if you really want to ensure only numerics, scan the field character by character, replacing non-numerics with SPACE, then use CONDENSE as above.

matt

Read only

Former Member
0 Likes
438

Hi Shahid,

One more solution.

DATA V_STRING TYPE '12a3'.

DATA V_LENGTH TYPE I.

DATA V_COUNTER TYPE I.

V_LENGTH = STRLEN( V_STRING ).

DO V_LENGTH TIMES.

IF V_STRING+V_COUNTER(1) CA SY-ABCDE.

V_STRING+V_COUNTER(1) = SPACE.

ENDIF.

V_COUNTER = V_COUNTER + 1.

ENDDO.

CONDENSE V_STRING.

Thanks,

Vinay