cancel
Showing results for 
Search instead for 
Did you mean: 

Java map question

Former Member
0 Kudos

Hello,

I'm trying to call a user defined function already defined in the function library in a package. How to do that? When I tried I'm getting an error saying the container should be initialized, the UDF has lot of functionality already built in, can anyone advise how this could be done?

The UDF has two string inputs and a container

Thank you.

Larry.

Accepted Solutions (0)

Answers (6)

Answers (6)

stefan_grube
Active Contributor
0 Kudos

Is the container used within the method in function library?

When the container is not used, you simply could call the method with "null" for container.

e.g. String result = new MyFunctionLib().myFunction("var1","var2", null);

Otherwise it is not possible, as you cannot create an instance for the Container interface easily.

Former Member
0 Kudos

Hi Aber,

Please use this:

@LibraryMethod(title="<UDF name>"  description="<description you like>" category="UDFPool" type="ExecutionMethod.SINGLE_VALUE")

After this use this:

Public string <UDF name> (

                                          @Argument(title="") String a,

                                          @Argument(title="") String b,

                                          Container container) throws StreamTransformationException{

<ur UDF code here>

         }

Note that strings a and b are the two string inputs.

Regards,

Souvik

Former Member
0 Kudos

Hi I'm trying to call this UDF from a Java mapping and not a graphical mapping..My questions is how can I call the UDF thats existing in the function library from the JAva mapping..I have trouble in initializing the container..

Larry

former_member183816
Active Participant
0 Kudos

I had same requirment to call UDF in java mapping. I couldn't find anything on time. So I applied another graphical mapping after my java mapping  (JM target structure to same structure) to fill required fields using those udf. Just an alternate solution if you couldn't find anything on this.

Refer above screen shot to import your Function library's function in your mapping.

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Aber,

I echo with Ambuj,

You can either import the required function library in to your required UDF or set dependency in your SWCV on the other SWCV which is having the function library.

Try this and let us know if you still have issues.

Regards

Vishnu

former_member183816
Active Participant
0 Kudos

In message mapping, import your function library like this,

If you are not able to see your functions here, then you have to add the SWCV as underlying swcv, where fl is defined, in current SWCV.

Former Member
0 Kudos

Hello,

Can any one help, is there a way we could do this?

Larry

former_member184720
Active Contributor
0 Kudos

Please go through below blog to use a UDF from function library

http://scn.sap.com/people/santhosh.kumarv/blog/2009/08/13/pi-71-function-library--part-i-creating-mi...

if everything looks good and unable to fix it, Share some screenshots on your error message and UDF