cancel
Showing results for 
Search instead for 
Did you mean: 

RFC Look Up Global Variable

Former Member
0 Kudos

Hi,

I have done a RFC look up to fetch values from ECC . I am successfully getting the values in the RFC response. I want to know how I can store or hold these values in SAP Pi using global variable. Can anyone please help with the UDF logic for the same. Below is the sample UDF I have written but I am not sure how I can use the same after the RFC output to hold the values.Any inputs would be appreciated.

I am currently getting the data in XML in the ITEM field. Please help on how to store the values in global variable.

DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey keySource = DynamicConfigurationKey.create("http:\\www.test.com\\RFClookup","ITEM");

if (conf != null) {

conf.put(keySource, var1);

}

return var1;

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

suman_saha
Contributor
0 Kudos

Hi,

If you want to use the variable in the same mapping you can do this graphically also.

Hope it may help in different approach.

In Java Code you may check

Suman

iaki_vila
Active Contributor
0 Kudos

Hi Vinoth,

Have you checked this document ?

Regards.

engswee
Active Contributor
0 Kudos

Hi Vinoth,

Welcome to SCN!

Can you elaborate on what you want to do with the values after storing them?

If you want to use them within the same message mapping, then you don't need to use Dynamic Configuration in your UDF. Once approach is by storing them as key-value pairs in the GlobalContainer object, the values stored in GlobalContainter can be retrieve back in any other UDFs of the same message mapping.

Alternatively, you can also just declare attributes directly in the message mapping in the "Functions" tab under "Attributes and Methods" section. You can add Java declarations like below there:-


private String[] items;

After your RFC Lookup call, you can store them into the attribute via UDF, example below with rfcOutput declared as a parameter for a UDF of Queue type.


items = rfcOutput;

When you want to access the values, you can just use another UDF and look through the values


for (int i = 0; i < items.length; i++) {

// do something here

}

Rgds

Eng Swee

Former Member
0 Kudos

Hi Eng Swee,


Thanks for the response. Currently I want it to store so that it can be used in other mappings.

I have three values in output which now as per your suggestion I have added under attributes.

private String[] items;

priivate String[] companycode;

private String[] location;


Can you please tell me how i can store them via UDF. Some sample code so that i can modify it accordingly.

engswee
Active Contributor
0 Kudos

Hi Vinoth

If you want to store them for subsequent mapping steps, you need to follow Inaki's suggestion below. The approach I mentioned above is only for storing/retrieving withing the same message mapping execution.

Do note that even with Inaki's suggestions, the values are only available during runtime processing of a message. Once processing has completed, the values are no longer available, as they are not persistent.

Rgds

Eng Swee

Former Member
0 Kudos

Hi Eng Swee,

I rechecked the requirement. I will need this in the same mapping and not in other mappings.
Can you please tell me what is to be done after this declaration. As to how I can get this data in a global variable in the same mapping.

engswee
Active Contributor
0 Kudos

Hi Vinoth

If your RFCLookup has 3 output values, then create a queue-type UDF with 3 input parameters of type String.

Let say the name of your 3 input parameters are input1, input2, input3, then the UDF is very simple:-


items = input1;

companycode = input2;

location = input3;

In your message mapping, map the 3 output of the RFCLookup into the 3 input of the UDF.

Rgds

Eng Swee

Former Member
0 Kudos

Hi Eng Swee,


Thanks for the response. One more clairification how to put this value in a single variable after declaration. I tried using result.addValue("") and also return(""); . Both are not giving me results.

Former Member
0 Kudos

Hi,


Any update on this..

engswee
Active Contributor
0 Kudos

Hi Vinoth

One more clairification how to put this value in a single variable after declaration.

What variable are you refering to - a variable declared in the Java section Attributes & Methods, or a graphical variable?

How do you intend to use this variable?

What is your actual goal anyway - after fetching the values from ECC via RFCLookup, what is the end use for the values? Why do you want to store them in global variables, and how will the global variables be finally used?

Rgds

Eng Swee

Former Member
0 Kudos

Hi Eng Swee,

I am referring to the variable declaration under Java.

a=item;

b=ZSOURCE;

c=ZTARGET;

This is what I have done in UDF. After declaring this values under Attributes.

Now I am passing this to the output of RFC.

RFC Look UP - > UDF - > Target Field. I am not getting any values here after passing this UDF. So wanted to know if I need to add anything more in UDF.

engswee
Active Contributor
0 Kudos

If the output of the RFCLookup goes to the target field, why do you even need global variable?

It should be like this:

RFCLookup --> Target Field

Really not sure what you are trying to achieve.