Function
Sets a breakpoint in a script of the current context. When the script is executed, it stops at the specified line and switches the script to debugging mode.
Importing Parameter
SCRIPT_NAME (Type STRING)
Name of the script in the current context.
LINE_NUMBER (Type I)
Line number, in which the breakpoint is set. If the line number is not available in the script or cannot be executed, the breakpoint is moved to the closest line.
Example
report DEMO_JAVA_SCRIPT_SET_BREAK.
data SOURCE type STRING.
data GET_VALUE type STRING.
data JS_PROCESSOR type ref to CL_JAVA_SCRIPT.
JS_PROCESSOR = CL_JAVA_SCRIPT=>CREATE( ).
concatenate
'var string = "Hello World,"; '
'string += " this"; '
'string += " is"; '
'string += " JavaScript!"; '
'string; '
into SOURCE separated by CL_ABAP_CHAR_UTILITIES=>CR_LF.
call method JS_PROCESSOR->COMPILE
exporting
SCRIPT_NAME = 'HELLO_WORLD.JS'
SCRIPT = SOURCE.
do 10 times.
call method JS_PROCESSOR->SET_BREAKPOINT
exporting
SCRIPT_NAME = 'HELLO_WORLD.JS'
LINE_NUMBER = SY-INDEX.
JS_PROCESSOR->EXECUTE(
exporting SCRIPT_NAME = 'HELLO_WORLD.JS' ).
if JS_PROCESSOR->LAST_CONDITION_CODE =
CL_JAVA_SCRIPT=>CC_BREAKPOINT.
GET_VALUE = JS_PROCESSOR->GET( NAME = 'string' ).
write: JS_PROCESSOR->BREAKPOINT_LINE_NUMBER,
JS_PROCESSOR->BREAKPOINT_SCRIPT_NAME,
GET_VALUE.
skip.
endif.
JS_PROCESSOR->CLEAR_SCRIPT_BREAKPOINTS(
exporting SCRIPT_NAME = 'HELLO_WORLD.JS' ).
enddo.
In a DO loop, breakpoints are set one after another in various lines with SET_BREAKPOINT in the compiled script HELLO_WORLD.JS and then deleted again with
CLEAR_SCRIPT_BREAKPOINTS. The script is executed in the process. The instance attribute LAST_CONDITION_CODE determines that a breakpoint has been reached and outputs the attributes BREAKPOINT_SCRIPT_NAME and BREAKPOINT_LINE_NUMBER as well as the current value of the variable string read with the GET method. All the breakpoints that are to be placed on line numbers that are greater than the total number of lines are set in the last executable line of the script.