Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

it is related to cl_java_script exception handling

rishi_kulkarni123
Participant
0 Kudos

guys i have written a program to evaluate the string but while writing exception it is giving an error so i have tried an exception handling method i.e try and catch .

following is my code

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

DATA: value TYPE p DECIMALS 3 ,
str TYPE string.
DATA: ocx_root TYPE REF TO cx_root.


START-OF-SELECTION.
str = '( ( 1830 * 1000 ) / 31104 ) / 0 ' .
try.
value = cl_java_script=>create( )->evaluate( str ).
catch CX_SY_CONVERSION_NO_NUMBER into ERROR_REF.
ERR_TEXT = ERROR_REF->GET_TEXT( ).
write ERR_TEXT.
endtry.

4 REPLIES 4

raymond_giuseppi
Active Contributor
0 Kudos

Your syntax (implicit conversion expected?) triggered a non-handleable exception in the call of the class, you could use an intermediate string field to get a handleable exception.

numfield = cl_java_script=>create( )->evaluate( str ). " not handleable
numfield = stringfield = cl_java_script=>create( )->evaluate( str ). " handleable

0 Kudos

first of all thanks for precious reply brother

but this code is not working as i have use this code before u send me i was thinking i have written it wrong way.

will send me complete code so i can added it in my program .

0 Kudos

For compatibiliy (readibility) I would write

my_java = cl_java_script=>create( ). 
result_string = my_java->evaluate( input_string ). 
result_num = result_string.

0 Kudos

thank you 'ray' brother yesterday only done that report using this method thank you once again