Entering content frameFunction documentation EVALUATE Locate the document in its SAP Library structure

Function

Compiles a script, executes it, and releases it again. The global data of the script is then available in the context.

Importing Parameter:

JAVA_SCRIPT (Type STRING)

JavaScript source text in a string in which individual source text lines are separated from one another by the static constant CL_ABAP_CHAR_UTILITIES=>CR_LF.

Returning Parameter:

RESULT (Type STRING)

Value of the last statement executed in the script.

Example

Example

report DEMO_JAVA_SCRIPT_EVALUATE.

data SOURCE type STRING.
data RETURN_VALUE type STRING.

data JS_PROCESSOR type ref to CL_JAVA_SCRIPT.
JS_PROCESSOR = CL_JAVA_SCRIPT=>CREATE( ).

concatenate
  'var string = "Hello World";             '
  'function Set_String()                   '
  '  { string += ", this is JavaScript!";  '
  '  }                                    '
  'Set_String();                          '
  'string;                                '
   into SOURCE separated by CL_ABAP_CHAR_UTILITIES=>CR_LF.

RETURN_VALUE = JS_PROCESSOR->EVALUATE( SOURCE ).

After the functional call of the EVALUATE method, RETURN_VALUE contains the value 'Hello World, this is JavaScript!'.

 

 

Leaving content frame