Beruflich Dokumente
Kultur Dokumente
1
DEBUGGING USING VMC DEBUGGER ..................................................................................................... 2
GENERAL STEPS ..................................................................................................................................... 2
STEPS TO CREATE OUR JAVA BREAKPOINT AND HIT IT IN THE VMC DEBUGGER ........................................................... 4
Setting ABAP breakpoints .................................................................................................................... 5
Setting Java breakpoint and exit the VMCJDB session ........................................................................ 5
Start debugging session and hit breakpoint ........................................................................................ 6
NAVIGATE THROUGH THE CODE AND CHECK VALUES OF VARIABLES ......................................................................... 8
SAMPLE DEBUGGING SESSION ............................................................................................................. 10
STEPS TO CREATE OUR JAVA BREAKPOINT AND HIT IT IN THE VMC DEBUGGER ......................................................... 10
Setting ABAP breakpoints .................................................................................................................. 10
Setting Java breakpoint and exit the VMCJDB session ...................................................................... 11
Start debugging session and hit breakpoint ...................................................................................... 15
NAVIGATE THROUGH THE CODE AND CHECK VALUES OF VARIABLES ....................................................................... 24
Checking content of an object (dump) ............................................................................................... 24
Example navigation inside a method and back ( step, stepup).......................................................... 27
Checking value of an expression (dump) ........................................................................................... 31
Execution stepping over calls (next)................................................................................................... 33
This document contains the steps to debug java coding using the Virtual Machine Container
Debugger. The steps can be used to debug the standard code as well as the customer code.
A chapter with general steps and another one with a sample session will be displayed with
almost the same subchapters in both, so that you can quickly check in the sample session the
details that you do not understand from the general steps chapter.
General steps
To start the VMC Debugger, use transaction VMCJDB. Commands can be used in the debugger
for several purposes , for example, set breakpoints, check values of variables or navigate
through the code. These commands can be executed either by writing them in the command
line or, whenever possible, by double-clicking on the list of commands or variables.
Example
If you are already debugging the code and want the debugger to go to the next line (similar to
F6 in ABAP) double-click on the command next, on the list of commands above
2
Or write the command next in the command line below
You can check all the available commands by double-clicking on command help
3
The general steps can be divided in the following way:
Steps to create our Java breakpoint and hit it in the VMC debugger
Navigate through the code and check values of variables in the VMC debugger
Steps to create our Java breakpoint and hit it in the VMC debugger
4
Setting ABAP breakpoints
The function modules that invoke the VMC normally start with SPC* (eg. SPC_CREATE_ITEMS) .
A session ABAP breakpoint or an external ABAP breakpoint must be set in a statement where
one of those function modules is called. The function module (VMC call) where the ABAP
breakpoint is set, does not need to be the same VMC call where the java breakpoint will be hit,
it can be the same one or another one that will be executed previously. This is because the
ABAP breakpoint is just used as a pre-step for the connection to the VMC debugger.
There are several options to set the breakpoint. We can choose any of them:
This is the most suitable way if you want to check first the java source code where you
want to set the breakpoint. Steps:
5
"dbsources" on the list of available commands that can be seen at the top of the
screen)
- All the list of Java source files located in the database can be seen
- Double-click on the source file where the breakpoint needs to be set
- Double-click on the line where we want to set the breakpoint.
To confirm that our breakpoint has been added, we can check the list of breakpoints if
we scroll down below the source code, where we see “Breakpoints”
We can remove a breakpoint by double-clicking on the breakpoint in that list.
After the breakpoint has been set, we exit our session in VMCJDB
It is assumed, that pricing functionality has to be debugged and PRC_RFC = X has been set, so
the ABAP debugger will stop in all the VMC calls to pricing ( one statement before). The steps
for debugging will be the following:
Start reproducing the problem in your application, e.g. creating a sales order
If the program stops before a pricing call ( statement break_rfc) but you are in a user
step where you do not expect the java coding you want to debug to be executed yet,
execute F8 in the ABAP Debugger, so the VMC Debugger is not connected yet.
When you are in the user step where you expect that the java coding will be executed,
and the first ABAP breakpoint ( statement break_rfc) is hit , press F6
6
In the statement that calls the VMC , “CALL FUNCTION SPC..” press F5 ( step into)
A pop-up appears with information about the port:
Java debugging back end on <host> is waiting for port <portnumber>
Don´t press OK yet.
A call stack should be displayed in VMC Debugger, which is a confirmation that the
debugger is attached to that port
Click OK in the pop-up.
The control goes to the VMC debugger. Command cont can be executed to continue
( it works as F8 in ABAP debugger) or execute other commands
The program can now jump from ABAP debugger to VMC debugger and vice versa.
If the control goes back to ABAP and you are not interested in ABAP debugging, hit F8
several times in the ABAP session until the java breakpoint is hit.
The breakpoint is finally hit.
The arrow indicates the current statement in the program flow
Instructions in VMC debugger can now be used to see values of variables,etc.
7
Navigate through the code and check values of variables
Navigation
The commands that are used to navigate in the debugger are the following:
It is also possible to check the value of an expression whose result is a primitive data type of
string using
print <expression>
8
The command used to check the value of an object reference variable is.
dump <object_reference>
Alternatively, double-click on the object reference, if it is visible on the screen.
It is also possible to check the value of an expression whose result is an object with the
command
dump <expression>
9
Sample debugging session
In the sample debugging session we will go inside the java coding of a standard value formula.
Steps to create our Java breakpoint and hit it in the VMC debugger
Transaction SU3
As the issue will be reproduced in CRM Web UI, a breakpoint is also set in one of the active
implementations of BADI CRM_COND_COM_BADI
10
Setting Java breakpoint and exit the VMCJDB session
Command dbsources will be used to display the java code and set the breakpoint. Double-click
in dbsources on the first screen
11
Search for the file that contains the class
com.sap.spe.pricing.transactiondata.userexit.value.NetValue
The file names have slash character “/” as separator, so search for string
com/sap/spe/pricing/transactiondata/userexit/value/NetValue
12
After clicking on the file name in the pop-up, the cursor will be placed on the file name on the
list of files. Double-click
13
The breakpoint has been added in that line. The list of breakpoints can be checked by scrolling
down below the source code, where “Breakpoints” can be seen.
14
Start debugging session and hit breakpoint
In this case, an order is initially opened, which already contains pricing and goes to the item
detail. In that user step the coding of our formula will not be executed, so there will be no
attempt to jump into the VMC calls.
Afterwards, when going to change mode in the order, there will be a jump into the VMC calls.
15
The commands that are displayed may also depend on whether the order has been opened
before or not.
Jump several times with F8 (The java breakpoint does not have to be hit yet)
16
The value formula number 2 is triggered , and it returns a value of 20 EUR
Go back to the item level and click on the pencil to go to change mode
17
The statements break_rfc before the VMC calls for pricing will be hit again.
There is a VMC call to remove the old pricing session. Click F8 to continue
18
Now we have the statement of the VMC call. Click F5
19
A pop-up appears with information about the port where the VMC Debugger must be attached
to be able to debug the pricing session (port 8002)
Don´t press OK yet.
Start VMCJDB
A call stack in VMC Debugger can be seen, which is a confirmation that the debugger is already
attached to port 8002
20
Click OK in the pop-up
21
The program can now jump from ABAP debugger to VMC debugger and vice versa.
As the Java breakpoint is not hit in the execution of the command SPC_CREATE_DOCUMENT
that has been used to connect the VMC debugger, when clicking on cont in the VMC Debugger,
the control will go back to the ABAP Debugger
In the ABAP Debugger an indication can be seen that the breakpoints have been reloaded
successfully
Click F8
22
Click F8 several times in ABAP , until the java breakpoint is found
23
Navigate through the code and check values of variables
24
PricingItem contains many other objects inside, rather than strings or primitive type variables,
Click on these objects to access the business relevant information.
For example click on _pricingDocument , and the following screen is displayed
Here you can see for example variable
_performCalcTrace true Indicates that the calculation trace will be executed
25
In the same screen where the content of object pricingItem is displayed, the Java coding can
still be seen by scrolling down.
26
Example navigation inside a method and back ( step, stepup)
So the debugger goes inside method getNetValueAsBigDecimal for the object pricingItem
( implemented in class PricingItem )
Double click on step again
27
The object that will be returned is given, which is m_netValue
Double click on m_netValue
28
See the values of intCompact and scale
intCompact 20000000000
scale 9
Means the value is 20
(the value that is shown in the calculation trace as result of the formula)
Click stepup
29
Click on stepup again
30
Returning to the formula method
dump pricingItem.getNetValueAsBigDecimal()
31
32
The same object that was displayed before, by stepping into the method execution, is
displayed now.
Being already in the last statement of the value formula, it will go out from the formula to its
calling method
33
It goes to the calling method
Click on Cont
34
35