Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

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?

5 REPLIES 5

mmcisme1
Active Contributor
0 Kudos

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

pokrakam
Active Contributor

Assuming you also want to exclude commented lines:

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

or cast the net a bit wider with

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

0 Kudos

Thanks Mike Pokraka , tried it with DEMO_REGEX_TOY but I got nothing, any idea why?

I tchanged the text and added "11" and "werks" in thw "Text box".

Thanks

Ariel

pokrakam
Active Contributor
0 Kudos

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(.+)['|`|\|]

horst_keller
Product and Topic Expert
Product and Topic Expert