cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT Code

Former Member
0 Kudos

HI,

Can anybody explain me where should i write the xslt code for error handling and how to use this error handling in Xi ?

Regards,

Tuhin

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

HI Jason,

This issue is becoming hot i think.

See I have two error condition one is suppose the file is not there when file adapter is looking for file.

Second there are blank values in flat file which i don't want to send to integration engine .I mean if value is not there in flat file say like

no name

1 a

2 b

3 c

blank d

3 e

3 f

here no is empty(no value) in 4th row in flat file .now i want to log this error in central log in a text file.IS this possible with

graphical tool ?

Thnks & regards

Tuhin

Former Member
0 Kudos

HI Jason,

yes i was not able to explain u.

We have used graphical message mapping.

Now what is the way of error analysis ?

Suppose i want to use java message mapping then i have to write code for mapping in any editor and then only i need to specify the class in message mapping editor is this a right way ?

Regards,

Tuhin

Former Member
0 Kudos

I need a little more detail.

You are using the graphical mapping tool.

What error could occur?

Is it in a user defined function? If so, you can simply throw a RuntimeException.

If not, then I would be interested in understanding the problem. What could go wrong in the graphical mapping tool? Typically you avoid validation in the middleware. Validation is an application task, not a message broker task.

Can you give me more detail?

Jason

Former Member
0 Kudos

Hi Tuhin,

Here is the right way:

you should create a user-defined function with a code that checks your conditions and then you can either throw a RuntimeException, or just log some messages using MappingTrace interface. An instance of MappingTrace is available in a function via container.getTrace(); Please also see documentation on package com.sap.aii.mapping.api; The user-defined function has to be used in some Target Field Mapping.

Regards,

Alexey

Message was edited by: Alexey Borodin

Former Member
0 Kudos

Hi All,

I followed this thread for a while. Because I'm also interested in good error handling during mapping.

I just experimented with throwing a Runtime Exception. This stops mapping but the error message is buried within a large stack trace in the ErrorHeader of the XI-Message.

I'm still searching for a method where the ErrorHeader clearly shows my error message like ...

<i> <SAP:ErrorHeader xmlns:SAP="http://sap.com/exchange/MessageFormat">

<SAP:Context></SAP:Context>

<SAP:Code p1="Error during mapping"

p2="Field value XYZ out of Range"

p3=""

p4="">MAPPING.GENERIC</SAP:Code>

<SAP:Text language="EN">Error during mapping</SAP:Text>

</SAP:ErrorHeader></i>

Regards,

Marc

Former Member
0 Kudos

Unfortunately you will not get such an elegant solution.

The user defined functions do not have an exception in the signature so you cannot throw a normal exception, instead you can only throw system type exceptions.

This result is that massive java stack trace you mentioned.

Not elegant, but all there is at this stage.

It does allow you to trap the error in the alert manager and respond automatically, which is a good start.

Regards,

Jason

Former Member
0 Kudos

Jason, sorry I am just learning this stuff - I have been looking for how to throw errors in graphical mapping. Agreed, the source/target should be responsible for validation, but in our business scenario, we have to be able to catch when we have idiot errors on the source system. How do I throw the exception? Even if it's buried within a dump, I can work around that with some custom reporting - right now I just can't figure out how to throw the thing... THANKS

Former Member
0 Kudos

HI Jason,

I know that documentation link.

Can u just expalin me where should i write this code during design of business scenario.

What i did is created a business scenario file->XI->Sap.

Datatype->MessageType->MessageMapping->

Interface->mapping all i created now i want to add condtion(Error handling) during message mapping but where to write this xslt code ?

Regards,

Tuhin

Former Member
0 Kudos

I guess I don't understand the problem then. You say you have created the message mapping.

A message mapping can be either Graphical mapping, abap mapping, java mapping, XSLT (java or abap).

I assume you have used an XSLT message mapping?

If so, then the doco shows the error handling is embedded in the XSLT code. You test your conditions and respond with the <xsl:message terminate=“[yes|no]“>.

If not, then you need a different error handling technique.

Can you clarify which message mapping you have used?

Jason

Former Member
0 Kudos

Hi Tuhin,

Error handling in XSLT is documented here:

http://help.sap.com/saphelp_erp2004/helpdata/en/8a/7672f7d7e444439fd7024f806221a4/frameset.htm

Basically if something goes wrong during mapping you can use: <xsl:message terminate=“[yes|no]“>

Does this answer your question?

Jason