cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

User defined functions with examples

Former Member
0 Likes
6,484

Hi,

Being am a trainee i didnt understand much about the user-defined functions at my training period..

Will you plz tell about them with best examples as u developed in real time and their requirement in scenario..

I tried for them very much in SDN..that is not statisfactory

Regards

guna

View Entire Topic
Former Member
0 Likes

Hello Guna,

There are 2 types of UDF - Simple and Advanced.

Simple UDFs uses Value, wherein we can manipulate only one value (input is one String). Therefore a single string is expected as input and the output would also b a single string.

Advanced UDFs uses Context or Queue, where you manipulate many values (input is an array of Strings).

Refer this link:

http://help.sap.com/saphelp_nw04/helpdata/en/40/7b8e40496f6f1de10000000a1550b0/content.htm

User-Defined Functions

Use

If the standard functions for a target field mapping do not fulfill your requirements, or if the graphical representation becomes unclear due to the complexity of the mapping, you have the option of creating your own user-defined functions. You can create Java source text in this function. The function is included in the Java coding that is generated for the message mapping as a Java method.

Activities

1. To create a new user-defined function, choose Create New Function () in the data-flow editor at the bottom of the screen, on the left-hand side. Choose Simple Function or Advanced Function in the menu.

2. Specify the attributes of the new function in the subsequent window:

Label:

Text that appears in the function chooser and on the data-flow object to identify the new function.

Name:

Technical name of the function.

Argument Count:

The number of input values that should be transferred to the function.

Description:

Description of how the function is used.

3. In the subsequent window you can create Java source code:

a. You can import Java packages to your methods from the Imports input field, by specifying them separated by a comma or semi-colon:

You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since all message mappings require these packages and therefore import them. You should be able to access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the package under Import. In other words, you do not have to import it as an archive into the Integration Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the SAP Logging Service (see also: Runtime Environment (Java Mappings)).

Besides the standard packages, you can also specify Java packages that you have imported as archives and that are located in the same, or in an underlying software component version as the message mapping.

b. If you want to import input field queues before you call the function, in advanced functions select the Cache Entire Queue checkbox. If you do not, the current input field context will be imported.

Note that saving the entire queue in the cache in the case of large messages will require a lot of memory at runtime. In such cases it is therefore better to work with contexts.

c. Create your Java source text in the editor window or copy source text from another editor.

4. Choose OK to confirm.

5. User-defined functions are limited to the message mapping in which you created the function. To save the new function, save the message mapping.

6. To test the function, use the test environment.

The new function is now visible in the User-Defined function category. When you select this category, a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the function to the data-flow editor, choose the arrow next to the button and select from the list box displayed.

Will you plz tell about them with best examples as u developed in real time and their requirement in scenario?

Padded zeros which is removed need to be replaced by spaces

Thanks,

Satya