cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple lines in XML tag

Former Member
0 Kudos

Hi Experts,

In target XML file i require to insert data from various tags of source file inside 1 tag i target file. In other words, i need to put data in XML file without tags.

Target file example:

<TransactionData>

:20:DDE_0000001-000022

:32A:101207SAR5817,42

:50:Conversion Company Limited

:52A:XND111111

:53B:30111111123

:57A:SAGRES223

:59:/3010016989940

Testing Employee Bank Account

3646: Conversion Company Limited

Houston 98765

USA

:70:SC_093765

</TransactionData>

Data between :20 to :70 coming from various fields in source file but needs to be embedded in target in vaious lines under 1 tag <TransactionData>.

Can any please let me know if this can be done with any function in message mapping or XSLT mapping?

Thanks.

SM.

Accepted Solutions (0)

Answers (1)

Answers (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You can try using COPY XML Subtree feature.  This would copy all the tags from the source in to one tag for the target.  Please see this link.

http://scn.sap.com/people/william.li/blog/2008/02/14/sap-pi-71-mapping-enhancements-series-copy-xml-...

Former Member
0 Kudos

Thanks Baskar for your reply.

I went through the blog, but it says that all the children tags will be copied. In my case i don't want to display tags in target file. I just want to show the values and all the values should come in different lines under 1 tag.

Can we mask target element field names somehow?

As mentioned below, 4 fields are coming under tag <TransactionData>. But my requirement is to not to show the 4 tags and only their values are displayed like

<TransactionData>

:20:DDE_0000001-000022

:32A:101207SAR5817,42

:50:Conversion Company Limited

:52A:XND111111

<TransactionData>

Thanks.

SM.

Former Member
0 Kudos

Hi,

You have to use UDF to achieve the above..

I dont think either graphical mapping function or XSLT will be helpful here..

HTH

Rajesh

Former Member
0 Kudos

Hi ,

Simply pass all the input field value that you want to pass to target field to udf.

udf-->single values

return input1+"\n"+input2+"\n"+input3....................

Regards

Venkat

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Use String concat function and see if that helps. Otherwise you have to use only UDF.

Former Member
0 Kudos

Hi,

I tried with below input xml and xsl:

xsl:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<Transactiondata>
<xsl:apply-templates select="root"/>

</Transactiondata>
</xsl:template>

<xsl:template match="root">
<xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>

input:

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

<root>
<a>123</a>
<b>456</b>
</root>

target:

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

123

456

</Transactiondata>

Please let me know your input xml for which you need to get given targer xml.

Regards,

Beena.