cancel
Showing results for 
Search instead for 
Did you mean: 

"Java sections" + UDF -> How to call a UDF from Initialization Section?

Former Member
0 Kudos

Hi all,

I have a UDF that makes an RFC Lookup to get some parameters from ECC. Some of these parameters are used in many different fields. So, to not call the UDF with RFC Lookup to the same parameter many times, I create a global variable at "Java Sections" and would like to load this variable on the Initialization Section, like this

myVariable = myUDF("param");

But the "myUDF" is not found using by this way.

The "natural" workaround would be to make a mapping to the root node of target message setting the value to the Global Variable, but if some of you know how to call UDF's directly at the Initialization Section I think it could help in other more complex scenarios.

regards.

roberti

Accepted Solutions (1)

Accepted Solutions (1)

bhavesh_kantilal
Active Contributor
0 Kudos

You cannot call a UDF in the Java Section.

One simple and better workaround though -

1. Create a Java Class that does your RFC lookup . You would need to define method in this class that Performs the lookup and return the appropriate data to you.

2. Import this class in the imported archive.

3. In the java section call this class, by creating an object for this class and get the required output from the class.

Regards

Bhavesh

Answers (1)

Answers (1)

henrique_pinto
Active Contributor
0 Kudos

a simple solution is to have a boolean parameter set with false in your java section.

Then, in your UDF, do it like this:

if (param = false) { 
  //do lookup and update java section variables with proper value;
  param = true;
}

It will only lookup the 1st time the function is called.

Regards,

Henrique.

Former Member
0 Kudos

Hi Bavesh, Henrique,

Good tips, I really didn't thought about it before.

I thought the problem in calling a UDF would be only some import detail, but if it is really not possible, lets work around it

thank you guys!

regards.

roberti