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

Code

Hi ,

There is a single field in an ITAB I need to check th field and replace some characters for example:

ITAB-f1 = 130 " front & 12 " back

I need to change it like this :

130 inches front and 12 inches back

anyone please give me the code.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Mar 02, 2007 at 03:10 PM

    If you are on a 46c release, you can to this.

    
    report zrich_0001 .
    
    data: begin of itab occurs 0,
          str type string,
          end of itab.
    
    
    itab-str =  '130 " front & 12 " back'.
    append itab.
    
    
    loop at itab.
      while sy-subrc = 0.
        replace '"' with 'inches' into itab-str.
        replace '&' with 'and' into itab-str.
      endwhile.
      modify itab.
    endloop.
    
    
    
    loop at itab.
      write:/ itab-str.
    endloop.
    
    

    With newer releases, the REPLACE statement allows you to do ALL OCCURANCES, which means that you don't need the WHILE to loop it.

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 02, 2007 at 03:04 PM

    Hi,

    You can use REPLACE command or try this FM STRING_REPLACE

    Regards,

    Amit

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 02, 2007 at 03:04 PM

    Hi,

    Loop at ITAB.
    REPLACE '''' with 'Inches' into itab-f1.
    REPLACE '&' with 'and' into itab-f1.
    modify ITAB.
    Endloop.

    Regards

    Sudheer

    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.