Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8430

Re: String character replacement manipulation

$
0
0

Here is one more way to do it. It should work fine for ABAP release 702 and above.

  1. DATA: text TYPE string VALUE 'You need to count # # and #',
  2.       substring TYPE c VALUE '#'.
  3. DO count( val = text
  4.           sub = substring ) TIMES.
  5.   text = replace( val   = text
  6.                   sub   = substring
  7.                   with  = substring && sy-index
  8.                   occ   = sy-index ).
  9.   IF sy-subrc NE 0.
  10.     EXIT.
  11.   ENDIF.
  12. ENDDO.
  13. WRITE text.

/.


Viewing all articles
Browse latest Browse all 8430

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>