Entering content frameComponent documentationUser-Defined Functions Locate the document in its SAP Library structure

Purpose

Functions enable you to use your own function modules for checking values and inferring characteristic values.

In a function, you refer to an ABAP function module. The function module is used to copy the characteristics and characteristic values as table contents. In the function module, you can access all the usual options for further processing.

Caution

When you call a user-defined function module, SAP Variant Configuration no longer has control of possible error situations: the person who writes the function module can use all ABAP language elements, but has sole responsibility for the code.

You may want to create function modules for the following, for example:

Example

You can use a function to concatenate values for characteristics to form a text string. The value for characteristic Door_ID can be defined as a string formed from a concatenation of the values for characteristics Door_Material, Door_Width, and Door_Height.

In a function module, you can define that the values for characteristics Door_Material, Door_Width, and Door_Height are concatenated to form the value of characteristic Door_ID. To do this, you define a function module with the following call:

‘concatenate Door_Material Door_Width Door_Height into Door_ID’

You then create the function, and define this function module in the function. You include characteristics Door_Material, Door_Width, Door_Height, and Door_ID in the function and define the value assignment alternatives. In this case, you must define Door_ID as a data field, because values for this characteristic are to be inferred.

Integration

You can use functions in selection conditions, preconditions, actions, procedures, and constraints.

Features

There are 2 steps to creating functions:

  1. You define a function module to process characteristics that are transferred across an interface.
  2. You create a function, entering the function module and the characteristics. If the function is for inferring values, define value assignment alternatives.
  3. The characteristics of the function can be the same as the characteristics of the class, if the characteristics are single value. If the characteristics of the class are multiple value, create single-value characteristics especially for the function.

  4. Enter the function in object dependencies. The characteristics of the function are compared with the characteristics of the variant class.

FUNCTION <function name>

(<characteristic of function> = <characteristic of class>,

<characteristic of function> = <characteristic of class>)

Call in a Precondition or Selection Condition

All the characteristics entered are interpreted as input parameters for the function module. The function module serves only to determine a yes/no result for these input parameters. If the condition is not fulfilled, the function module must signal this by using the predefined exception FAIL. It is not possible to infer values in this context.

Call in an Action or Procedure

In an action or procedure, you can use a function call to infer values. In the value assignment alternative, specify which characteristics are import parameters and which are export parameters of the function module. Output parameters (return values) must refer to single-value or multiple-value characteristics of the class. If one of the input parameters does not have a value assigned in configuration, the function is not called.

Function calls in actions and procedures read only the first value assignment alternative, as do table calls.

Function Call in Constraints

You can use a function call in the conditional part of a constraint (test for exception FAIL) and in the restrictions part (test and inference).

Restrictions

Leaving content frame