Start of Content Area

Function documentation Local Function Libraries  Locate the document in its SAP Library structure

Use

You can use your own user-defined functions in message mappings in addition to the standard functions. The PCK saves these functions in a local function library of the message mapping. They are only visible in this message mapping (in the data-flow editor for defining target-field mappings).

You can use user-defined functions to add your own simple or complex Java functions to the functions of the message mapping.

Features

The editor for a function library is structured as follows:

This graphic is explained in the accompanying text

General

Class and Package Name

Each function corresponds to a Java class, which is identified by a class name and a package name. Once a function has been created, the PCK assigns the name of the function to the class name automatically and uses the PCK namespace to create the package name automatically.

All package and class names of local functions and imported archives must be unique. If there is already a package with the same name in an imported archive and a class with the same name in this package, this results in a naming conflict. To resolve such conflicts, you must change the predefined class name and package name of your function.

Editing Source Text

The PCK has an integrated editor for creating Java source text of functions. You can also use an external tool to edit the source text of a function. To do this, you export the source text and reimport it once you have edited it using the external tool.

The exported source text contains markers for the beginning and end of the individual functions and areas. When the source text is imported at a later point in time, the PCK only imports the source text between these markers. The methods must already be contained in the function library into which you are importing the source text. New methods are not created automatically.

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 of the same message mapping.

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

More information: Import Statements

Activities

...

       1.      On the Functions tab page of the message mapping, create a function library.

       2.      Implement your Java functions.

Note the implementation considerations for Java mappings.

       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.

       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.

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.

The Java function is visible in the data-flow editor immediately.

 

End of Content Area