Application Development and Automation 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: 

Using Regex to determine certain conditions in ABAP

0 Kudos
591

Hello guys,

I am a newcomer to the ABAP world and I've been tasked with coming up with a piece of code that uses regex to better control the outcome of a certain program with search results.

The task involves the following:

- Usage of regular expressions to determine if, anywhere in the formula string, there is a combination of a formula parameter (from table TQ75T as described above) and a number of max 5 digits, in which the number corresponds to the MIC number (which usually is represented by a 4-digit number with leading-zeroes).

- To consider cases where the same MIC is repeated in a formula (it is also possible), only unique MICs should be considered (eg. if a single MIC exists twice in a formula and no other exists, it should be considered to be checked).

E.g. for MIC formulas. It can have anything between 2 and 5 digits (after the first 2). The first 2 digits are always the result of a field in the table TQ75T:

- C00040 + C00050 + C00060 + C00070
- C0020 / C0010

My idea would be to first SELECT the field from table TQ75T to have the first 2 digits. And then implement regex options to go according to what is described above.

Would you be able to help me?

Thank you.

2 REPLIES 2

BaerbelWinkler
SAP Champion
SAP Champion
462

Hi Pedro,

as you are new to ABAP and REGEX you may want to "play" with this SAP-provided program:

DEMO_REGEX_TOY

It explains the various REGEX options and lets you try things out.

Hope this helps!

Cheers

Bärbel

Sandra_Rossi
Active Contributor
462

You should read the documentation about Regular Expressions, then play with DEMO_REGEX_TOY to practice, as Bärbel explained. If you don't understand the documentation, please tell us what you don't understand. Also it's important to know if you use ABAP 7.55 or below, because you should usually prefer PCRE over POSIX due to performance.