You are on page 1of 2

ABAP Trick - Clean a given string by removing unwanted characters Tags: sy-fdpos, Category: ABAP Development Expert Abaper

Company: DivulgeSAP Posted on 21 Aug, 2011 10:08 AM

This article shows a simple ABAP trick to clean a given string by removing all unwanted characters. The ABAP program given below does as shown in the screen shot below:

report data:

zcleanstr.

char1(60) type c, str2 type string, ch(1) type c. field-symbols type c. parameters p_str type string. parameters p_chk type string default '1234567890'. concatenate p_chk space into p_chk respecting blanks. char1 = p_str. *sy-fdpos: Found Location in Byte or Character String while not p_str co p_chk. ch = p_str+sy-fdpos(1).

replace all occurrences of ch in p_str with ''. endwhile. write p_str.

You might also like