SAP ABAP 执行计算公式

report ztest6 .

data jj  type  i .
perform dynamicformula   using  ' 900 + 7  % 3 ' jj .
write / jj .
perform dynamicformula   using  ' 900 + ( 7 + 10 )  % 3 ' jj .
write / jj .
perform dynamicformula   using  ' 900 * 30 + ( 7 + 10 )  % 3 ' jj .
write / jj .
*&---------------------------------------------------------------------*
*&      Form  Dynamicformula
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->SOURCE     text
*      -->RE         text
*----------------------------------------------------------------------*
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 .                     "Dynamicformula

你可能感兴趣的:(SAP)