Skip to Content

Duda with REPLACE ALL OCCURRENCES

Hello! Exists the posibility of optimize the next code?

REPLACE ALL OCCURRENCES OF 'á' IN wa_header-justif WITH 'á'.

REPLACE ALL OCCURRENCES OF 'é' IN wa_header-justif WITH 'é'.

REPLACE ALL OCCURRENCES OF 'í' IN wa_header-justif WITH 'í'.

REPLACE ALL OCCURRENCES OF 'ó' IN wa_header-justif WITH 'ó'.

REPLACE ALL OCCURRENCES OF 'ú' IN wa_header-justif WITH 'ú'.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Apr 07, 2016 at 09:10 PM

    Try with Regex - [áéíóú] and replacement á.

    Use program DEMO_REGEX_TOY to play with it.

    If the input text is -

    Thís hás sómé néw stúff

    Output would be (with replace all)

    Thás hás sámá náw stáff

    Regards,
    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 07, 2016 at 10:16 PM

    Since you want to work on the same field a lot, I'd suggest a local macro (this is an example where a macro makes sense):

    define m_rep.

    REPLACE ALL OCCURRENCES OF &2 IN &1 WITH &3.

    end-of-definition.

    (note the sequence of placeholders)


    Now you can code like so.


    m_rep fieldname:

    'from1' 'to1',

    'from2' 'to2',

    'from3' 'to3'.


    With proper naming and indentation, it makes your code more readable. The performance is the same of course... Keep the macro close to the code if possible.


    If the action is more complex and you need to debug, you can use the same technique for readability and issue a perform from the macro. I only use macros for some cases, and this would be one of them.


    Wolfgang


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 08, 2016 at 05:50 AM

    These are HTML tags. I'm fairly sure there are some standard function modules or methods that do this work for you. Or perhaps the escape string function (7.40).

    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.