cancel
Showing results for 
Search instead for 
Did you mean: 

How to fail message in Java mapping

Former Member
0 Kudos

Hi All,

My requirement is very simple.

i have to check value of a field "RFCResponse" , it will have 2 values ( S ,F) means sucsess or failure.

If "RFCResponse" = "F". I need to fail the Java mapping and in the SXMB_MONI , error step i should get a message

"Java mapping failed since RFC look up failed.

below is part of my code

public class JavaMapping extends AbstractTransformation {

..................
public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException {

try (if RFCResponse = "S")
	{
	//8. The JAVA mapping output payload is returned using the TransformationOutput class
	// arg1.getOutputPayload().getOutputStream()
		arg1.getOutputPayload().getOutputStream().write(RFCResponse.getBytes("UTF-8"));
	}
	catch(Exception exception1) { }


}
}

Please kindly let me know how to write code when RFCResponse = "F"

Accepted Solutions (1)

Accepted Solutions (1)

shweta_walaskar2
Contributor
0 Kudos

Hello Sam,

If your error message is constant 'Java mapping failed since RFC look up failed' you can simply write a statement :

(if RFCResponse = "F")

throw new RuntimeException("Java mapping failed since RFC look up failed");

When you do this,in case of RFCLookup failure, message will fail in SXMB_MONI and you can see your error message in Message Trace in SXI_MONITOR.

Please let us know if it meets your requirement.

Thanks.

Best Regards,

Shweta

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

if (<condition>)

throw new StreamTransformationException("<Message>");

StreamTransformationException has worked for me. Write it inside transform method.

Regards,

Manjusha

Former Member
0 Kudos

Hi Sam,

Just try the following for RFC lookup failure scenario:

else if ( RFCResponse.equalsIgnoreCase( "F"))

throw new StreamTransformationException("Java mapping failed since RFC look up failed");

Hope this helps.

Regards, Gaurav

Former Member
0 Kudos

http:// www/saptechnical/com/Tips/XI/JavaMapping/Exceptions.htm

Former Member
0 Kudos

Hi All,

I have tried using both the below statement , but both the time messages are processed in MONI.

throw new StreamTransformationException("Mapping failed:", e); 
throw new StreamTransformationException("Mapping failed:");

Any other thought??

former_member200962
Active Contributor
0 Kudos

the JAVA methods you have used will populate the error message in the trace info....message will still be executed.

If you want to error-out the message in SXMB_MONI (red flag) then you can refer this blog by MIchal:

/people/michal.krawczyk2/blog/2007/04/26/xipi-throwing-generic-exceptions-from-any-type-of-mapping

Former Member
0 Kudos

chk this whethre this helps u or not??....

try

{

if(RFCResponse.equalsIgnoreCase( "F")) /put ur logic here/

throw new StreamTransformationException("");

}

catch (StreamTransformationException exception1) {

getTrace().addWarning("Java mapping failed");

StreamTransformationException me = new StreamTransformationException("mapping failed due to soem reason", exception1);

throw me;

}

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Using java mapping you can able to throw exception . THis way you can pass error message and can be traced in SXMB_MONI. But you cannot stop the message execution. What is you requirement? Another solution is use some trick in the reciever determination to stop transferring to target system by checking the xpath or context object. Is that requirement?

Former Member
0 Kudos

Hello,

You simply need to throw the StreamTransformationException (the corresponding message will then appear with an error in SXMB_MONI) ...

Other technics may be available, this is the most obvious one IMHO

Rgds

Chris

PS : your code seems a little bit strange to me (the try (if ....)) block, but I'm no JAVA expert ...

Edited by: Christophe PFERTZEL on May 4, 2011 10:04 AM