cancel
Showing results for 
Search instead for 
Did you mean: 

Reusable Function in XI

Former Member
0 Kudos

How can i write a function(java) in the message mapping which can be reused across all the message mappings in the same namespace.

I found out that there is a option of importing a class in the mapping.Is there a special way to write these classes.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The UDFs you create with in a message mapping is specific only to that mapping. If you want to reuse the code, you need to create a jar file and import this jar as external definitions. Then it can be reused.

Regards,

Jai Shankar

Answers (9)

Answers (9)

Former Member
0 Kudos

Hi babesh,

I got the other classes/packages except for

import com.sap.aii.mappingtool.tf7.rt.*;

It is not there in that jar.

Regards,

Sudip

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Sorry for that cofusion.

This class is available in the jar , <b>aii_mt_rt.jar</b>

Regards,

Bhavesh

Shabarish_Nair
Active Contributor
0 Kudos

you will have to use aii_mt_rt.jar found in

usr\sap\<SID>\DVEBMGS00\j2ee\cluster\server0\apps\sap.com\com.sap.xi.services

Former Member
0 Kudos

Hi Babesh,

Any idea which jar contains the package.

com.sap.aii.mappingtool.tf7.rt.*

Regards,

Sudip.

bhavesh_kantilal
Active Contributor
0 Kudos

Sudip,

If only you read the previous reply.

There jar, <b>aii_map_api.jar</b> , the path of which I have shown in my previous reply contains the classes you need.

Please look into Michal's FAQ as well.

Regards,

Bhavesh

Former Member
0 Kudos

where do i get the required jars for doing a local build e.g

It must me somewhere in the XI installation , do you know the path.

import com.sap.aii.mapping.api.*;

import com.sap.aii.mapping.lookup.*;

import com.sap.aii.mappingtool.tf7.rt.*;

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Look at question 5 under Section Mappings of this blog.

/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions

<i>5. Where can I find aii_map_api.jar to create my Java mapping?

Go to your XI server folders and use this path:

j2ee\cluster\server0\apps\sap.com\com.sap.xi.services

Inside com.sap.xi.services folder you'll find the jar file.</i>

Regards,

Bhavesh

Former Member
0 Kudos

is it normal class or any special way to write the class like in case of modules

Shabarish_Nair
Active Contributor
0 Kudos

it is a normal class... dont confuse the same with a EJB !!!

Shabarish_Nair
Active Contributor
0 Kudos

Also check out this post Dmitry Yankovsky. he has an interesting idea up his sleeve.

<i>

Mapping class loader allows mapping program to access all classes of the boot class loader and only jar files in the same namespace where this mapping is located.

Therefore you need to implement your function in some static (or not static method) of some java file and pack this class to a jar file.

Then you have 2 options:

- put your jar to the boot class path of the J2EE server

- put this jar to every namespace where you going to use this function.

In the Message Mapping you'll need to create a wrapper for your function and that's a manual process for each mapping.

But you can use a workaround to prevent manual creation of similar functions in all mappings.

Just create a mapping template that contain all needed functions and then apply this template on each mapping you are working on. Even if your structure is different all functions from your mapping template will be added to the current mapping.

Best regards,

Dmitry Yankovsky </i>

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

if you are looking to use the User Defined Function across all SWCV's, then Create a sepaarte SWCV, and import the .jar file as an imported archive in this SWCV.

Now all other SWCV's you define should be dependent on this SWCV containing the Jar file and then you can access this class in any namespace.

I have not tried this option, but I think it should work too.

Regards,

Bhavesh

Former Member
0 Kudos

no i don't want to copy paste it and create new functions every time.I want that to be resused

Former Member
0 Kudos

Hi,

Then create the required class files and import it as a jar file in external definitions and you can use those classes.

Regards,

Sudheer.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

if you need to use if across namespaces in a software component, then wirte the code in a java class, and then import it under imported archives as a .jar file.

use it inside a UDF, by instantiating the class and triggering the method,.

The Class Files under Imported Archives can be accessed in all namespaces of an SWCV.

Regards,

Bhavesh

Shabarish_Nair
Active Contributor
0 Kudos

yes you can reuse them. Follow the tips as mentioned in this thread;

Former Member
0 Kudos

Hi,

If you write a user defined function that can be accessible only in that mapping.If you want to use that in any other mapping you have to copy the code and create a new function.

Regards,

Sudheer.