cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping - Get TAG returns

Former Member
0 Kudos

Dear All,

I have a message mapping with the structures:

Souce:

<ns2:DadosMsg><cUF>SP</cUF><ano>2006</ano></ns2:DadosMsg>

Target:

<cUF>SP</cUF>

<ano>2006</ano>

I have to move the values between the tags <cUF> <ano> from the source structure that is one line only to the target structure that will be independent fields.

How can I do this?

Best Regards,

Fernando

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

You can do this with following simple UDF with the parameters <i>source</i> and <i>tag</i>:

int start = source.indexOf("<" + tag) + tag.length() + 2;
int end = source.indexOf("</" + tag);

if ((start > 0) && (end > start))
    return  source.substring(start, end);
else
    return "";

As source you apply the string, as tag the constants cUF or ano.

Regards

Stefan

Former Member
0 Kudos

Hi Stefan,

I Used your sugestion and worked very well.

Thank you so much,

Regards,

Fernando

Answers (3)

Answers (3)

stefan_grube
Active Contributor
0 Kudos
<cUF>SP</cUF><ano>2006</ano>

and

<cUF>SP</cUF>
<ano>2006</ano>

are identical. 'nl' is considered as whitespace and omitted from the graphical mapping tool.

Stefan

MichalKrawczyk
Active Contributor
0 Kudos

hi,

but the source message has: DadosMsg

as a root element

I believe he may want to delete it

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

Former Member
0 Kudos

Hi,

The structures are not identical because the souce has only a element with the all XML information and the target has a lot of elements.

Souce:

<ns2:DadosMsg><cUF>SP</cUF><ano>2006</ano></ns2:DadosMsg>

Target:

<cUF>SP</cUF>

<ano>2006</ano>

I want to select on a information between the tag <cUF> from the element <ns2:DadosMsg> 'SP' and move to the element cUF from the target structure.

How can I make this mapping?

Thaks,

Fernando

P.S. Both structures are external definitions.

Former Member
0 Kudos

Hi,

The structures are not identical because the souce has only a element with the all XML information and the target has a lot of elements.

Souce:

<ns2:DadosMsg><cUF>SP</cUF><ano>2006</ano></ns2:DadosMsg>

Target:

<cUF>SP</cUF>

<ano>2006</ano>

I want to select on a information between the tag <cUF> from the element <ns2:DadosMsg> 'SP' and move to the element cUF from the target structure.

How can I make this mapping?

Thaks,

Fernando

P.S. Both structures are external definitions.

stefan_grube
Active Contributor
0 Kudos

I cannot see any difference. Maybe the string is escaped like:

<ns2:DadosMsg>&amp;lt;cUF&amp;gt;SP...

In this case you need first to deescape the string with Java mapping.

If you have it just for two tags, you can do this as well in a user defined function.

Regards

Stefan

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Is you soruce datatype like this,

<ns2:DadosMsg>XXXX</ns2:DadosMsg>

if yes, and if your data is going to be,

<ns2:DadosMsg><cUF>SP</cUF><ano>2006</ano></ns2:DadosMsg>

then , Graphical mappping will error out as your Source XML schema / XSD will not match with your input!

In this case, you will need to use java or XSL mapping to handle the same. By the ways, can you tell us why you have such an input? It would be better if you have a source datatype like the input itself/

Regards

Bhavesh

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

but this:

<cUF>SP</cUF>

<ano>2006</ano>

is not an xml document

create a normal xml document and just cut the rest in the adapter module

or create the output with the use of xslt mapping

as with message mapping you need to have

an xml document as an output (and with XSLT, java, abap

mappings it is not necessary)

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

Former Member
0 Kudos

HI,

I know what you mean, but I put only a short piece of the XML. This is an example.

So I am looking a way to work with this kind of string convertion, I mean, to move from one line only to the corresponding fields of my XML target.

got it ?

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

You would need to use either Java or XSL mapping to do this does not confirm to your Source XSD. Graphical mapping will error out and so, using Java / XSL is the way to go.

Regards

Bhavesh

Former Member
0 Kudos

Hi,

I agree with you.

I don't know java very well.

Can you show me an example?

Thaks,

Fernando