cancel
Showing results for 
Search instead for 
Did you mean: 

Receiver Mail Adapter: transformation of Content tag

Former Member
0 Kudos

Hi,

I have a problem with the transformation of the tag Content in the e-mail message. I'm very ignorant about xsl and java transformation, but my problem is quite simple.

My message, coming from an R/3 system, is this:

<ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">

<Subject>Hello</Subject>

<From>sender@sender.com</From>

<To>receiver@receiver.com</To>

<Content>row1 \n row2 \n row3</Content>

</ns:Mail>

The only thing I have to do is to test the string in tag Content, and replace \n with EOL.

So my message will become:

<ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">

<Subject>Hello</Subject>

<From>sender@sender.com</From>

<To>receiver@receiver.com</To>

<Content>row1

row2

row3</Content>

</ns:Mail>

Can anyone help me with an XSL transformation or an advanced java function to solve my problem?

I'll be very grateful....

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Ilaria

Since the message is coming from R/3, do a simple message mapping with java function converting the "Content" tag contents to the required.

eg, a string function .replaceAll with regex argument specifying '
n' to be replaced with '\n' will solve your problem.

regards,

Felix

Former Member
0 Kudos

Hallo Felix,

thanks for your reply.

Unfortunatelly I can't understand your suggestion. I need to convert '\n' with 'EOL', but I don't know which symbol means 'End Of Line'. In my example, the text I have to send in my e-mail must be on three lines.... What is '
n'?

Thanks in advance.

Ilaria

Former Member
0 Kudos

Ilaria,

you have the text content as "row1 \n row2 \n row3" which is not actually

"row1

row2

row3"

Hence, in java the string "row1 \n row2 \n row3" is actually represented as "row1
n row2
n row3" because '\n' in java is escape code. So, what you need to do is just to replace your text '\n' to escape code '\n'. If '\n' is a text then the real text present there is '
n' which are 2 chars which had to get converted to one char '\n'.

Since the function is in java you can use a simple java function to and process the input string as

function testfn(String inputstr,Container container)

{

return inputstr.replaceAll("[
n]","\n");

}

This would solve your problem

Best regards,

Felix

Former Member
0 Kudos

Dear Felix,

you've been very very helpful to me.

I had to manage the fact that java function didn't replace substring "\n" nor "
n" nor "[
n]". So I've changed in the input message (abap report from the R/3 system) "\n" with value "&EOL".

Java code now is

return inputstr.replaceAll("&EOL","\n");

and work perfectly!

Thanks a lot!

Ilaria

Former Member
0 Kudos

Ilaria,

I am happy to hear that it worked and see encouraging comments from you.

Regards,

Felix

Answers (0)