Skip to Content
author's profile photo Former Member
Former Member

How to fail message in Java mapping

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"

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on May 04, 2011 at 08:10 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 04, 2011 at 08:04 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 04, 2011 at 08:14 AM

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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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?

  • author's profile photo Former Member
    Former Member
    Posted on May 04, 2011 at 09:45 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 04, 2011 at 10:25 AM

    Hi,

    if (<condition>)

    throw new StreamTransformationException("<Message>");

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

    Regards,

    Manjusha

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.