Developers need some basic tools to do their job properly and effectively, these are:
- a development environment with auto-complete
- a decent espresso-machine
- a debugger
Unfortunately, while the choice of espresso (, pour-over, or any other form of coffee you prefer) basically depends on your budget, taste and skills, debugging in Lumira Designer is pretty limited…
However, there are some poor-man’s-debugger options you can try:
Temporary component
You can set the text of component (e.g. a TEXT component) you add temporarily – this works both in local execution mode, as well as on the BI plattform.
Alert
If running your app locally (with the web server being hosted by Lumira Designer in eclipse), you can use APPLICATION.alert() to display a popup message if script excution hits this statement. The message dialog is displayed by Lumira Designer (eclipse), not by your browser, so you might have to look for it in the background, hiding behind your browser window. The script execution is halted, as long you do not confirm the popup.
In the message text you can pass the values of selected variables, but you need to convert them to a string: often is as simple as writing: APPLICATION.alert( integerVariable + “”) or – even better – APPLICATION.alert( “integerVariable=” + integerVariable )
Log
You can use APPLICATION.log() to have a log entry written in the error log of Lumira Designer. To see the error log, activate it from the ‘View’ menu. The drawback is that the log entries will be in a common list with dozens of other entries generated automatically by Lumira. It might help to use some prefix in the message text, and use the filtering option in the error log view to search for this text.
Developer-Info popup
Often it is useful to get an overview of the state of your global variables, the (query) variables and filters of all your data-providers and planning objects. You can easily do this with a few components and code-snippets. It requires less than quarter of an hour to create, and you can use it later anytime on-demand to analyze issues.
- Add a dialog component containing a text-area. (Don’t forget a button to close the dialog.)
- Add a KEYBOARDSHORTCUTS component and register some shortcut (e.g. Ctrl+Shift+I) to execute the script method below – you can display the ‘developer info’ popup when required using this shortcut.
- Create the script coding as detailed below.
- In the first block with ‘someVariable’ adapt the code for your most important global variables.
- In the line ‘datasources=…’ list your datasources.
- In the lines ‘seuqences=…’ and ‘sequenceNames=…’ list your planning sequences and their respective IDs as strings
When the script is executed, it will display global variables and the most important properties of your datasources and planning objects. The code could be adapted to also display filters if required. Often you can spot issues with a wrong variable value this way. A big benefit is: also exit variables used in queries are displayed – a great option to see immediately if your variable exit coding has delivered the correct result, without firing up the ABAP debugger.
var i = "";
i = i + "user: " + APPLICATION.getInfo().user + "\n";
i = i + "\n\n";
//Show selected internal variables
i = i + "someVariable = " + someVariable + "\n\n";
i = i + "someOtherVariable = " + someOtherVariable + "\n\n";
i = i + "\n\n";
i = i + "\n\n";
//Display datasources
var datasources = [DS_MAIN, DS_PROMO, DS_IND_ROLLUP, DS_UPLIFT, DS_TOTAL, DS_CHART_DET];
datasources.forEach(function(datasource, index) {
i = i + datasource.getName() + ":\n";
i = i + "isInitialized: " + datasource.isInitialized() + "\n";
i = i + "isInputReady: " + datasource.isInputReady() + "\n";
i = i + "system: " + datasource.getInfo().system + "\n";
i = i + "query: " + datasource.getInfo().queryTechnicalName + "\n";
var v1 = datasource.getVariables();
v1.forEach(function(variable , index) {
i = i + variable.name +": " + datasource.getVariableValueExt(variable.name) + "\n";
});
i = i + "\n\n";
});
i = i + "\n\n";
i = i + "\n\n";
//Display planning sequences
var sequences = [ PS_ADD_PRODUCTS, PS_DEL_PRODUCTS, PS_LOAD_UPLIFT, PS_SAVE_UPLIFT, PS_COPY_PLAN, PS_CALC_INDSPLIT, PS_APPLY_INDSPLIT ];
var sequenceNames = ["PS_ADD_PRODUCTS", "PS_DEL_PRODUCTS", "PS_LOAD_UPLIFT", "PS_SAVE_UPLIFT", "PS_COPY_PLAN", "PS_CALC_INDSPLIT", "PS_APPLY_INDSPLIT"];
sequences.forEach(function(sequence, index) {
i = i + sequenceNames[index] + ":\n";
var v2 = sequence.getVariables();
v2.forEach(function(variable, index) {
i = i + variable.name +": " + sequence.getVariableValueExt(variable.name) + "\n";
});
i = i + "\n\n";
});
TEXTAREA_DEVELOPER_INFO.setValue(i);
DIALOG_DEVELOPER_INFO.open();
Poor man’s trace
Taking the above idea one step further, you can implement your own custom tracing, which you can view – even when your application runs on the BI plattform – without any hassle:
- Create a global variable of type string (or string array), e.g. trace
- Implement the developer-info popup as described above, and make sure that this global variable is output
- In the code you would like to trace, simply append to you global variable
This way the traced ‘events’ – along with any additional information you pass – can be collected in the global variable, and the contents can be displayed conveniently on demand. It’s as easy as pressing Ctrl+Shift+I…