The Business scenairo：
- Customized Delivery freight condition ZDEL which has scale basis and group condition checked, it will be calculated per items according to condition records;
- If multiply items exist freight condition ZDEL, only the highest should be active at the header level; all the other lower value freight fees should be ignored.
- Currently achieved by manually deleted per Item after compared at Header level. Now the requirement is to show all items ZDEL value at header level and only the highest one is activated.
Thought 1. Deactivate all ZDEL except the highest one
The header condition has to be reflected on to the item level as pricing data is stored in tables at the item level(even for header condition type). So by making all items’ ZDEL as inactive status except the highest ZDEL at the Item level, then only the highest ZDEL will active at the header level.
Looks quite straight forward by set XKOMV-KINAK as blank for not the highest ZDEL item after comparing all item’s ZDEL amount with help of user exit like userexit_xkomv_bewerten_init at the program RV61AFZB. It’s working fine for normal order creation, but it’ll fail if any changes happen, as the inactive ZDEL at item level will not re-join the calculation process after it’s been set as inactive especially for group conditions.
Take below scale setting as an example:
If two items belong to the same condition group and the system can’t calculate per item directly and have to calculate the total quantity at the header level, then split the total freight fee into items level. If item 2’s quantity been changed and item 2’s ZDEL will been always inactive as haven’t waited for total quantity been sum, the result of ZDEL amount per item been compared too earlier which lead to the wrong item been selected as the highest ZDEL.
Even try to trigger new pricing by user exit userexit_new_pricing_vbkd at program MV45AFZB will not work after item changes. Cause loop XKOMV at userexit_xkomv_bewerten_init is triggered by earlier than group conditions calculation, it’s impossible to get which item contains the highest ZDEL at that time. The key debug point is to find where all ZDEL been calculated correctly at the function module: PRICING_COMPLETE. You can check this article for more details about this FM.
Thought 2. Using freight condition as statistics
There’re so many customer user exits existed for pricing process, I try many of them and didn’t find the right place to catch the “final” highest ZDEL. Even if it’s achievable by some enhancement or with the help of access key to modify the pricing calculation function, the above method still has a major issue as only the highest ZDEL item been collected into the header item. This means other items are free of charge, the header ZDEL amount from a specific item is not split into all items which leaves a huge potential problem for delivery processing.
From the above experience, we know that ZDEL must keep active status all the time during the calculation, otherwise, it’ll impact the calculation of header level ZDEL for special cases like group condition or exclusion been involved. So the new idea is:
- Create another new condition ZDLX (which kind of mirror of condition ZDEL without condition records ) at the header level only (no item condition).
- Make its value always equal to the highest ZDEL at the item level at the loop of XKMOV inside RV61AFZB(no value for other lower ZDEL items), and keep all ZDEL as XKOMV-KINAK=’L’ and statistical XKOMV-KSTAT = ‘X’.
- At the setting of price procedure, make freight subtotal include ZDLX but exclude the ZDEL.
ZDEL must keep active status but should not show at the header level, otherwise will be very confused for the user as so many freight conditions been listed at the header level. It can be done by set XKOMV-KINAK=’L’. For other values like ‘X’, it’s the inactive status(will display as Red traffic Icon)then it’ll impact the calculation of final ZDEL.
Plus set XKOMV-KSTAT = ‘X’ will help to set ZDEL which displays with statistic icon at the Item level.
- Keep ZDEL always active status, let it joins the whole condition calculation cover all scenarios which provide the correct highest ZDEL item for new condition ZDLX as a reference and it’s been hidden at header level to avoid confusion.
- And another advantage is: new ZDLX is at header level only which will be split into item levels for the freight fee guarantee the following delivery processing no issue if involved partial shipment scenario.
- The disadvantage of this approach is to make the pricing procedure difficult to cover normal scenarios for example only a few sales organizations want this highest ZDEL logic. Then a new pricing procedure needs to be created accordingly~ And all output forms which using the value of ZDEL have to be adjusted as well, extra work required.
If anything incorrect or you have a better approach, please kindly let me know. Many thanks : )