Execute jQuery file from ABAP using CL_JAVA_SCRIPT
<p>I want to use CL_JAVA_SCRIPT in abap to execute a javascript file : jQuery.js which i get from url.
And this is my code :</p>

<pre><code>REPORT ZCLIENT.  
DATA: LV_CLIENT TYPE REF TO IF_HTTP_CLIENT.  
DATA:lv_URL TYPE STRING .  
lv_URL  = 'https://resources/jquery.js'.  
* Create client  
   CALL METHOD CL_HTTP_CLIENT=&gt;CREATE_BY_URL  
     EXPORTING  
       URL                = lv_URL  
     IMPORTING  
       CLIENT             = LV_CLIENT  
     EXCEPTIONS  
       ARGUMENT_NOT_FOUND = 1  
       PLUGIN_NOT_ACTIVE  = 2  
       INTERNAL_ERROR     = 3  
       OTHERS             = 4.  
   IF SY-SUBRC NE 0.  
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO  
       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.  
   ENDIF.  
*   LV_CLIENT-&gt;REQUEST-&gt;SET_CONTENT_TYPE(  
*       EXPORTING  
*         CONTENT_TYPE = 'application/javascript; charset=UTF-8'  
*         ).  
   CALL METHOD LV_CLIENT-&gt;REQUEST-&gt;SET_FORMFIELD_ENCODING  
     EXPORTING  
       FORMFIELD_ENCODING = LV_CLIENT-&gt;REQUEST-&gt;CO_ENCODING_URL.  
* Get request:  
   CALL METHOD LV_CLIENT-&gt;SEND  
     EXCEPTIONS  
       HTTP_COMMUNICATION_FAILURE = 1  
       HTTP_INVALID_STATE         = 2  
       HTTP_PROCESSING_FAILED     = 3  
       OTHERS                     = 4.  
   IF SY-SUBRC NE 0.  
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO  
       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.  
   ENDIF.  
* Prepare client-receive:  
   CALL METHOD LV_CLIENT-&gt;RECEIVE  
     EXCEPTIONS  
       HTTP_COMMUNICATION_FAILURE = 1  
       HTTP_INVALID_STATE         = 2  
       HTTP_PROCESSING_FAILED     = 3  
       OTHERS                     = 4.  
* Get HTML:  
DATA EV_DATA TYPE STRING.  
CONSTANTS co_line_size TYPE i VALUE 150.  
TYPES: t_line TYPE c LENGTH co_line_size.  
DATA: l_string TYPE string,  
      lt_lines TYPE TABLE OF t_line.  
FIELD-SYMBOLS: &lt;l_line&gt; TYPE t_line.  
   EV_DATA = LV_CLIENT-&gt;RESPONSE-&gt;GET_CDATA( ).  
"   compile js  
data GET_VALUE type STRING.  
data JS_PROCESSOR type ref to CL_JAVA_SCRIPT.  
data SOURCE type STRING.  
concatenate  EV_DATA SOURCE into SOURCE SEPARATED BY cl_abap_char_utilities=&gt;cr_lf.  
JS_PROCESSOR = CL_JAVA_SCRIPT=&gt;CREATE( ).  
JS_PROCESSOR-&gt;COMPILE( SCRIPT_NAME = 'TEST_GET.JS'  
  SCRIPT =  EV_DATA ).  
if JS_PROCESSOR-&gt;LAST_CONDITION_CODE &lt;&gt; 0.  
write: / 'Error in COMPILE',  
  JS_PROCESSOR-&gt;LAST_ERROR_MESSAGE.  
else.  
write / 'JavaScript was compiled'.  
endif.  
skip.  
JS_PROCESSOR-&gt;EXECUTE(  
exporting SCRIPT_NAME = 'TEST_GET.JS' ).  
if JS_PROCESSOR-&gt;LAST_CONDITION_CODE &lt;&gt; 0.  
write: / 'Error in EXECUTE',  
  JS_PROCESSOR-&gt;LAST_ERROR_MESSAGE.  
else.  
write / 'JavaScript was executed'.  
endif.  
skip.  
</code></pre>

<p>my file is well compiled but When executing my code i'm getting some errors like "window is not defined" .</p>

<p>How should resolve the problem</p>