Workflow. Using Functional Methods in Workflows
Workflow. Using Functional Methods in Workflows
What is a Functional Method?
To begin with, when we talk about workflows—especially about functional methods—we need to understand that this discussion refers to so-called utility classes.
See: ABAP Classes in Workflow
In classes designed for use in SAP workflows, it is possible to create functional methods that return only one parameter, although multiple input parameters can be passed into the method.
Using functional methods is justified when there’s a need to quickly retrieve some information. For example, to find an employee’s email address, their date of birth, or to determine the number of entries in a custom table, and so on. This efficiency is achieved by adding a task of a certain type into the workflow and calling the required class method. This will be discussed further below.
See: Expressions: Functional Methods
Use
You can use a functional method within an expression on the source side of a binding row. You can use a functional method for the following purposes:
-Performing calculations
-Performing data conversions, for example, currency conversions
-Calling a GET method to read a private attribute of the business object (BOR)
Example 1: Retrieving an Employee's Email Address
Let’s look at an example where an employee’s email is retrieved using a functional method in a workflow. The workflow creation is shown in a simplified form, only to demonstrate how the functional method works.
Creating a Utility Class
In transaction SE24, create a utility class to be used in your workflow.

Creating a Functional Method in the Class
Define a new method and its parameters. SAP recommends the following naming convention for functional methods: GET_<method_name>

Let’s assume the method has the following code:
DATA: lt_p0105 TYPE TABLE OF p0105,
ls_p0105 TYPE p0105.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
tclas = 'A'
pernr = im_pernr
infty = '0105'
TABLES
infty_tab = lt_p0105
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
IF sy-subrc is INITIAL.
LOOP AT lt_p0105 INTO ls_p0105 WHERE subty = '0010'.
ex_email = ls_p0105-usrid_long.
ENDLOOP.
ENDIF.
Using the Functional Method in a Workflow
In the following video segment, I will:
- Create a new workflow model (transaction SWDD)
- Add a step of type Container operation
- Create a new workflow container element named
EMAIL
- Call the functional method of the class and assign its result to the new container element
EMAIL
%utility_class.functional_method(parameters)%
Example 2: Calculating Task Deadline in a Workflow
Here’s another classic example of using functional methods in workflows: calculating a task’s due date. Note that the reference date for the deadline is July 18, 2018. Again, the workflow model is presented in a simplified form.
See: Workflow. Managing Deadlines for Workflow Tasks
Creating the Method to Calculate the Task Deadline
Create a new method and define its parameters.

The method’s source code:
CALL FUNCTION 'END_TIME_DETERMINE'
EXPORTING
duration = lv_in
unit = 'TAG'
factory_calendar = '99'
IMPORTING
end_date = lv_out
EXCEPTIONS
OTHERS = 7.
IF sy-subrc <> 0.
lv_out = sy-datum + lv_in.
ENDIF.
Using the Functional Method in a Workflow
Next, I will perform the following steps:
- Create a new workflow model (transaction SWDD)
- Add a new Activity background task
- Call the class’s functional method to calculate the task deadline. I’ll pass the value 3 as a parameter first, then 5
- Execute the workflow sequentially using different values to calculate the task deadline date