Skip to Content
author's profile photo Former Member
Former Member

Replacing ',,' by space

Hi All,

I have a variable in that the value is "3,,,,,,,,,,Test".

Now the user wants to replace the ",," by space.

Its urgent.

Can anyone give me a solution.

Points will be rewarded immediately.

Regards,

Nikhil Moghe

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    Posted on Dec 03, 2007 at 11:48 AM

    Hi,

    Use replace with all occurances statement

    Try like this

    DATA: myText type string.

    myText = 'abcabcabcabcabc'.

    REPLACE ALL OCCURRENCES OF 'abc' IN myText WITH 'XYZ'.

    Regards,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Nikihl,

      Do like this

      data: text(50) type c value 'a,,,,,b,,,,',
            len type i,
            ind type i,
            pos type i.
      
      len = strlen( text ).
      
      do len times.
      ind = sy-index.
      pos = sy-tabix.
      if text+ind(pos) = ','.
      replace ',' with space into text.
      endif.
      enddo.
      condense text no-gaps.
      write text.

      Regards,

      Satish

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 11:47 AM

    Hi,

    Use replace statment.

    Replace ... all occurences ....

    regards,

    Santosh Thorat

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2007 at 11:47 AM

    hi Nikhil,

    TRANSLATE string USING ', '.

    (pls. note there is a space between , and ')

    if the use wants only one space instead of n comas than you also have to:

    CONDENSE string.

    hope this helps

    ec

    Message was edited by:

    Eric Cartman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 11:48 AM

    Do like this

    REPLACE ALL OCCURRENCES OF ',' in STRING with space.

    Regards,

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2007 at 12:14 PM

    Try yo use

    TRANSLATE string USING ', . '. " , space . space 

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 12:22 PM

    Hi try this...

    data : var type STRING.

    var = '3,,,,,,,,,,,,,,,,,,,,,,,,Test'.

    write var.

    REPLACE ALL OCCURRENCES OF ',' in var with space.

    write :/ var.

    reward poinds if usefull...

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.