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?
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.