on 05-13-2009 7:58 AM
Hi Frnds,
I want to read XI Message ID and assign to Particular field in my Payload.
How to achive this one Using Java Map
Regards,
Raja Sekhar
any specific need to use java mapping?...it can be easily done using an UDF in message maping...
java.util.Map map = container.getTransformationParameters();
String MSGID = (String)map.get(StreamTransformationConstants.MESSAGE_ID);
return MSGID;
no argument/parameter needed...just map the output to the desired field in target
Edited by: abhishek salvi on May 13, 2009 1:19 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vijay/Abhi,
When i am trying to execute i am getting below mapping error,i developed one message mapping
in that i writen as a UDF .
<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>
<SAP:P1>com/sap/xi/tf/_MM_ProductDefinition_to_Payload_</SAP:P1>
<SAP:P2>com.sap.aii.mappingtool.tf7.IllegalInstanceExcepti</SAP:P2>
<SAP:P3>on: Cannot create target element /ns0:MT_Payload/p</SAP:P3>
<SAP:P4>ayload. Values missing in queue context. Target X~</SAP:P4>
<SAP:AdditionalText />
<SAP:Stack>Runtime exception occurred during application mapping com/sap/xi/tf/_MM_ProductDefinition_to_Payload_; com.sap.aii.mappingtool.tf7.IllegalInstanceException: Cannot create target element /ns0:MT_Payload/payload. Values missing in queue context. Target X~</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
</SAP:Error>
UDF Code is below.
DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/JMS","DCJMSMessageProperty0");
java.util.Map map = container.getTransformationParameters();
String DCJMSMessageProperty0 = (String)map.get(StreamTransformationConstants.MESSAGE_ID);
conf.put(key, DCJMSMessageProperty0);
return DCJMSMessageProperty0;
Regards,
Raj
UDF Code is below.
DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/JMS","DCJMSMessageProperty0");
java.util.Map map = container.getTransformationParameters();
String DCJMSMessageProperty0 = (String)map.get(StreamTransformationConstants.MESSAGE_ID);
conf.put(key, DCJMSMessageProperty0);
return DCJMSMessageProperty0;
not a major change that you require...
Your requirement is to get the message ID for a particular JMS processing and map it to an element in the Message Header....message header is something different
So you dont need this statement return DCJMSMessageProperty0; instead you need:
return "";
Hi,
use the below (crude) method to get the Message Id into the DCJMSMessageProperty0 parameter:
You should have two UDFs like:
UDF1 to get MessageID: (It should be without any parameter or any argument)
java.util.Map map = container.getTransformationParameters();
String msgID = (String)map.get(StreamtransformationConstants.MESSAGE_ID);
return msgID;
UDF2 to put the mesage ID into the DCJMSMessageProperty0 parameter:
Case 1) If there is an unused field in the target structure...then UDF should have one parameter...say msgId and type as string
DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/JMS", "DCJMSMessageProperty0");
conf.put(key, msgId);
return "";
so in your mapping the sequence will be:
UDF1 ---> UDF2---> Some target node
Case 2) If all the fields are used then UDF should have two parameters...have parameter1 as msgId and parameter2 as var1...both of type string
DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/JMS", "DCJMSMessageProperty0");
conf.put(key, msgId);
return "var1";
so in your mapping the sequence will be:
UDF1 --->
-------> UDF2---> Some target node
SourceField----->
(to parameter2 of UDF2 )
I am extremely sorry that i am suggesting you a weird way of implemeneting this...but as of now this is the only thing that came to my mind.... this method will work..just it may have a drawback of not being optimal.....
@Sandeep....we can only get a message ID using the UDf you have given but the actual req is something else....you can refer the earlier posts
my requirement is I have to read XI message id and i have to set the value to Attribut i defined in
JMS Receiver communication Channel. JMS Receievr Communication Channel i already defined
attibutes using ASMA Properties.
Hi Below code working fine,thanks for your inputs.
once again Vijay/Abhi appreciated your inputs.
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key =DynamicConfigurationKey.create("http://sap.com/xi/XI/System/JMS","DCJMSMessageProperty0");
String DCJMS = (String)container.getTransformationParameters().get(StreamTransformationConstants.MESSAGE_ID);
conf.put(key, DCJMS);
return DCJMS;
Cheers,
Raj
Hi raja
follow this thread
/people/michal.krawczyk2/blog/2005/06/11/xi-how-to-retrieve-messageid-from-a-bpm
write this UDF named MESSAGE_ID
String constant;
java.util.Map map;
map = container.getTransformationParameters();
constant = (String) map.get(StreamTransformationConstants.MESSAGE_ID);
return constant;
MESSAGE_ID -
> field
thanks
sandeep
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
are u r testing it in message mapping?...If so pls try to do the same in the interface mapping as the message mapping has to be instantiated.
Regards,
Tauseef
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes abhishek, you r right...
thank you for elucidating on that...we just do that to make sure the rest of the mapping is nt the cause of the error...
u get the rest of the mappiing except the values for dynamic config...
I do not know how much it would help ..but we dont use the container variable in the dynamic configurationcode when using it in a java mapping...but as u r using it in UDF it is required i guess.
Regards,
Tauseef
ref this link - http://help.sap.com/saphelp_nw04/helpdata/en/b3/9a2aeb24dc4ab6b1855c99157529e4/content.htm
the sample code will help point to the right direction
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Thanks alot for your quick replay,I am planning to develop as a JAVA Map to read Message ID,
below code i written please look in to this let me know any chnages required,
after reading message id I have to assign MsgId to Payload in header section.
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import java.util.HashMap;
import com.sap.aii.mapping.api. AbstractTrace;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
public class MsgId implements StreamTransformation {
private Map param = null;
private AbstractTrace trace = null;
private static final Object MessageId = null;
/*The Integration Engine transfers parameters
to the mapping program with this method.
It evaluates these parameters at runtime in the method execute()*/
public void setParameter (Map param) {
this.param = param;
if (param == null) {
this.param = new HashMap();
}
}
/*
At runtime, the Integration Engine calls this method to execute a mapping
*/
public void execute(InputStream in, OutputStream out) {
try {
String headerField;
java.util.Map map;
// get runtime constant map
map = container.getTransformationParameters();
headerField = (String) map.get(MessageId);
}
catch (Exception e)
{}
}
}
Regards,
Raja Sekhar
Hi Vijay,
If i write as a UDF it will work fine instead of Java Map.please check code my once.
String headerField;
java.util.Map map;
String container;
// get runtime constant map
DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/JMS","FileName");
map = container.getTransformationParameters();
headerField = (String) map.get(MessageId);
Regards,
Raj
>
> Hi Vijay,
>
> If i write as a UDF it will work fine instead of Java Map.please check code my once.
>
>
> String headerField;
> java.util.Map map;
> String container;
> // get runtime constant map
> DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
>
> DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/JMS","FileName");
>
>
> map = container.getTransformationParameters();
>
> headerField = (String) map.get(MessageId);
>
>
> Regards,
> Raj
you will also have to include the statement
conf.put(key, headerField);
if the property has to be accessed in the target side
if you are planning to use UDF then you can have the code which i have given.....i am currently using it in one of my scenarios in production and we are not facing any problem.....other tha pasting the code in your udf and including the jar file you dont need to do any thing:)...no need to define any variable also....
Edited by: abhishek salvi on May 13, 2009 4:08 PM
String headerField;
java.util.Map map;
String container;
// get runtime constant map
DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/JMS","FileName");
map = container.getTransformationParameters();
headerField = (String) map.get(MessageId);
i doubt about the working of this code....it can be use to dynamically give filename in case of a JMS adapter....i dont know how you can use this code to get message id and then assign it to target field????
In my scenario only XSLT Mapping available, if i want to use as a UDF then i have to create
on emesaage mapping
No problem :)......JAVA (here read it as UDF logic) can be used in XSLT mapping also:
http://help.sap.com/saphelp_nw04/helpdata/en/55/7ef3003fc411d6b1f700508b5d5211/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/43/03fe1bdc7821ade10000000a1553f6/content.htm
whatever links you get are meant for your reference...contents from them need to be used based on the requirement.....like the one above...you may need to combine the logic from both links or just one....final decision is yours:)......
Hi abhishek salvi ,
Thanks for your inputs,
my requirement is I have to read XI message id and i have to set the value to Attribut i defined in JMS Receiver communication Channel.
JMS Receievr Communication Channel i already defined attibutes using ASMA Properties.
but i dint assign the value,bcz i have to assign value dynamically(XIMsgID)
My code will work fine??
if any chnages needed let me know
DCJMSMessageProperty0 name of the JMS Attribute.
below code i written
DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/JMS","DCJMSMessageProperty0");
map = container.getTransformationParameters(MessageId);
String DCJMSMessageProperty0 = (String) map.get(MessageId);
conf.put(key, DCJMSMessageProperty0);
Regards,
Raja Sekhar
>
> Hi abhishek salvi ,
>
> Thanks for your inputs,
> my requirement is I have to read XI message id and i have to set the value to Attribut i defined in JMS Receiver communication Channel.
> JMS Receievr Communication Channel i already defined attibutes using ASMA Properties.
>
> but i dint assign the value,bcz i have to assign value dynamically(XIMsgID)
>
>
> My code will work fine??
> if any chnages needed let me know
>
>
> DCJMSMessageProperty0 name of the JMS Attribute.
>
> below code i written
>
> DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
>
> DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/JMS","DCJMSMessageProperty0");
>
>
> map = container.getTransformationParameters(MessageId);
>
> String DCJMSMessageProperty0 = (String) map.get(MessageId);
>
> conf.put(key, DCJMSMessageProperty0);
>
> Regards,
> Raja Sekhar
the code should work fine
map = container.getTransformationParameters(MessageId);
you need one more line :
java.util.Map map;
map = container.getTransformationParameters(MessageId);
Please correct me if i am wrong.....
just found a thread which deals with assigning MessageId to JMScorrelationId.....only difference is that you are using DCJMSMessageProperty0.....this thread is only for your reference....
Regards,
Abhishek
Edited by: abhishek salvi on May 13, 2009 6:41 PM
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.