Skip to Content

ABAP regex help needed

Hi.

I'm trying to find code in abap using abap_source_scan & regex.

I want to find if developer used to write company code hard coded in program (or plant or a set of others such as vkorg etc)

I've been trying to build a regex using the regex toy and succeded finding the company numbers:

11(\s|pm|qt|00|rt) gave me all the company code I'm searching: 11,11pm,11qt,1100 & 11rt. I wanted to get only lines that include the word "werks" . tried

11(\s|pm|qt|00|rt)(?=werks) didn't work. Any idea How can it be done?

Add comment
10|10000 characters needed characters exceeded

  • Awful answer so I put it in the comments.

    Create a program to look at their transports and go through the programs based on anything they touched. Search the source code of everything they touched for your plant numbers. Then display it as an ALV with a double click.

    Sorry - I can't think of anything else. I'm hoping someone else has a great answer for you.

    Michelle

  • Get RSS Feed

2 Answers

  • Feb 15 at 03:21 PM

    Assuming you also want to exclude commented lines:

    ^[^\*](.+)werks = ‘11

    or cast the net a bit wider with

    ^[^\*](.+)werks(.+)11
    Add comment
    10|10000 characters needed characters exceeded

    • I just tried it and you're partly right, the first one needs the equal sign escaped, but the second variant works for me.

      ^[^\*](.+)werks(.+)'

      Will find

         if werks <> '1234'.

      but ignore

      *    werks = '1234'.

      And of you want to specifically restrict it to equality, then my first variant needs the equal sign escaped:

      ^[^\*](.+)werks \= ‘11

      To break it down:

      ^ : Beginning of line

      [^\*] : Not a *

      (.+) : one or more characters

      werks : werks

      (.+) : one or more characters

      ' : '

      Writing this I suppose a better search would be to include different string delimiters:

      ^[^\*](.+)werks(.+)['|`|\|]
  • Mar 04 at 03:38 PM
    Add comment
    10|10000 characters needed characters exceeded