CX Works

A single portal for curated, field-tested and SAP-verified expertise for your SAP C/4HANA suite. Whether it's a new implementation, adding new features, or getting additional value from an existing deployment, get it here, at CX Works.

Dev Console as a Key Assistant and Checker for Your Projects

The Dev Console is by far the strongest dev utility in SAP CPQ (Configure, Price, and Quote) Development Kit. Your obligation is to check the user actions and execution steps of your implementation against the console.

If you notice any issue with your SAP CPQ implementation, the console will be the best possible working buddy that can help to close the issue successfully and quickly. You will notice that it is faster and provides prompt analysis compared to any consultants or SAP CPQ engineering.

The goal of this article is to show you how problems from the previous article (about non-deterministic rules engine) could have been identified in time and more easily, and how the console could have resolved it. Additionally, all techniques depicted here can be applied in any other SAP CPQ module, not just the product configuration.

Many different facilities are built into the console and almost every execution sequence in the engine code is recorded and displayed for you. Even if you are unable to tackle an issue, you will have enough information to give to SAP support and engineering to do the final analysis.

The console can be used to give information about what exactly changed the value of a field, simply type in the field name in the search box and all related entries will pop up. The tool shows the whole call stack so you can navigate between different levels of execution flows and traverse different branches with just few clicks. The console also has multiple functionalities and trace levels that enable performance breakup and analysis.

Table of Contents


Observe Regular Entries in Console

When, in the previous article's example, the user had entered '23' and rules were running five times, the Dev Console would have been tracing entries in the background (if it had been opened). Here, after just typing 'execute' into the search box, entries are listed that would make it easy for you to identify multiple execution cycles of product rules:



When you identify this from the console output, you should investigate the sources of repetitions. You can inspect each individual record by clicking on the 'i' icon available for every trace row:



Here you can find data about the record that fully determines its execution time and place. By comparing this to the 'total duration' column on the original screen (that gives execution times for every step) and the total execution times from actions in the upper screen, you can get a good idea on how time consuming some actions are.



Notice the seconds/milliseconds difference in units between the two tables and that the times that are minimal for our miniature model with four rules. It is easy to picture the actual performance impact where four rules would make all (potentially hundreds) of the product rules loop five times.

Also, pay attention to the breadcrumbs row. If you click any of the table rows below, it will display the whole call-stack for that row, coupled with all details.


Engine Identifies Loops on its Own

If you type in 'loop' in the same search box, you will get records for every point that SAP CPQ determined that another iteration of rules should have been run. Additionally, you can then read the reasoning for the decisions, as seen below:



In this example, if you mouse over the third row, you will see that the 'Number Of Additional Empty Slots' value was changed from '15' to '5' and that this was the reason for running another cycle of rules. If the value had changed on multiple attributes, then all this information would have been listed there as well.

Note that here, we are focusing on the keyword 'loop' which is useful for product rules, but keep in mind the general use of the Dev Console. There is no need to memorize any keywords, simply inspect available trace lines and come to your own conclusions. The dead loops that we discussed in the previous article would also be recorded in the Dev Console, as seen below:



Engine Keeps Track of Actions with Lowest Performances

Let us now draw your attention to the starting screen with the Dev Console and the 'Slowest first' option that the console offers:



If you tick the checkbox, the console will automatically rearrange all the records by execution time, in descending order. This is a direct list of pain points for optimal functioning of your implementation. It is here where you can get the execution steps broken down, displayed, and quantified per every call-stack level.


Another Example to Illustrate How to Track Point Changes

In this next example, we will show you how to use the console to pinpoint the source and the cause of a single value change or an action in SAP CPQ. It will also integrate what was shown regarding the console from the previous sections. 

Let's say that the issue is that customers have reported that the 'Place Order' action resets all discounts to zero:



You know that the action just sends data to the web and you find it quite strange that it modifies discounts. Now, the troubleshooting process starts with reproducing the issue (just a click to 'Place Order') with having the Dev Console opened in the background:



The screen above is the state after the click.

Let's now select 'ExecuteAction' at the top table in the Dev Console (to target the quote action itself) and type 'discount' in the search box below. Pay attention to the line that states that the discount value was changed from '10' to '0':



Now, click on the line so that the call-stack breadcrumbs are loaded too:



The screen contains all the information needed to trace the issue successfully:

  • You can see the 'Annul Discounts' triggered the value assignment to zero (two lines above the line you clicked).
  • You can see the 'Annul Discount' (as part of the quote calculations) was triggered from the 'Refresh All Prices' action (as part of the call-stack breadcrumbs above). 
  • If you view the execution tree on the right side (to see all peer execution steps), you can see how this fits into the 'Place Order' action: 'Refresh All Prices' is set to run as a pre-action to 'Place Order'. At this moment, the project implementer should remember that the 'Refresh All Prices' was set to precede the 'Place Order' in the SAP CPQ workflow in order to pull the latest product prices before the order is placed.

From the 'Refresh All Prices' code (below), you can see why the 'Annul Discount' is invoked. That is, before a call of custom routines to calculate custom fields and totals, the standard quote calculate is invoked to perform standard calculations.



The quote calculate invokes all routines that are set up in the 'Cart Fields Administration' (the main admin page for calculations and pricing). If you navigate to the table cell that directs calculations for the quote status and user type you need, you will see the following:



From the screen above, you can see that the 'Annul Discounts', a custom Python calculation that sets discounts to zero for an item just added to a quote (or reconfigured), is set to run in that case only and not for all other editable groups (the last is quite expected otherwise discounts would be constantly annulled on end-user side).

The Quote.Calculate() (invoked from 'Refresh All Prices') is a Python procedure that does not run from the UI side. Therefore, no editable group is selected and the default group is used. In this case, this would be the 'Item Add/Update Calculations', even though no items are being added/updated. This is the reason for why the 'Annul Discounts' are triggered even when there is no requirement for it. The error here was unintentional and you are then expected to modify the setup to include this use case also (in this example, the best solution would probably be to use default discounts in SAP CPQ to set the starting zeros).


Conclusion

The Dev Console is a high-quality tool enabling you to inspect all details of your implementation and to quickly resolve current issues.

While the SAP CPQ installation is available to help you identify errors, remember that it's your responsibility to check the implementation before moving your project to the next phase. Something that looks like it works smoothly from the end-user's perspective might record dozens of errors in the backend console traces. That's why it's important to make sure each error is addressed.

This article focuses on the problem from the previous article and the issues that stem from it. However, you should also check the official help pages on Dev Console where you can read about individual controls of the console in more detail. 
To continue with articles in this series (that deals with how to make your SAP CPQ projects great) go here to learn how to boost and maximize your scripting performances.