Technical Articles
Select only the highest freight condition at Sales document
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
Scale value from | Scale value to | Freight fee |
1.0 GBP | 1000.00 GBP | 150 Eur |
1000.01GBP | maximum | Free, no charge |
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.


Conclusion:
- 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 : )