2022 Nov 27 5:36 PM
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.
2022 Nov 27 8:23 PM
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
2022 Nov 28 5:48 AM
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.