Application Development 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: 

ASCII Character Processing in ABAP

Former Member
0 Kudos

Hi,

I have to remove the special characters (+/-, Ø) from the Text and process the same with out the Special Characters in it. The General requirement is that, I need to remove the special characters, which fall between the ASCII Values 32 to 128. Is there a Standard Function Module or Function available in SAP. Can you please suggest me a good solution for this requirement. Thanks for your Help in Advance.

Thanks and Regards,

Kannan.

Message was edited by: Kannan SA

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

DATA: v_char.

FIELD-SYMBOLS: .

IF v_int1 IN r_hex.

CONCATENATE v_result v_char INTO v_result.

CONDENSE v_result.

ENDIF.

ENDDO.

WRITE: / v_result.

Hope this helps..

Thanks,

Naren

9 REPLIES 9

Former Member
0 Kudos

i dont know exactly is there any function module available,but here i am giving small logic,may be helpful to you.

you can use REPLACE command to replace the special characters with some space.

data : V_CHAR(100) type c.

<b>REPLACE ALL OCCURRENCES OF ',' IN V_CHAR WITH ''.</b>

THEN use CONDENSE To remove the spaces between the characters.

<b>CONDENSE V_CHAR.</b>

Regards

Srikanth

Message was edited by: Srikanth Kidambi

0 Kudos

Hi Srikanth,

Thanks for the reply. Actually i have to look for the Special Characters which has ASCII Values between 32 to 128. So in each Text, i have to check for the occurance of 96 Special Characters. There may be one or more special characters that exists in the Text.

Thanks and Regards,

Kannan.

christian_wohlfahrt
Active Contributor
0 Kudos

Hi!

I don't think there is a function module for such a task - everyone might understand something different under 'special character'.

But you can use the ABAP-statement TRANSLATE text USING pattern. In pattern you can define pairs of characters as a replacement-rule, just have a look into the online help.

You might run into a problem defining all the source-values, maybe you can use hex-defined structures as a help variable.

Regards,

Christian

0 Kudos

Hi Christian,

Thanks for the reply. Can you please give me a code sample for the logic and hex-defined structures? Thanks for your Help in Advance

Thanks and Regards,

Kannan.

Former Member
0 Kudos

Hi,

DATA: v_char.

FIELD-SYMBOLS: .

IF v_int1 IN r_hex.

CONCATENATE v_result v_char INTO v_result.

CONDENSE v_result.

ENDIF.

ENDDO.

WRITE: / v_result.

Hope this helps..

Thanks,

Naren

0 Kudos

Hi Naren,

Please have a look at the link below.

http://www.lookuptables.com/. The good ones are from 32 to 127. Rest of them are giving problem. Please also look the extended ASCII Codes. 0 - 31 and 128 - 255 are the problem ones. The objective is not to allow them in the Text. Please let me know your thoughts.

Thanks and Regards,

Kannan.

Message was edited by: Kannan SA

Message was edited by: Kannan SA

0 Kudos

THe following codereplaces special chars ( < 33 and > 127 ) with space.

data: len type i,
      off type i,
      hex1 type x value '1F',
      hex2 type x value '80'.

data asci_str(100) type c.

field-symbols <fs> type any.

len = strlen( asci_str ).

while off lt len.
  assign asci_str+off(1) to <fs> casting type x.
  if <fs> le hex1 or <fs> ge hex2.
    asci_str+off(1) = ' '.
  endif.
  add 1 to off.
endwhile.

write:/ asci_str.

Regards

Sridhar

Former Member
0 Kudos

Hi,

The code I mentioned will remove the characters that doesn't fall between 32 and 128..

Is this your requirement??

Thanks,

naren

0 Kudos

Hi All,

Thanks for all your Help.

Thanks and Regards,

Kannan.