Start of Content Area

Process documentation Implementing Java Functions  Locate the document in its SAP Library structure

Purpose

Message mappings and mapping templates support a range of standard functions, which are provided in the data-flow editor. User-defined Java functions enable you to extend the scope of the functions provided to include functions tailored to your requirements. You save functions in function libraries:

      Local function libraries are part of message mappings and mapping templates. The functions of these libraries are only visible in the corresponding message mapping or message template.

      You create function libraries that are independent of message mappings or mapping templates as a separate object type in the ES Repository. You can use the functions of these function libraries in message mappings or mapping templates of the same or a superordinate (local) function library (the term “(local) function library” covers the local and the independent function library).

Note

You can also implement the methods with the defined names init() and cleanUp() in (local) function libraries. These methods are executed by the mapping runtime before or after the whole mapping program has been called.

Functions of Other Java Libraries

All user-defined functions in (local) function libraries can access the following objects of the mapping runtime:

Accessing Standard Objects in User-Defined Functions

Object

Use

Container

This object enables you to cache the values that you want to read again when you next call the same user-defined function.

GlobalContainer

This object enables you to cache the values that you want to read again when you next call any user-defined function that is in the same message mapping.

AbstractTrace

This object enables you to transfer information for the mapping trace during mapping to a container that can be viewed by users in the message monitoring.

You can also access functions in standard Java packages or imported archives (see also: Archives Used and Import List).

Prerequisites

You have created either a function library, a message mapping, or a mapping template in the ES Repository. The editor for message mappings and the editor for mapping templates have a Functions tab page, whose functions the ES Builder saves in a function library, which is visible locally in the message mapping or the mapping template. The interface of this tab page is the same as that of function libraries.

Process Flow

...

       1.      Enter a new function in the function overview and define its function properties on the Properties tab page (see also: Function Overview and Function Properties).

Note

Alternatively, in message mappings and mapping templates, you can choose Create New Function (This graphic is explained in the accompanying text) in the data-flow editor. You then define the function properties and the source text of the function in a dialog window. The function is automatically added to the local function library.

The description below of how to edit the function assumes that you are on the Functions tab page or in a function library.

       2.      Read the implementation considerations for Java mappings, which apply to Java functions in (local) function libraries as well.

       3.      Enter the source text for the function in the source text editor at the bottom of the function library on the right. Alternatively, you can also export the classes belonging to the function library and edit them using an external tool (see also: Function Libraries).

       4.      For functions with execution type All Values of Context or All Values of Queue, note the meaning of the values and the consistent structure of queues (see also: Advanced User-Defined Functions).

       5.      If you need global variables or global help methods for your Java function, enter these in the source text editor for the Java area Attributes and Methods.

       6.      Return a result value in your Java function. Java functions with execution type Single Values must return a result value; Java functions with execution type All Values of Contextor All Values of Queue must return an object of type ResultList.

Result

You have implemented a Java function in your function library.

If this is a local function library, the function is immediately visible in the data-flow editor of the message mapping or the data-flow editor of the mapping template in the function category you assigned to the Java function in the function properties.

      To use the Java function in other message mappings or mapping templates, you must transfer the functions of the local function library to an independent function library (see also: Copying Functions of a Local Function Library).

      If your function library is an independent function library, you can use the Java function in all message mappings or mapping templates of the same or a superordinate software component version (see also: Using Java Functions of Function Libraries).

 

 

 

 

End of Content Area