Skip to Content
avatar image
Former Member

ASCII Character Processing in ABAP

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 28, 2006 at 04:30 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • avatar image
    Former Member
    Aug 28, 2006 at 03:49 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • avatar image
    Former Member
    Aug 28, 2006 at 07:38 PM

    Hi,

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

    Is this your requirement??

    Thanks,

    naren

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 28, 2006 at 03:54 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.