cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to change CONVERSATION_ID in UDF?

Former Member
0 Kudos

Dear All,

I am facing a scenario, which wants to change the CONVERSATION_ID based on one field of the source Message in Message Mapping dynamically, is it possible to change the CONVERSATION_ID in the User Defined Function? If it is possible, could anyone help me to give me some sample code? Or is there any other way to handle this situation?

Thanks and Regards,

Nick

Accepted Solutions (0)

Answers (2)

Answers (2)

justin_santhanam
Active Contributor
0 Kudos

Nick ,

I never tried this, can you please try the below UDF and lemme know it.

Get the input field and map to the root node of target element.

Select the UDF as Context with one input value.

java.util.Map map;

map = container.getTransformationParameters();

String test = (String) map.put (StreamTransformationConstants.CONVERSATION_ID,<b>input</b>);

result.addValue("");

Best regards,

raj.

Former Member
0 Kudos

Raj,

Thank you very much for your suggestion, but it fails. I got an error with Error Category - MAPPING and Error Code - EXCEPTION_DURING_EXECUTE, detail error message in sxmb_moni:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<!-- Request Message Mapping -->

<SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30"xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">

<SAP:Category>Application</SAP:Category>

<SAP:Codearea="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>

<SAP:P1>com/sap/xi/tf/_MM_File_to_MQ_</SAP:P1>

<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>

<SAP:P3>RuntimeException in Message-Mapping transformatio~</SAP:P3>

<SAP:P4/>

<SAP:AdditionalText/><SAP:ApplicationFaultMessage namespace=""/>

<SAP:Stack>com.sap.aii.utilxi.misc.api.BaseRuntimeException thrown during application mapping com/sap/xi/tf/_MM_File_to_MQ_: RuntimeException in Message-Mapping transformatio~</SAP:Stack>

<SAP:Retry>M</SAP:Retry>

</SAP:Error>

Do you have any suggestion?

Thanks and Regards,

Nick

justin_santhanam
Active Contributor
0 Kudos

Nick,

Try the same with mapping editor and check for any syntax errors.

Best regards,

raj.

Message was edited by:

Raj

Former Member
0 Kudos

Nick,

There may be something wrong in your udf.

Just you create a Value UDF with no input variables. Then you import java.*; and put this code:

String constant;

java.util.Map map;

map = container.getTransformationParameters();

constant = (String) map.get(StreamTransformationConstants.CONVERSATION_ID);

return constant;

If you need some help on this function check this michals weblog:

/people/michal.krawczyk2/blog/2005/02/25/simple-java-code-in-graphical-mapping--xi

http://help.sap.com/saphelp_nw04/helpdata/en/6e/ff0bf75772457b863ef5d99bc92404/content.htm

---Satish

Former Member
0 Kudos

Nick,

<i>which wants to change the CONVERSATION_ID based on one field</i>

Here what is conversation_id? From what I understand is you have field in the target which has different values based upon the input. If this is so then you can achieve in graphical mapping using If then else along with exists function or by writing a UDF.

Can you please let us know some more details?

---Satish