on 10-29-2012 4:17 PM
Dear friends,
I have a question about Graphical mapping in PI. I have a XML structure within a XML structure...
A snap shot of my structure looks like this:
<Content>
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<SendToRequest>
<ORGANISATION_ID>XXXXX</ORGANISATION_ID>
<MESSAGE_ID>716378916347891624781</MESSAGE_ID>
</SendToRequest>]]>
</urn1:Content>
So because of CDATA there can be a XML structure within a XML structure and in I just have to pass the value in from Message_ID to the taget field Content...
It must be possible with an UDF.
Can you please help me with this and provide me the code for this solution?
Thank you,
John
Hi PI Consultant,
Please Try this UDF
public static String UDF(String s)
{
try
{
int i=s.indexOf("<MESSAGE_ID>"),j=s.indexOf("</MESSAGE_ID>");
s=s.substring(i+"<MESSAGE_ID>".length(),j);
}
catch(Exception e)
{
e.printStackTrace();
}
return s;
}
Ideally you need a java/XSLT mapping to get the message ID value. Please try this if this works else you need java/XSLT mapping.
Map like this
content-------->UDF------>target
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Anupam for your reply...
I will try your solution...
So the UDF looks like this:
Execution Type: Single Values
One Argument with the name: s
And the code looks like this:
public String CDATA(String s, Container container) throws StreamTransformationException{
public static String CDATA(String s);
{
try
{
int i=s.indexOf("<MESSAGE_ID>"),j=s.indexOf("</MESSAGE_ID>");
s=s.substring(i+"<MESSAGE_ID>".length(),j);
}
catch(Exception e)
{
e.printStackTrace();
}
return s;
}
It this correct?
Regards,
John
Hi PI Consultant,
Here it is once again. Use UDF of type "value"
public String CDATA(String s, Container container) {
try
{
int i=s.indexOf("<MESSAGE_ID>"),j=s.indexOf("</MESSAGE_ID>");
s=s.substring(i+"<MESSAGE_ID>".length(),j);
}
catch(Exception e)
{
e.printStackTrace();
}
return s;
}
the name of the UDF is CDATA. Thus the mapping becomes
Content ------>CDATA--------->Message ID
Regards
Anupam
Thank you very much Anupam,
This was exactly what I needed
Points are rewarded...
I will bother you more in the future
Regards,
John
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You could use a XSL mapping, as well.
With this example:
<?xml version="1.0" encoding="UTF-8"?>
<urn1:Content xmlns:urn1="http//:someweirdnamespace">
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<SendToRequest>
<ORGANISATION_ID>XXXXX</ORGANISATION_ID>
<MESSAGE_ID>716378916347891624781</MESSAGE_ID>
</SendToRequest>]]>
</urn1:Content>
If you use this XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Extract">
<xsl:copy-of select="@*"/>
</xsl:template>
</xsl:stylesheet>
You will have the follow output XML:
<?xml version="1.0" encoding="UTF-8"?>
<SendToRequest>
<ORGANISATION_ID>XXXXX</ORGANISATION_ID>
<MESSAGE_ID>716378916347891624781</MESSAGE_ID>
</SendToRequest>
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi John,
Use can use the below dynamic configuration UDF to get the message ID.
public String msgid(Container container){
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey keyHeader1 = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "Message_ID");
String msgid = conf.get(keyHeader1);
return msgid;
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
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.