Posted: Fri Apr 11, 2008 10:07 pm Post subject: JavaScript test
Code:
REPORT Z_JAVASCRIPT_TEST .
data: l_JS_PROCESSOR type ref to CL_JAVA_SCRIPT,
l_RETURN_VALUE type STRING,
l_SOURCE type STRING.
* Creation of a new javaScript
l_JS_PROCESSOR = CL_JAVA_SCRIPT=>CREATE( ).
* this is the Javascript code
concatenate
'var l_source = "Hello World,"; '
'l_source += " I''m"; '
'l_source += " JavaScript!"; '
'l_source; '
into l_SOURCE separated by CL_ABAP_CHAR_UTILITIES=>CR_LF.
* we compile the JavaScript code
l_JS_PROCESSOR->COMPILE( SCRIPT_NAME = 'DANYTEST.JS' SCRIPT = L_SOURCE )
.
* Any syntax error ?
if l_JS_PROCESSOR->LAST_CONDITION_CODE <> 0.
write: / 'Error in COMPILE', l_JS_PROCESSOR->LAST_ERROR_MESSAGE.
exit.
else.
write / 'JavaScript was compiled'.
endif.
* Let's go and run the script
l_JS_PROCESSOR->EXECUTE( SCRIPT_NAME = 'DANYTEST.JS' ).
* Any problem during execution ?
if l_JS_PROCESSOR->LAST_CONDITION_CODE <> 0.
write: / 'Error in EXECUTE',l_JS_PROCESSOR->LAST_ERROR_MESSAGE.
exit.
else.
write / 'JavaScript was executed'.
endif.
* we read the output variable
l_RETURN_VALUE = l_JS_PROCESSOR->EVALUATE( JAVA_SCRIPT = 'l_source;' ).
write : / l_RETURN_VALUE.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.