This is the first posting of the WPS (Wednesday Performance Snippet) series. This series addresses hints and best practices on how to develop efficient, specifically in the context of TM.
This time it´s about how to read data efficiently.
Often you need context information when processing data. Let’s say you need first stop information when working with items.
We unfortunately see coding like this quite often in customer enhancements:
This coding snipped has several issues.
The most important one: The data is read within the loop, so in every single loop BOBF is called and data is read from DB or buffer. This is not a good idea at all. It will increase the runtime a lot, and in many cases you will only find out after go live when realistic data volumes are processed.
You have to collect the keys and read the data in advance in one mass call, e.g. like this:
Of course you also have to distinguish if you really need this information for all items or only for some, e.g. only for the main cargo items, only the vehicle items etc.
This is specifically relevant for determinations. Determinations are always called, if the prerequisite (e.g. modify to the item node) is fullfilled, and this is then true for ALL item categories. But this will be the focus of another WPS 😎
Now your challenge: Find other performance issues in the first code snippet, there are at least two … 😕