Recently we started to develop a tool to be able to react flexible and fast to the changing requirements in product configuration. I will show in this blog the current solution and you are invited to comment, improve or also mention pros and cons of the shown solution. Do not hesitate to share your opinion and questions.
The main goals of the desired solution are:
1. Every - also complicated - variant configurations can be done by pure configuration and there is no need for writing any ABAP code.
2. The whole configuration of one product can be viewed and managed on one screen
3. The solution is based entirely on the existing SAP ECC variant configuration.
Lets assume you have a packaging company for sweet tasty chocolate and you parcel the different bar sizes into different cases and place diffrent label on top of the closed case.
The products have different heights, widths and lenghts and you have lets say 3 different boxes small medium and large.
How to you assign the products to the boxes?
Further how you configure the text on the label. Lets say you want to print the first word of the product description on the label?
Well, the variant configuration of SAP offers a bunch of features to solve this things. The two above tasks could be solved with Variant functions and some ABAP code behind (you can find a good introduction in Variant Functions with an example.)
But what happens if you want to make some small changes - do you want really want that for every configuration change you have to find a developer who makes the necessary code changes for you?
So in the current solution the user view on the product configuration looks like this (simplified):
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 |
Volume | DEFAULT | Length * Width * Height |
.... |
That mean for example an customer order with the materialCode "white chocolate" and a characteristic Length = 250 should get additional characteristics TrayType=BIG and ChocolateType=White. In another customer order with characteristic Length=100 the TrayType will be MEDIUM and so on.
If the BIG box should only be used if the Length > 210 the user can change this object dependency by simply changing the corresponding table entry.
So how this can be implemented, what would you suggest?
In my opinion the above mentioned variant functions fits best to get there and the solution is already working quite good with them. With some adaptions the variant functions get rather generic and to apply a change the only thing which remains for the user is to change the configuration.
Code Solution drafted
1. object dependency with variant function
for each desired additional characteristic an object dependency should be created. For example
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.
2. adaption to function module of the above mention example
The function module which links to the variant function evaluates the characteristic value for the target characteristic and writes it back to the variant function.
Adapted example code for function module
* GET name of target characteristic
CALL FUNCTION 'CUOV_GET_FUNCTION_ARGUMENT'
EXPORTING
ARGUMENT = 'TARGET_CHARACTERISTIC'
IMPORTING
* VTYPE =
SYM_VAL = LV_TARGET_CHARACTERISTIC
* NUM_VAL =
* IO_FLAG =
TABLES
QUERY = QUERY
EXCEPTIONS
ARG_NOT_FOUND = 1
OTHERS = 2
...
if LV_TARGET_CHARACTERISTIC = 'TrayType'.
*Select lines of the configuration table which fits the characteristics best and return the value expression.
*Evaluate the value expression and write the result into the function result
LV_FUNCTION_RESULT
endif.
...
CALL FUNCTION 'CUOV_SET_FUNCTION_ARGUMENT'
EXPORTING
ARGUMENT = FUNCTION_RESULT
VTYPE = 'CHAR'
SYM_VAL = LV_FUNCTION_RESULT
* NUM_VAL =
TABLES
MATCH = MATCH
EXCEPTIONS
EXISTING_VALUE_REPLACED = 1
OTHERS = 2
The evaluation of the selection criteria can be done with some extension to the SAP function EVAL_FORMULA (this function module can beside numeric expressions like the above "Length * Width * Height" also process boolean formulas. Operations like FirstWord have to be implemented once in ABAP.
I am looking forward to your feedback, ratings, comments and especially your ideas to improve the show solution.