cancel
Showing results for 
Search instead for 
Did you mean: 

Export parameter in Message mapping UDF

Former Member
0 Kudos

Hi, I use PI7.1.

I defined an Export parameter in Message mapping "Signature" tab.

And as http://help.sap.com/saphelp_nwpi71/helpdata/en/43/c3e1fa6c31599ee10000000a1553f6/frameset.htm,

I wrote in my UDF as follows:

public String myudf(int var1) {

String str="test";

if(exists("MY_PARA") == true) {

getOutputParameters.setString("MY_PARA", str);

}

return str;

}

However when I ran the test, it said there is "syntax error".

I guess the reason is not found the method exitst() or getOutputParameters. Anybody can help? thanks

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

close this one, I have another one.

Former Member
0 Kudos

Maybe its a little late, but if I use this code in my UDF it seems to work fine. I get "yea!" when i test it.

I have an export parameter named "exportParam" in my MM signature. Havent tested it in a transformation step yet tho...

Hope it helps.


String status = "";

GlobalContainer gc = container.getGlobalContainer();
OutputParameters params= gc.getOutputParameters();


if(params.exists("exportParam") == true) {
	params.setString("exportParam", "Test");
	status = "yea!";
}
else {
	status = "nay!";
}
return status;

Former Member
0 Kudos

Please click on the following thread.

May help you.

Former Member
0 Kudos

Hi!

And you did care of that fact: The names of the export parameters that you set in the source text must be identical to the names of the message mapping export parameters on the Signature tab page (not case-sensitive) ?

What about the syntax error? What does it say?

Additionally please check for the following libraries in your import part:

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

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

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

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

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

Hope this helps!

Regards,

Volker

Former Member
0 Kudos

the errors are:

Function SetExportPara, Line 3:

cannot find symbol symbol : method exists(java.lang.String) location: class com.sap.xi.tf._TEST_ if(exists("EXPORT_PARA")) { ^

Function SetExportPara, Line 4:

cannot find symbol symbol : variable getOutputParameters location: class com.sap.xi.tf._TEST_ getOutputParameters.setString("EXPORT_PARA", str);

There are import lines in the UDF

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

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

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

import java.util.*;

public String SetExportPara(COntainer container) throws StreamTransformationException {

String str = "123";

if(exists("EXPORT_PARA")) {

getOutputParameters.setString("EXPORT_PARA", str);

}

return str;

}

Former Member
0 Kudos

Here is a valid sample for a Java Mapping program working with Parameterized Mappings - taken from help.sap.com::

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

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

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

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

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

public class Parametrization_Java

extends AbstractTransformation {

public void transform(

TransformationInput in,

TransformationOutput out)

throws StreamTransformationException {

try {

// Read Import Parameters

String paramS =

in.getInputParameters().getString(u201CPARAM_Su201D);

int paramI =

in.getInputParameters().getInt(u201CPARAM_Iu201D);

Channel paramC =

in.getInputParameters().getChannel(u201CPARAM_Cu201D);

// Use Parameters during Mapping

// ...

// Set Export Parameters

out.getOutputParameters()

.setString(u201CPARAM_ESu201D, [String-Wert]);

out.getOutputParameters()

.setInt(u201CPARAM_EIu201D, [Integer-Wert]);

out.getOutputParameters()

.setValue(u201CPARAM_ECu201D, [java.lang.Object]);

} catch (Exception e) {

// Exception Handling

}

}

}

Regards,

Volker

Former Member
0 Kudos

thank you. But this function has input parameter in, out, hence can call relative methods. My question is how to use export parameter in UDF in message mapping.

Former Member
0 Kudos

Hi,

Are you running this test in the mapping? Have you tried running the end-to-end scenario (your code will change for this)?

Are you able to get the export value transferred to Integration / Monitoring process?

Regards,

Neetesh