Friday, January 13, 2017

Debugging FOX: Part 2


In this second post on ways to debug FOX code in SAP BPC Embedded/BI-IP, I will focus on the debugging of the generated ABAP code.

Two methods exists:
1 - Debug the fox code itself as FOX script, covered here, and
2 - Debug the generated ABAP code, covered in this post.

Debug FOX Code ABAP

This method of debugging is very helpful if you know some ABAP, of course, as it shows you on source code level the statements that are being executed. Once you get to grips with the way the statements work, it becomes a lot easier and it is my preferred way of debugging.

To start off, go the transaction RSPLAN and select the FOX code you want to debug. In the code at the point you want the breakpoint, simply add the statement BREAK-POINT.

Execute the code with Trace Mode and you will step into the  ABAP Debugger. Some this to look out for in the debugging of FOX:

Key Figure Value assignment, for example:


Is generated in ABAP as:


GS_OPER-0FISCPER = '0000000'.

A further ABAP statement is generated that reads the reference data table to get the value:


Stepping into this statement and the assignment takes place here:

READ TABLE ith_data ASSIGNING <s_data> WITH TABLE KEY s_chas is_oper.
 IF sy-subrc 0.

is_oper contains the values of the block characteristics and the fields to be changed and is used a the key for the table read against the reference data. This is why, when the fields to be changed contains more than one characteristic value, a foreach loop is required, else the io_oper structure will be incomplete. This is further supported by the fact that a READ statement is executed, rather than a LOOP... WHERE

sy-subrc of course gives the indication whether a record has been found or not. 


The generated code for the FOREACH loop is generated as follows:
                   USING LT_CUR_FIELDS_00001 XT_REF_DATA
                   CHANGING L_CUR_00001_CNT.

It is quite convenient to view the data in the reference table and to get the record of the current iteration. From here, everything follows the same pattern of Key Figure Value assignment and then the table read.

Happy debugging and let me know what your thoughts are on this post.

I will also be making a video, and will update this entry as soon as it is done.

No comments:

Post a Comment