2016 Apr 07 9:59 PM
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 'ú'.
2016 Apr 07 10: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
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 'ú'.
2016 Apr 07 10: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
2016 Apr 07 10:35 PM
2016 Apr 07 10:52 PM
Simplest form - REPLACE ALL OCCURRENCES OF REGEX 'u*' IN text WITH 'x'
http://help.sap.com/abapdocu_740/en/abapreplace_in_pattern.htm#!ABAP_ADDITION_1@1@
Regards,
Naimesh Patel
2016 Apr 07 10:57 PM
2016 Apr 07 11:18 PM
2016 Apr 08 12:47 AM
Thanks! Like:<br>
REPLACE ALL OCCURRENCES OF REGEX 'áéíóú' IN my_var WITH 'param1' 'param2' 'param3...?
2016 Apr 07 11: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
2016 Apr 08 6: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).
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |