Function
Destroys a script compiled using the COMPILE method from the context. A destroyed script can no longer be executed. If the script has been executed at least once with the EXECUTE method, however, the global variables defined in the script are even retained in the context after the DESTROY method.
Importing Parameter
SCRIPT_NAME (Type STRING)
Name under which the compiled script is stored in the context.
Example
report DEMO_JAVA_SCRIPT_DESTROY.
data SOURCE type STRING.
data JS_PROCESSOR type ref to CL_JAVA_SCRIPT.
JS_PROCESSOR = CL_JAVA_SCRIPT=>CREATE( ).
data return_value type string.
SOURCE = 'var string; string = "Hello World!";'.
call method JS_PROCESSOR->COMPILE
exporting
SCRIPT_NAME = 'HELLO_WORLD.JS'
SCRIPT = SOURCE.
RETURN_VALUE = JS_PROCESSOR->EXECUTE( 'HELLO_WORLD.JS' ).
write / RETURN_VALUE.
call method JS_PROCESSOR->DESTROY
exporting SCRIPT_NAME = 'HELLO_WORLD.JS'.
RETURN_VALUE = JS_PROCESSOR->EXECUTE( 'HELLO_WORLD.JS' ).
if not JS_PROCESSOR->LAST_CONDITION_CODE =
CL_JAVA_SCRIPT=>CC_OK.
write / JS_PROCESSOR->LAST_ERROR_MESSAGE.
endif.
write / JS_PROCESSOR->LAST_ERROR_MESSAGE.
This sequence deletes the compiled script that is in the context under the name HELLO_WORLD.JS after the first call of EXECUTE. The second time EXECUTE is called, an error message is output.