Skip to Content

it is related to cl_java_script exception handling

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.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Aug 30, 2018 at 11:53 AM

    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
    

    Add comment
    10|10000 characters needed characters exceeded