cancel
Showing results for 
Search instead for 
Did you mean: 

Message-Mapping: Use same RFC lookup for different target fields

Former Member
0 Kudos

Hello,

I need to apply an RFC Lookup which delivers a boolean flag back (true or false). This RFC lookup should be used for different target fields.

Is there a way to execute the RFC lookup just once and then store the result in an internediate variable that I can use for all futher checks for different target fields?

If this is not possible and I have to apply the RFC lookup for all necessary target fields is it then executed for each target field ? This is exactly what I want to avoid in order not to slow down performance.

The input parameter (=source field value) would be the same.

Thank you for your advice!

Accepted Solutions (1)

Accepted Solutions (1)

former_member181962
Active Contributor
0 Kudos

Hi Florian,

This is very much possible.

Firstly use this RFC lookup in the first node mapping.

Then you can define Global variables using the EDIT JAVA SECTIONS part of the message mapping.

Then use getparameter and set parameter java functions to get the stored value and use it elsewhere in the mapping.

To store values in global variable

container.getGlobalContainer ().setParameter ("str", FIELDNAME);

To get the value already stored in global variable.

String myStr = (String) container.getGlobalContainer().getParameter ("str");

Regards,

Ravi Kanth Talagana

Former Member
0 Kudos

Exactly.

Here is a UDF example I have that you could adapt to your needs.

Set

public String setCounter(String a,String b,Container container){

/* Store values in global datacontainer
a: mapping value and return valueparameter
b: name for stored value parameter
 */

GlobalContainer myGlobalContainer;
myGlobalContainer = container.getGlobalContainer();
myGlobalContainer.setParameter(b.toUpperCase(), a);
return a;

}

Get

public String getCounter(String a,Container container){

   //write your code here
GlobalContainer gc = container.getGlobalContainer();
if (gc.getParameter(a) != null) {
  return String.valueOf(gc.getParameter(a));
} else {
 return "1";
}

}

Former Member
0 Kudos

Thanks a lot for the helpful answer.

However we use version 7.1 could it be that the EDIT JAVA SECTION is not available there anymore?

One more question concerning the usage of the proposed UDF. Would I use the first node as a "dummy" to call the RFC lookup and afterwards storing the value in the container (by using the set UDF) and in subsequent target field mappings I would use the the get UDF to retrieve the value?

Thank you again for your additional help

former_member181962
Active Contributor
0 Kudos

Hi,

YOu can probably use a concept called graphical variables in the PI 7.1.

An illustration about how to use the graphical variables is given here:

/people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-graphical-variable

Regards,

Ravi

Former Member
0 Kudos

Hi,

Use RFC lookp up in graphical mapping option available in PI 7.1. This should serve your purpose.

Regards,

Siddhesh S.Tawate

Former Member
0 Kudos

Thank you for your postings! I started working with global container variables, think that this should have solved the problem however then I switched to the graphical variables which made the problem very easy to handle.

Answers (1)

Answers (1)

former_member193376
Active Contributor
0 Kudos

Hi

You dont need to use any global variables.

I had a similar issue where i had an RFC lookup which was made through a JCO call and written in a UDF,and my RFC was returning more than 1 output for diffferent output nodes, but had to use the same RFC lookup

What i did was i input a constant along with the same common input node with and the the name being (For EG : output1)

and in the lookup code i checked for the input constant, if its equal to output1, i return the desired output, else i check for output2, if equal i send the output.

this way i am using only the code once,

hope this helps

thanks

SG