SAP Function Modules

EVAL_FORMULA SAP Function module - Analysis of a syntactically correct formula







EVAL_FORMULA is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions (Comments) specific to the object.

See here to view full function module documentation and code listing, simply by entering the name EVAL_FORMULA into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: CALC
Released Date: 25.03.1997
Processing type: Normal fucntion module
Normal function module settings


Pattern for FM EVAL_FORMULA - EVAL FORMULA





CALL FUNCTION 'EVAL_FORMULA' "Analysis of a syntactically correct formula
  EXPORTING
*   degrees = SPACE             "               Operators for angle function specified in GRAD
    formula =                   "               Formula to be calculated
*   program = SPACE             "               Program for value assignment to a variable
*   routine = SPACE             "               Routine for value assignment to a variable
*   unit_of_measure = SPACE     "               Unit of measurement for calculated value
*   no_existence_check = SPACE  "               'X' if existence of program/routine is not to be checked
  IMPORTING
    value =                     "               calculated value of the formula
  EXCEPTIONS
    DIVISION_BY_ZERO = 1        "               Division by zero
    EXP_ERROR = 2               "               Invalid argument for exponential function
    FORMULA_TABLE_NOT_VALID = 3  "              Invalid formula set
    INVALID_EXPRESSION = 4      "               Syntax errors
    INVALID_VALUE = 5           "               Invalid Value
    LOG_ERROR = 6               "               Invalid argument for logarithmic function
    PARAMETER_ERROR = 7         "               Invalid parameter
    SQRT_ERROR = 8              "               Invalid argument for root function
    UNITS_NOT_VALID = 9         "               Invalid unit of measure
    MISSING_PARAMETER = 10      "               Program or Routines Missing for Variables
    .  "  EVAL_FORMULA

ABAP code example for Function Module EVAL_FORMULA





The ABAP code below is a full code listing to execute function module EVAL_FORMULA including all data declarations. The code uses the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the original method of declaring data variables up front. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8).

DATA:
ld_value  TYPE STRING .

DATA(ld_degrees) = 'some text here'.
DATA(ld_formula) = 'some text here'.
DATA(ld_program) = 'some text here'.
DATA(ld_routine) = 'some text here'.
DATA(ld_unit_of_measure) = 'some text here'.
DATA(ld_no_existence_check) = 'some text here'. . CALL FUNCTION 'EVAL_FORMULA' EXPORTING * degrees = ld_degrees formula = ld_formula * program = ld_program * routine = ld_routine * unit_of_measure = ld_unit_of_measure * no_existence_check = ld_no_existence_check IMPORTING value = ld_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 . " EVAL_FORMULA
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 3. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 4. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 5. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 6. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 7. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 8. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 9. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 10. "Exception "Add code for exception here ENDIF.







ABAP code to compare 7.40 inline data declaration with original syntax

The below ABAP code uses the older none in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. It may also be useful if you are using an older version of SAP as some of the newer syntax above, such as the @DATA is not available until 4.70 EHP 8.

DATA:
ld_value  TYPE STRING ,
ld_degrees  TYPE STRING ,
ld_formula  TYPE STRING ,
ld_program  TYPE STRING ,
ld_routine  TYPE STRING ,
ld_unit_of_measure  TYPE STRING ,
ld_no_existence_check  TYPE STRING .

ld_degrees = 'some text here'.
ld_formula = 'some text here'.
ld_program = 'some text here'.
ld_routine = 'some text here'.
ld_unit_of_measure = 'some text here'.
ld_no_existence_check = 'some text here'.

SAP Documentation for FM EVAL_FORMULA


The function module EVAL_FORMULA evaluates Literal or Variable formulas. It accepts: ...See here for full SAP fm documentation

Contribute (Add Comments)

Please help keep this info upto date and use the comments section below to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name EVAL_FORMULA or its description.