This is a follow up to the article Enhanced variant configuration tool

In this blog some developement specific points are shown which ensure that the characteristic configuration is evaluated properly. This are the first thoughts and if you have some improvement ideas, do not hesitate to mention them.

characteristic | selection criteria | value expression |
---|---|---|

TrayType | Length > 200 or Width > 50 or Heigth > 20 | BIG |

TrayType | Length < 100 and Width < 20 and Heigth < 10 | SMALL |

TrayType | DEFAULT | MEDIUM |

ChocolateType | DEFAULT | FirstWord(MaterialCode) |

ChocolateType | MaterialCode = “chocolate mix” | materialCode |

WEIGHT | TrayType = ‘BIG’ | ROUND(Length * Width * Height*2, 2, ‘X’) + 20 |

WEIGHT | TrayType = ‘SMALL’ | ROUND(Length * Width * Height*2, 2, ‘X’) + 10 |

1. object dependency with variant function

Each characteristic which should be calculated gets a variant function assigned in the object dependencies. This is linked to one function module. To avoid the need for separate function module for each characteristic some “help characteristics” can be very useful.

FUNCTION Z_EvaluateTrayType

(Length = $ROOT.Length,

Width= $ROOT.Width,

Height = $ROOT.Height,

**TARGET_CHARACTERISTIC = ‘TrayType’**

**FUNCTION_RESULT = SELF.TrayType**)

TARGET_CHARACTERISTIC and FUNCTION_RESULT are two additional characteristics to get the interface between variant function and function module more generic. Well this is a bit tricky and I am still searching for a better solution – do you have one? – but its working.

Target_Characteristic is defined as input variable and Function_result the only output variable which will get the value of function result.

Now you can for example calculate the TrayType, Volume, Weight, Groundfloor with the same function module by setting the TARGET_CHARACTERISTIC to the desired value as they use all the same input characteristics.

2. replacement of characteristics in formulas

To evaluate the selection criteria and the value expression a more or less complex parser is needed. I found in ABAP only the eval_formula, which does fit quite good for arithmetical expressions but not for text expressions, have you got any hints for me?

Finally I settled with REGEX replacement but I am still thinking about switching to a conventional top down or bottom up parser. What do you think?

3. replacement of sub characteristics

Subcharacteristics, like used when calculating the WEIGHT characteristic are done by using recursive function calls.

4. handling of brackets and boolean expressions

Brackets in numerical expressions are coverd quite good through the SAP standard method EVAL_FORMULA. This method provides also some standard functions as rounding to integers, square functions and so on.

The function EVAL_FORMULA can also process boolean expressions, well text comparisions have first be transfered by pure code to a number value (0 or 1)

Numeric functions like Length > 200 or Width > 50 or Heigth > 20 (Length, Width, Height) are characteristics which are replaced with their numerical value can be entirely passed to EVAL_FORMULA.

5. user defined functions

User defined functions like FirstWord(MaterialCode) or for example a oracle like decode function have to be coded in ABAP. To spot formulas in the expressions I used onces more regular expressions.

A bit tricky is the combination of user defined functions with characteristics. I read somewhere about the definition of user defined functions together with EVAL_FORMULA, anybody has good experience with them and want to share it?

6. SAP standard functions

Functions, like substring, round are already available in ABAP. Nevertheless some mapping from the expressions to the ABAP function call has to be done.

All together a lot of coding is necessary. But it should only be necessary once and the big advantage of the solution is that for later configuration changes no further programming effort is needed and thus leads to a efficient and time-consuming configurable system -> i hope so ðŸ™‚

Any feedback, especially to the questions is welcome.

Andreas

Tapio ReisingerHello Andreas,

as I wrote in your other blog, in general there is already another tool available which fullfills your requirements.

But I also made some thoughts about an “enhanced” version of it. If you like we can share our “visions”.

Best regards, Tapio

Andreas GautschPost authorHello Tapio!

Thanks for your input. Currently I am confident with the already implemented ABAP solution, it fits too all of our requirements and I will not take more effort into the solution or change it with another tool.

But if there arise additional requirements or some other topics where ECP could fit I come back to you. Let me know if you want to know some further details of the above shown solution.

Regards, Andreas

Tapio ReisingerHello Andreas,

aah ok. I didn’t noticed that you post this already back in November. If you found a solution and it works for you, fine. You should keep it.

Yes, I would be interested about your solution. And I’m also interested in how you are adopting agile methodologies, but I think it’s too much off-topic to discuss here. Maybe you accept the following, so we can discuss about it in a bit more detail. and also in our mother lanuage, I guess. ðŸ˜‰

Best regards, Tapio