SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

JavaScript test



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Connect to External system, Unix и Perl
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Fri Apr 11, 2008 10:07 pm    Post subject: JavaScript test Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Connect to External system, Unix и Perl All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.