Using program referenced variables in pricing routines
It shouldn’t be a difficult thing to agree that pricing is one of the most tricky items to handle, especially when it comes to debugging scenarios that break so randomly.
There was an issue where a custom pricing condition (that calculates the discount based on neighboring items in the order) wasn’t giving expected results. In certain cases it worked, but in some other cases it didn’t. Typical on any custom development right!
The calculation was very straightforward and had no chances of breaking. After much debugging it was seen that the RETTKOMV structure was overwriting the values. After ploughing through plenty of SD forms (eg. http://scn.sap.com/thread/236383) which mentioned about this “notorious-yet-popular” structure , I was still clueless on what the issue was.
For anyone who has debugged the pricing routines, you can imagine the patience that we develop as a part of this. The number of times the routines get called is pretty much close to being called insane, if you consider the good number of pricing conditions configured per line item.
But ABAPers have a way of resolving any issue. Its just a matter of time.
It suddenly struck me that to get the details of the line items, we were referencing a structure from SAPMV45A… and this one kept changing focus depending on the various updates to the line items. Bingo.
Moral of the story – the pricing condition values getting overwritten because of RETTKOMV is a pretty standard scenario. The framework ensures the dependencies are correctly handled and the prices not distorted because of the umpteen pricing conditions. Care should be taken to make use of the right structures (which again, is dependent on the scenario under consideration) to set the price values. And do not make use of specific item level structures from SAPMV45A as they may change amidst the loops! In the worst case scenario, use the whole table content from SAPMV45A (ensuring performance isn’t significantly impacted) and read the required content based on the item number on which the pricing is to be applied.
This was just a tip.. if at all anyone runs into a similar issue.