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 local 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 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:

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

For more information: Container Object

      The GlobalContainer object enables you to cache the values that you want to read again when you next call any user-defined function of the same message mapping.

For more information: GlobalContainer Object

      You can also access the functions of standard Java packages or imported archives.

Prerequisites

You have created either a function library or a message mapping.

Process Flow

...

       1.      Enter a function in the function overview and define the function properties on the Properties tab page.

For more information: Function Overview and Function Properties

Alternatively, in message mappings and mapping templates, you can choose Create New Function 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.

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

For more information: Java Mapping

       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 export the classes belonging to the function library and edit them using an external tool.

For more information: Local 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.

For more information: 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 Context or All Values of Queue must return an object of type ResultList.

Result

You have implemented a Java function in your function library.

The function is immediately visible in the dataflow editor for the message mapping.

To use the Java function in other message mappings as well, you must copy the functions of the local function library.

For more information: Copying Functions of a Local Function Library

 

End of Content Area