cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to fill subject

Former Member
0 Kudos

Hi Everybody,

I have to fill the subject of mail with the value in the input tag <id> , i have tried this code to set the subject but dont knwo how to extract the field to fill.

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

DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/Mail", "THeaderSUBJECT");

conf1.put(key1, "Test");

return "";

please suggest me some UDF to proceed further.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I think you have Receiver Mail Adapter and want to pass Subject value from one of your source field value..

following links will help you..

http://help.sap.com/saphelp_nw04/Helpdata/EN/6b/4493404f673028e10000000a1550b0/content.htm

Thanks,

Bhupesh

Former Member
0 Kudos

Hi Bhupesh,

I tried the code in the link provided but got error as "Cannot find symbol"

trace = (AbstractTrace) param.get(StreamTransformationConstants.MAPPING_TRACE);

The error points to trace and param..

Please tell me who to resolve this,

Thanks

Former Member
0 Kudos

Hi,

Did you miss out declaring the trace object?

You have to declare the trace before using it.

AbstractTrace trace = container.getTrace();

then

trace = (AbstractTrace) param.get(StreamTransformationConstants.MAPPING_TRACE);

In the receiver mail channel you even have to enter the Variable transport binding:

In the advance tab. tick use adapter specific message attributes and the Variable transprot binding.

then under Variable Header Name1 : enter: THeaderSUBJECT

Then it will work

Regards,

Aravind

Former Member
0 Kudos

Hello

Are you doing JAVA mapping or UDF ? Code is slightly different for UDF and JAVA mapping (param exists in JAVA mapping, not sure it does for UDF)

Rgds

Chris

Former Member
0 Kudos

Hi,

Im using UDF, still my problem is not solved.

thanks

Former Member
0 Kudos

Hi,

Try this in UDF:




public String setSubject(String var1, Container container) throws StreamTransformationException
{

/***  get the subject in the Var1   ***/

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

/***		set the Subject of the mail		***/
parmValue = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/Mail", "THeaderSUBJECT");
conf.put(parmValue, var1);


}

Then set the Variable Transport binding in the Advanced Tab of receiver Mail channel under Adapter specific Message Attributes:

Variable Header (Name1) : THeaderSUBJECT

Refer:

http://help.sap.com/saphelp_nw70/helpdata/en/6b/4493404f673028e10000000a1550b0/content.htm

Regards,

Aravind

Former Member
0 Kudos

Hi Aravind,

I tried the code you have provided but in the subject of the mail im getting as "Testmssgid".

Im mapping the input tag <ID> with the output tag <subject> with the UDF in between.

The input parameter to the UDF is ID

still Im getting subject in the mail as Testmssgid.

Please suggest me as what change I need to do.

Thanks

Former Member
0 Kudos

Hi,

Have you set the Variable Transport Binding Parameter in the Receiver Mail Channel?

Without setting this you wont get the subject value set in the UDF.

And check if you are setting the correct variable in the code:

conf.put(parmValue, var1); // var1 should be the value from the tag <ID>

Regards,

Aravind

Former Member
0 Kudos

Hi Aravind,

Im able to achive the subject but now my problem is I have to use the Id to fill the subject dynamically but im not mapping the output of the UDF to any target field , can you please tell me as how to achive this.

Thanks

Former Member
0 Kudos

Hi,

I don't think you can skip returning a string from a udf.

So the alternative for this is create a variable on the target structure in the Message Mapping. Then map the out put of the udf to this variable.

To create a variable:

In the Message mapping, in target structure. Right click on any of the node or field and click on "Add Variable". Give a variable name. Then Double click on this variable (not click and drag). Then map the out put of the udf to this variable.

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

The value of the variable does not actually reflect on the target payload. So this should solve your problem.

Regards,

Aravind

Answers (0)