Skip to Content
0
Jun 15, 2021 at 06:08 AM

Loop through a file, check for specific characters and replace. Use new abap

131 Views

Hi all,

I would like to loop through a file (open dataset, read dataset, etc.), check for certain characters in the rows of this file, and replace where necessary. I know how to do this but I still use the old abap code, is there a neater, newer, better, way of doing this with abap 7.40?

Here is a sample of the code I have. There are more characters that I have to test for but this is just a small example to demonstrate my point:

        IF gv_string CS 'E#'.
          REPLACE 'E#' WITH 'n'.
        ELSEIF gv_string CS 'M<'.
          REPLACE 'M<' WITH 'la'.
        ELSEIF gv_string CS 'T#'.
          REPLACE 'T#' WITH 'abc'.
        ELSEIF gv_string CS 'XZ'.
          REPLACE 'XZ' WITH 'w'.
        ENDIF.

All help, tips, etc., are really greatly appreciated.

I wish you all a nice day further.