data:lv_value type string. call function 'EVAL_FORMULA' exporting formula = '90 <= 90' program = sy-repid importing value = lv_value exceptions division_by_zero = 1 exp_error = 2 formula_table_not_valid = 3 invalid_expression = 4 invalid_value = 5 log_error = 6 parameter_error = 7 sqrt_error = 8 units_not_valid = 9 missing_parameter = 10 others = 11. if sy-subrc <> 0. * Implement suitable error handling here endif.
FORM dynamicformula USING formula TYPE string CHANGING re TYPE i. DATA source TYPE string. DATA return_value TYPE string. DATA js_processor TYPE REF TO cl_java_script. js_processor = cl_java_script=>create( ). CONCATENATE 'result = ' formula ';' INTO source. return_value = js_processor->evaluate( source ). re = return_value. ENDFORM.
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/17957.html