How to Throw an Exception in a SapServer

Hello,
We have successfully implemented SAPServer in our external process.
The only thinks that doesn't work perfectly is that we can't throw an exception in the implementation of remote function module.
The ABAP Program that is calling our fontion waits on expetion 0, 1, 2, 3 and 4. But when we throw the exception like this : throw new RfcException( "Error" );
the ABAP catch this exception, but as exception 4 (others) and not as 3 (Error)
Can someone help. Thanks

Hello
Thanks for the answer.
In the while we tried the following:
RfcAbapException( "ERROR" );
but it doesn't work.
The solution was to call this method with 2 parameters:
RfcAbapException( "ERROR", "Some error text...");
And now OK.

Similar Messages

  • How to Throw/Catch Exceptions in BPM

    Hi All,
    I've seen a couple articles that talk about how to Throw/Catch an execption in a BPM. My question has two parts:
    1) RFC Call: I was able to catch an Fault Message in an exception step when calling an RFC (Synchronous Interface). What I wanted to do is use the fault message (exception) and store it in a DB for later review.
    2) IDOC: I'm sending an IDOC to R3 from a BPM. The send step is enclosed in a block w/ an exception. The send step is throwing an error (IDOC adpater system error), but the exception is never thrown. My question is: when the error occurrs at the adapter level does it still throw an exception in a BPM?
    Thanks for any tip/advice/anything!
    Fernando.

    Hi Fernando,
    1) Define a send step in the exception branch.
    2) If u send a IDoc from R/3 to XI and the IDoc adapter is running to an error of course there cant be an exception in ur business process. Usually the IDoc adapter sends back status back up via ALEAUD. In case of success IDoc should have then '03', if the adapter cannot send anything the IDoc should remain at '39'. U should send a ALEAUD in case of exception of BPM switching to status '40', in case of success to '41'.
    Regards, Udo

  • How to throw an exception that is not treated as error

    Hi,
    I have a repository manager displayed as /root/myrepository. Now when someone who's not authorized clicked it, I wish an error message will display on top in red, but not throw an exception as System Error.
    Now my implementation is to throw an ResourceException in getChildren() of the node. But when the user clicked on /root/repository, a System Error screen appeared, but what I want is just an error message.
    Any help is much appreciated~
    I don't know how to attach the screenshots. My MSN is [email protected]
    Thanks,
    Ray

    If you want to disallow getChildren altogether, throw an AccessDeniedException. If you want to hide specific children, just don't put them into the result list.
    Best regards, Julian

  • How to throw bundled exceptions thrown by checkErrors()

    Hi,
    I call pl/sql to do update, and call checkErrors() , the code looks like following, but it doesn't display read friendly message on the screen. What is the right way to throw bundled exception from checkErrors() method?
    try{
    xxg2cGoalPk.startWf (conn,
    new BigDecimal(srpGoalHeaderId),
    new BigDecimal(userId),
    returnStatus,
    msgCount,
    msgData);
    int msgCount1 = 0;
    if(msgCount[0] != null){
    msgCount1 = Integer.parseInt(msgCount[0].toString());
    String returnStatus1 = returnStatus[0];
    String msgData1 = msgData[0];
    OAExceptionUtils.checkErrors(tx,msgCount1, returnStatus1, msgData1);
    catch(OAException e) {
    e.printStackTrace();
    throw new OAException(e.getDetailMessage(),OAException.ERROR);
    thanks
    Lei

    What Shiv said is only an alternative, but what you are using is correct.I haven't tested but as per javadoc of
    OAExceptionUtils.checkErrors(tx,msgCount1, returnStatus1, msgData1);
    will itself raise bundled exceptions. You need to write this line outside try/catch block.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to throw 2 Exceptions,

    Hello,
    I have a problem with a method. I would like to do something like:
    boolean thisIsATest ( ) throws PepeException,PacoException {
    Is it possible ? I already hava thought in wrapping then into a general exception, but I would like to find out if this is possible.
    Thanks in advace for your help,
    Sitomania

    boolean thisIsATest ( ) throws
    PepeException,PacoException {The "throws" clause simply states what exceptions the method can throw. You can list as many as you want, separated by commas.
    However, you can't actually throw multiple exceptions at once. This is reasonable: there should be a single definable condition that prevents your code from continuing.

  • How to throw custom exception from sessionbean

    I define an AppException generalize from EJBException.
    public class AppException extends EJBException{
    when error occurs in sessionbean,I throw AppException, Container perform rollback operation. but at client. I only get EJBException, Why? and How can I get AppException from sessionbean?

    AppException extends RuntimeException

  • How to throw exception in run() method of Runnable?

    Hi, everyone:
    I want to know how to throw exception in run() method of interface Runnable. Since there is no throwable exception declared in run() method of interface Runnable in Java API specification.
    Thanks in advance,
    George

    Thanks, jfbriere.
    I must add though that if your run() methodis
    executed after a call to Thread.start(), then
    it is not a good choice to throw anyRuntimeException
    from the run() method.
    The reason is that the thrown exception won't be
    handled appropriately by a try-catch block.Why do you say that "the thrown exception won't be
    handled appropriately by a try-catch block"? Can you
    explain it in more detail?
    regards,
    George
    Because the other thread runs concurrently with and independently of the parent thread, there's no way you can write a try/catch that will handle the new thread's exception: try {
        myThread.start();
    catch (TheExceptionYouWantToThrowFromRun exc) {
        handle it
    do the next thing This won't work because the parent thread just continues on after myThread.start(). Start() doesn't throw the exception--run() does. And our parent thread here has lost touch with the child thread--it just moves on to "do the next thing."
    Now, you can do some exception handling with ThreadGroup and uncaughtException(), but make sure you understand why the above won't work, in case that was what you were planning to do.

  • How to throw Exception in Thread.run() method

    I want to throw exception in Thread.run() method. How can I do that ?
    If I try to compile the Code given below, it does not allow me to compile :
    public class ThreadTest {
         public static void main(String[] args) {
         ThreadTest.DyingThread t = new DyingThread();
         t.start();
         static class DyingThread extends Thread {
         public void run() {
         try {
                   //some code that may throw some exception here
              } catch (Exception e) {
              throw e;//Want to throw(pass) exception to caller
    }

    (a) in JDK 1.4+, wrap your exception in RuntimeException:
    catch (Exception e)
    throw new RuntimeException(e);
    [this exception will be caught by ThreadGroup.uncaughtException() of this thread's parent thread group]
    In earlier JDKs, use your own wrapping unchecked exception class.
    (b) if you know what you are doing, you can make any Java method throw any exception using Thread.stop(Throwable) regardless of what it declares in its "throws" declaration.

  • How to throw a permanent exception during mapping?

    I'm using the java coding: "throw new RuntimeException(message);" to trigger an error during mapping.
    This will set the message status to: "System error, manual restart possible".
    How can I throw a permanent exception during mapping? So that the message is set to error but will NOT be restartable.

    Hi,
    Any error in  asynchronous mode in XI will be in a Restart Mode.  I dont think this can be done.
    /people/alessandro.guarneri/blog/2006/01/26/throwing-smart-exceptions-in-xi-graphical-mapping
    /people/sap.user72/blog/2005/11/29/xi-how-to-re-process-failed-xi-messages-automatically
    Regards,
    Bhavesh

  • How to throw or catch sql exception for executeReader sql adapter

    Wcf sql adapter was created and executeReader was used.
    When an invalid sql statement was constructed and send it to wcf sql adapter, it will hanging there, and no response. No exception was catched even though send chape  was inside a catch block. How can I catch this kind of exception
    or throw this exception ? I need to give client an exception resposne.
    thanks
    Gary

    I used scope with exception handle which has Exception object type: "System.SystemException".
    I guess this type "System.SystemException" can catch any exception, including sql exception. Maybe I am wrong. I got error from window event:
    A message sent to adapter "WCF-Custom" on send port "WcfSendPort_SqlAdapterBinding_DalCore_Custom" with URI "mssql://shig-quad-2k3e1//DataSourceOne?" is suspended.
     Error details: System.Data.SqlClient.SqlException: Incorrect syntax near '='.
    Server stack trace:
       at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
       at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
       at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
       at System.ServiceModel.Channels.ServiceChannel.EndRequest(IAsyncResult result)
    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at System.ServiceModel.Channels.IRequestChannel.EndRequest(IAsyncResult result)
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)
     MessageId:  {B24EF5B8-298A-4D4F-AA98-5E639361A7DB}
     InstanceID: {F8924129-265B-4652-B20E-8D25F8F20A51}
    If  "System.SystemException" can't catch all exception, which type can catch all exception ? I want to catch all exception in this catch block.
    thanks
    Gary

  • How to throw exception from Listener's Event Methods

    Hi,
    We are using Jdev 10.1.3 and I'm implementing a class that implements EntityListener and RowSetListener interfaces.
    The problem that i'm facing is when I override the event methods of the interface (Which don,t throw any exception) , I'm not able to throw any exceptions in overridden methods also. Kidnly guide me on how to achieve this...
    Sample Code :
    public class GenericHistoryViewObjectImpl extends ViewObjectImpl implements RowSetListener
    // this event is fired when a row is deleted from rowset and it registers data in history
    public void rowDeleted(DeleteEvent event)
    latestEvent = "DEL";
    try
    GenericHistoryManager.registerDataInHistory(this);
    wasLastEventExecutedSuccessfully = 1;
    catch (Exception e)
    e.printStackTrace();
    wasLastEventExecutedSuccessfully = 0;
    genericHistViewException = e;
    from The mothod public void rowDeleted(DeleteEvent event) of RowSetListener i want to throw an exception ...

    JSalonen is totally correct. I would only add that this topic, generally, exposes the differences between checked and unchecked exceptions. Unchecked exceptions extend RuntimeException or Error. Checked exceptions extend Throwable or Exception. There are important differences.
    Checked exceptions must specifically be caught or declared in a throws clause of a caller. Unchecked exceptions do not have this restriction. This means you can always 'wrap' (or throw without wrapping) an unchecked exception. Unchecked exceptions are very useful. You can use an existing unchecked exception, or create your own by extending RuntimeException or Error.
    To illustrate the difference, let's say we are creating a new user account and storing it in the database. For a checked exception, I might define DuplicateUserRegistration in case a user registers with an existing user name (a non-fatal error case that can be anticipated in system design). However, if the database was down, I would not throw SQLException (which is checked) but rather something like ResourceUnavailableError. This would be unchecked. A calling class (normally) will not be able to realistically handle a situation where the database is down, so why force that caller to either declare throws SQLException or catch SQLException for this instance?
    - Saish

  • How do i throw BPEL exception from java embedded activity

    Hello everybody,
    i want to use some embedded java code in my BPEL process (bpelx:exec). This code would sometimes throw exceptions. How can i deal with these exceptions to control my BPEL process? I would like, in a sense, to do some catching of java exceptions but at the BPEL level... for example, my java code would throw an exception, that my BPEL process would "catch" and react the way i want. Is it possible to do that?
    Thanks for your help!

    Re: Embedded Java in BPEL and exception handling

  • Throwing Runtime Exceptions from BPM. How?

    Hi !
    I want to make appear a red flag in the SXMB_MONI as a result of a custom condition inside a BPM. I tried with the control step, but it makes no "red flag".
    Should I make a transform step between 2 dummy message types with a UDF that throws the runtime exception there?? is there another way ?? We want a red flag as a result of a expired deadline while waiting a file adapter transport acknowledgement.
    Thanks !!
    Matias.

    Matias,
    As you said before you want the BPM to be errored out if it reach the deadline, am I right. In control step if u say cancel process it equivalent to logically deleting the work items, so obviously you will get an succesfull message. What I suggest you to do is in  Deadline branch - control branch select throw exception. The exception name has to be defined in Block level. So if you throw an exception it will look for the exception branch in the same block level if not the higher(super)block level, if it couldn't find the exception branch it will run out to error. Actually the exception branch is used to catch that exception and continue the rest of the process, so i think there is no need for defining the exception branch itself.
    Hope it helps you!!!
    Best regards,
    raj.

  • How to throw a SOAP exception

    Hi,
    I have a requirement from customer that when they call the WSDL from their app and the workflow will not get what it should, that it should throw standard SOAP exception.
    To give more details on it, they will send for example input string "A" and based on that I will return output string "B" in the process.
    Now if they ask for "C" for instance, I need to be able to throw that SOAP exception. Is that possible? The process in workbench consists of simple decision point and set value activity based on route conditions.
    Thanks
    J.

    I am assuming you are wanting something to come back as a SOAP fault element?
    Unhandled process exceptions are sent back as faults. So, theoretically, you could write a service component to do nothing but throw an exception. Then you could route your process to call that in specific situations.
    As an alternative, I would consider having something like an additional 'status' output variable that always came back in the response which indicated the status of your process.
    Good Luck,
    Ryan M. Jacobs
    [email protected]
    Cardinal Solutions Group

  • How to throw exception..?

    class A
    void execute() throws Exception
    int i=10/0;
    public static void main(String args[])
    try
      new A().execute();
    catch(Exception e)
    System.out.println(e);
    (or)
    class A
    void execute() throws Exception
    try
    int i=10/0;
    catch(Exception e)
    throw e;
    public static void main(String args[])
    try
      new A().execute();
    catch(Exception e)
    System.out.println(e);
    }hi i want to knw which form of throwing of exception is best from the above two program... and also tell me the reason pls... can anyone give the solution.....

    There are two general classes of exceptions in java, often called checked and unchecked.
    The exception thrown by zero divide, in your example, is a RuntimeException and doesn't require a throws clause.
    Most exceptions are throw with a throw statement, but a few kinds are throw directly by the JVM, zero divide or NullPointerExceptions being examples.
    If you need to throw an exception you typically create an exception class of your own, by extending the Exception class. That way you can have a catch clause that catches just that one kind of exception and your program can act accordingly.

Maybe you are looking for

  • Setting up mail

    Can I set up more than one e mail account to access my e mails? I have gmail account set up and works fine but would also like to set up my POP mail as well. Appreciate some instruction on how to do this. thanks p.s. yes I paid $20 and upgraded to 1.

  • Oracle Management Agent 10.2.0.5 64-bit Solaris

    I am installing Oracle Management Agent 10.2.0.5 on Solaris box. It has been installed successfuly on box1 and on box2 it is giving me error message "Error in invoking target tnsping nnfgt.o mkldflags client_sharedlib of makefile". I am wondering bot

  • Elements 12 unable to install

    I have successfully downloaded a purchased version of elements 12 but when I click on the set up file and agree 'for changes to be made' nothing further happens. I have also tried installing the trial version but this does not work either. My operati

  • Installing JDK for Microsoft Windows

    Hi all, I'm installing 8.53 on Win 2008 following http://docs.oracle.com/cd/E38921_01/psft/acrobat/PeopleTools_8.53%20_Installation_for_Microsoft_SQL_Server.pdf At step Task 2-1-2: Installing JDK for Oracle WebLogic there are three choices : Develpme

  • My rectangle tool has been replaced with a rectangle hotspot tool in Fireworks CS6

    My rectangle tool has been replaced with a rectangle hotspot tool. Is there a way to go back to just the regualar rectangle tool and not a hotspot tool? Thanks