How to handle JCO Exceptions at JCO (RFC) function call

Hello Forum,
I am implementing an JCO Server scenario.
I use dynamic repositories like Example7.java from the JCO documentation.
Example7 throws an JCO.AbapException if anything went wrong, e.g. the function is not implemented.
How to react on this AbapException?
The examples in SAP Help documentation only catch
SYSTEM_FAILURE and COMMUNICATION_FAILURE.
All other RFC modules I have seen which declare the function modules to be used by dynamic JCO repositories (like Example7.java) do not define any other Exception parameters.
But these two are only thrown and caught when something with communication went completely wrong, e.g. RFC not found.
But when RFC can be reached and the JCO Server is executing the Java method, an AbapException could be thrown on error. How to react on this?
In my implementation based on the examples I always get a ABAP dump. The dump says:
Exception named  without message text. Why that name?
How to handle this type of exception in order to avoid the dump?
Can anyone post an example please?
Thanks,
Carsten
Edited by: Carsten Schön on Apr 15, 2008 4:22 PM
Edited by: Carsten Schön on Apr 15, 2008 4:24 PM

Hi Micky,
thanks for your quick response.
If so, to throw JCO.AbapException on JCO Server side is not correct?
What I do is throwing the JCO.AbapException (like in the JCO Example 7).
At the RFC call in APAB I handle both exceptions SYSTEM_FAILURE and COMMUNICATION_FAILURE like
CALL FUNCTION 'MY_JCO_FUNCTION_MODULE'
    DESTINATION JCO_DEST
    <...>
    EXCEPTIONS
      SYSTEM_FAILURE        = 1  MESSAGE RFC_MESS
      COMMUNICATION_FAILURE = 2  MESSAGE RFC_MESS.
This works as far something with RFC is wrong, e.g. Server can not find the function or Server not reachable.
But the AbapException thrown by the JCO Server (Java) is not handled that way. Why?
Sorry if this is the wrong forum but I tried posting in Netweaver integration and got no answer for 1 week and because it's ABAP related I thought the topic suites here.
Carsten
Edited by: Carsten Schön on Apr 15, 2008 5:10 PM

Similar Messages

  • Can we disable implicit DB commit in JCO RFC function call?

    I called RFC function provided by ABAP from JCo connection, found that each RFC function is a db LUW itself. All the db access sql in RFC function is implicit commited.
    Till now, to wrap the db access sql in seperate "Update function module" or "Perform on commit" seems to be a choice for me (like most BAPI doing so). But is it the only choice?
    The point is, can we disable(or bypass) the implicit DB commit while calling a RFC function from JCo connection?

    Hi Guru,
    Yes you approach is correct, make sure commit/rollback is possible only when a change is/was made in database.
    Go through these links will be helpful,
    BAPI_TRANSACTION_COMMIT with Web AS/SOAP Interface
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/d352a790-0201-0010-5082-b1a608d22b6c
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/d352a790-0201-0010-5082-b1a608d22b6c
    Hope that solves your problem.
    Thanks & Regards,
    Kathirvel

  • How do I retrieve records from a table using JCO RFC Function Call

    Hi
    I am totally new to SAP Java Progamming. And I would like to know if I am writing code correctly. I read some tutorials in the Internet but I am still not sure if I am doing it the correct way.
    This is what my vendor has given me.
    My question is whether this is the correct optimum way to do get the customer detail based on an array of input values for the customer reference number.
    Input:
    I_CUSTNO - Any number customer IDs. This is a table similar to I_CUSTDETL
    Output:
    Structure name:  I_CUSTDETL
    Note: The CUSTID column has been added in the structure to identify the address of the relevant customer id
    Field details:
    Field Name  Data Type  Length
    CUSTID       Character   10
    COMPANYNAME   Character   40
    EMAIL        Character     40
    This is my code:
            JCoFunction function = connect.getFunction("Z_GET_CUSTOMER");
            JCoTable cust = function.getTableParameterList().getTable("I_CUSTNO");
            cust.appendRow();
            cust.setValue("CUSTID", "10000700");
            cust.appendRow();
            cust.setValue("CUSTID", "10000701");
            cust.appendRow();
            cust.setValue("CUSTID", "10000702");
    connect.execute(function);
            JCoTable table = function.getTableParameterList().getTable("I_CUSTDETL");
              System.out.println("Table size: " + table.getNumRows());
              for (int i = 0; i < table.getNumRows(); i++, table.nextRow()) {
                String custid= table.getValue("CUSTID").toString();
                String companyname = table.getValue("COMPANYNAME").toString();
                String email = table.getValue("EMAIL").toString();
                System.out.println("----
                System.out.println("Record Number::" + i + "::");
                System.out.println("----
                System.out.println("Value custidis::" + custid+ "::");
                System.out.println("Value companyname is::" + companyname + "::");
                System.out.println("Value email is::" + email + "::");

    Hi,
    Answer to your question :whether this is the correct optimum way to do get the customer detail based on an array of input values for the customer reference number? is
    YES.
    Regards,
    Ganga

  • How to handle the exception in GP(Exception : Activity could not be read)

    Hi all
    we are getting the GP exceptions  as  1) "Activity could not be read"  2) "Action has been stopped"
    3) error while processing the item can not be displayed
    Please let me know how to handle these exceptions in GP .
    currently i got some documents in SDN on GP exceptions but those are related to manual exceptions for example if you enterd wrong data in the inputfield then we can handle those exceptions then it will allow to enter the new value but the exceptions which i mentioned above are new it seems
    can you please let me know how to handle or solve those 3 exceptions
    Thanks
    bindu

    Hi Shikhil
    Thanks for your reply
    Please have a look below for exceptions which i am getting in GP and let me know how to handle these exceptions.
    1) "Activity could not be read"
    2) "Action has been stopped"
    3) error while processing the item can not be displayed
    if you give any idea/clue how to handle these exceptions then it would be great help to me
    Thanks
    Sunil

  • How to handle the Exception in GP using executable callabel object.

    Hi all,
            I handled an exception in GP using Background callable Object. That is working fine.
    (Ex: Exception_No_User_Found). The Problem is I am not able to handle the exceptions for normal callable object. I have done the same thing as i did in background callable object except implementing IGPBackgroundCallableObject Class.  I have created an WebDynpro DC Project where in getDescription method i declared an Exception and in execute method of component controller I caught the exception if no user found.
    Then i created an callable object for this simple DC project. but that is not working i could not catch the exception. when i execute the process it is asking the User ID if i give the wrong userId it is not refreshing back to the user id input form.
    But if i test that simple callable object separately it is throwing an Exception when I give the wrong input..
    but the same thing is working fine using background callable object.
    I couldn't handle the exception for the simple callable object or executable callable object.
    Please If anyone bring me the solution that would be appreciated.
    Thanks in advance.
    Regards,
    Malar.

    Hi Shikhil
    Thanks for your reply
    Please have a look below for exceptions which i am getting in GP and let me know how to handle these exceptions.
    1) "Activity could not be read"
    2) "Action has been stopped"
    3) error while processing the item can not be displayed
    if you give any idea/clue how to handle these exceptions then it would be great help to me
    Thanks
    Sunil

  • How to handle an Exception in GP through webdunpro

    Hi,
    How to handle exception in WebDynpro GP callable objects.
    I created exception parameter in getdescription() method like
    IGPExceptionInfo processExc1 = technicalDescription.addProcessException("USER_NOT_FOUND");
      processExc1.setNameKey("USER_KEY");
      processExc1.setDescriptionKey("USER_DESCRIPTION_KEY");
      processExc1.setFatal(true);
    In my Process I have 2 levels, In block level i am able to see the above created exception using exception tab.
    I have created an action with same callable object mapped, this action is mapped to exception handler & selected an repeat option from dropdown.
    If any exception occurs in execute method(like UMException) how to call an  handler from coding. I tried this code to call a handler
    String localizedMessage =textAccessor.getText("USER_NOT_FOUND");
      wdThis.wdFireEventTechnicalException(new GPTechnicalCallableObjectException(logger,localizedMessage,e));
    this is not working...
    Can any one please bring me an Solution.
    Thanks in advance.
    Regards
    ThenMalar

    Hi Shikhil
    Thanks for your reply
    Please have a look below for exceptions which i am getting in GP and let me know how to handle these exceptions.
    1) "Activity could not be read"
    2) "Action has been stopped"
    3) error while processing the item can not be displayed
    if you give any idea/clue how to handle these exceptions then it would be great help to me
    Thanks
    Sunil

  • How to handle XScript Exceptions ?? HELP !!

    hey buddies !!!
    I am getting the following exception in the browser for some jsp that is using XSCript.
    "Caught exception when evaluating expression "MIDC PHASE II DOMBIVALI {E}" with available binding contexts [actionForm, pageFlow, globalApp, request, session, appication, pageContext, bundle, container, url, pageInput]. Root cause: com.bea.wlw.netui.script.xscript.IllegalContextStateException: The context "E" could not be found. "
    Its okay that i am gettign this exception but i want to to know how to handle this exception. I tried using a try catch block but it didnot catch the exception and it still showed on the screen. I want to know how to handle this exception in the jsp ...
    Please help me ...thanks a lot !!!
    Nikhiol

    Nikhil--
    Can you paste in the tag (with the attributes) that is throwing the expression?
    Are you trying to data bind to "{E}"? If so, that's not a supported NetUI data binding context
    and the exception is legit. There isn't really a way to "handle" it -- it's more of a runtime error
    that occurs during regular development. When the application is deployed, such exceptions shouldn't
    occur.
    <g>
    Eddie
    Nikhil Gonsalves wrote:
    hey buddies !!!
    I am getting the following exception in the browser for some jsp that is using XSCript.
    "Caught exception when evaluating expression "MIDC PHASE II DOMBIVALI {E}" with available binding contexts [actionForm, pageFlow, globalApp, request, session, appication, pageContext, bundle, container, url, pageInput]. Root cause: com.bea.wlw.netui.script.xscript.IllegalContextStateException: The context "E" could not be found. "
    Its okay that i am gettign this exception but i want to to know how to handle this exception. I tried using a try catch block but it didnot catch the exception and it still showed on the screen. I want to know how to handle this exception in the jsp ...
    Please help me ...thanks a lot !!!
    Nikhiol

  • CATCHABLE EXCEPTIONS in the remote function call (RFC)

    Please tell me what are the CATCHABLE EXCEPTIONS in the remote function call (RFC) and to which exception class do they belong????
    Thanks in advance.
    Dinesh Dhiman

    HI,
    With external function calls, the EXCEPTIONS addition of the CALL FUNCTION command can be used to assign return values to the exceptions defined in the interface of the called function module. Class-based exceptions cannot be propagated to the caller from a remotely-called function module, and have the effect of an exception that cannot be handled.
    As well as the exceptions defined in the interface of the called function module, an external function call can also have the following predefined exceptions:
    The <b>SYSTEM_FAILURE</b> exception is the response to a runtime error that occurs when the remotely-called function module is executed.
    The <b>COMMUNICATION_FA</b>ILURE exception occurs when the connection to the partner system cannot be established or if the connection is lost during communication.
    Note
    We strongly recommend that you assign a return value to both these exceptions for every RFC, and that you handle this return value, as otherwise a runtime error will occur in the exception situations in question.
    Regards,
    Sesh

  • RFC Function Call - System not available

    Hello,
    in my own program i´m using an RFC function call to get data out of our BW - System like this:
    CALL FUNCTION 'RRW3_GET_QUERY_VIEW_DATA' DESTINATION i_dest
        EXPORTING
          i_query               = i_query
          i_view_id             = i_view_id
          i_t_parameter         = i_t_parameter
        IMPORTING
          e_axis_data           = gt_axis_data
          e_cell_data           = e_cell_data
        EXCEPTIONS
          system_failure        = 1
          communication_failure = 2
          OTHERS                = 3.
    This works fine and fast as long the BW System is up and running. If the BW system is for some reason down my program has very bad performance because this RFC function call is trying for about 10 seconds every time.
    Is there a way to avoid this long waiting time? A kind of parameter?
    If there is no answer after one or two seconds the programm should continue.
    Any ideas for this?
    Thanks a lot.
    Best regards
    Manfred

    try the following like look for TTL(time to live) in the doc
    http://www.google.co.in/url?sa=t&source=web&cd=5&ved=0CDkQFjAE&url=http%3A%2F%2Fwww.erpgenie.com%2Fsapgenie%2Fdocs%2FSAP%2520Connectors.doc&rct=j&q=ttl%20for%20rfc%20call%20in%20sap%20abap&ei=DShnTv7VGYbWrQeYgPXcCg&usg=AFQjCNGvnINnxj8kYx9IeelUHy0dQPmuMA&cad=rja

  • TS1424 How do you fix a R6025 pure virtual function call error?  When I try to search for music, iTunes freezes & returns this message.

    How do you fix a R6025 pure virtual function call error?  When I try to search for music, iTunes freezes & returns this message.

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    tt2

  • How to handle JCO.AbapException on JCO call in ABAP

    Hello Forum,
    I am implementing an JCO Server scenario.
    I use dynamic repositories like Example7.java from the JCO documentation.
    Example7 throws an JCO.AbapException if anything went wrong, e.g. the function is not implemented. My coding is like:
         protected void handleRequest(JCO.Function function) throws AbapException {
              try {
                // Process incoming requests
              } catch (Exception e) {
                log.error(this.getProgID() + ": error handling request " + function.getName(), e);
                throw new AbapException(function.getName(), e.getMessage());
    How to react on this AbapException?
    The examples in SAP Help documentation only catch
    SYSTEM_FAILURE and COMMUNICATION_FAILURE.
    I implemented the JCO call as well like following.
    CALL FUNCTION 'MY_JCO_FUNCTION_MODULE'
        DESTINATION JCO_DEST
        <...>
        EXCEPTIONS
          SYSTEM_FAILURE        = 1  MESSAGE RFC_MESS
          COMMUNICATION_FAILURE = 2  MESSAGE RFC_MESS.
    But these two are only thrown and caught when something with communication went completely wrong, e.g. RFC not found.
    When the exception in the JCO server occured and JCO.AbapException was thrown I always get an ABAP short dump, i.e. the exception was not handled.
    Additionaly, the exception is named like the JCO function called and the message text which was submitted to JCO.AbapException is not displayed. I think that means that the AbapException was not recognized at all?
    The JCO API doc says:
    Creates an exception with the specified key. This constructor is normally used in the server's handleRequest() methods to throw an exception which is part of the function interface definition. In such a case the SAP system will not raise a system exception. If however the specified key is not a defined exception for the currently processed function module the SAP will raise a system exception.
    But whether I define an exception in the function interface definition named like the module (thererfor new AbapException(function.getName(), <...>)) or not, it always dumps. I understand the exception that a system exception is raised when the exception is not defined? But this is not been handled with above ABAP code as well.
    What is wrong here? Could anyone post an example please how the exception has to be handled?
    Please note that I do not define static repositories but have the remote function defined on in the ABAP server to be used by dynamic repository (like the STFC_CONNECTION test rfc). Am I right that the exception should be defined in that RFC remote definition?
    Thanks,
    Carsten

    Dear everybody,
    Finally I solved this old problem
    I am a novice in JCO and played a little with the problem and found an old reference to the difference between J2EEAbapException and AbapException classes. I modified my program and it works! ABAP caller gets the correct exception, not system_failure! The details:
    1. modify beanname.java source
         import com.sap.mw.jco.JCO;
         import com.sap.mw.jco.JCO.J2EEAbapException;
         public interface ... extends EJBObject {
        public void processFunction(JCO.Function function) throws RemoteException, J2EEAbapException;
    2. modify beannamebean.java source
        import com.sap.mw.jco.JCO.J2EEAbapException;
         public void processFunction(JCO.Function function) throws J2EEAbapException {
         throw new JCO.J2EEAbapException("NODATA");
    3. modify beannamelocal.java source
          import com.sap.mw.jco.JCO;
         import com.sap.mw.jco.JCO.J2EEAbapException;
              public void processFunction(JCO.Function function) throws J2EEAbapException;
    I hope it helps for somebody else too!
    Imre

  • HOW to handle JCO connection failure

    if i have a JCO connection.....to process the RFC function...
    when i call the function...the job leave to R3 to do the rest...
    yet ..the connection broken..at this time..
    the is no result return..and consequency receive the
    RFC_ERROR_COMMUNICATION exception...
    how do i handle this kind of situation....
    what should R3 SHOULD DO..
    let's say i have a jco connection
    the connection broken during processing...how do i return the error message to the java program
    the error include....RFC_SYSTEM_FAILURE ,RFC_ERROR_COMMUNICATION
    Message was edited by:
            yzme yzme

    Yzme,
    You have already got answers how to catch this exception.
    Next processing depends on application-specific nature of RFC: whether or not call is idempotent, in simple words -- submitting same request doesn't hurt.
    This comes from the fact that network failure may occurs when transferring request (hence no background processing performed) or when returning response (hence function already executed).
    For idempotent calls there is also an option for automatic re-tries finite number of times. For non-idempotent calls the only option is to display error to user in friendly format.
    An idempotent call is a call that can be executed more than once on the server without undesirable side effects. Take for example Create / Read / Update / Delete operations. Obviously, read is idempotent while it doesn't alter data at all. You may treat Delete as idempotent up to certain extent -- just handle "record not exists" gracefully. Create and Update are not good candidates -- re-submitting same request typically leads to serious problems like duplicate entries or data inconsistency.
    Valery Silaev
    SaM Solutions
    http://www.sam-solutions.net

  • How to handle system exception in Sync communication without BPM? Help!

    Hi Experts
       I have a Synchronous scenario in XI: webservice <------>RFC SAP R/3.
      Webservice is making a sync call to RFC FM in SAP R/3 system.
       I want to handle system exception when SAP R/3 is down and send an email alert.    
       Can I achieve this in graphical mapping without BPM? How? Kindly provide necessary steps/screenshots for the same.
       Are there any other alternatives for handling system exception apart from mapping and BPM?  
    Thanks
    Gopal

    Hi GopalKirshna,
          Yes,You can handle the Exception if at all you are using the RFC.You can achieve this without using BPM.
       Using Fault message you can catch the System Exception and even the primary role for Fault Message is to catch the RFC Exceptions.
       Please refer the Fault messages Notes to achieve this you will understand better.
    Hope I am clear.
    Please let me if you have any more queries regarding this..!
    Thanks and Rewards,
    Chandu.

  • How to use the exceptions in a RFC ?

    I can use XI (through BPM) to call a RFC and get response from the "Export" of a RFC. But could I get the exception from the "exception" of a RFC ?
    I tried to write a RFC which will generate a exception and I found it in the XI monitor, but how to use it ? i.e. sometimes I need to get the "export", but sometimes I need to get "exception". Is there any documents or examples for it ? thanks.

    Hi,
    <i>But for fault message, I don't know how to send it to a receiver.</i>
    There is no other configurations that you need to do with respect to fault messages.
    If the rfc returns an exception, this message, is passed on to the receiver instead of the response message.
    The receiver of the fault message will be the system that sent the request.
    <i>(If I can use a transformation to mapping it to other message, I think it's ok too.)</i>
    You need not use a BPM, for this, in case you are using it only for fault message handling.
    All you need to do is, create a message mapping, with source and target message types as RFC exceptions and carry out a one to one mapping.This would display the exception coming from the RFC as the fault response st the sender.
    In case, the exception returned from the RFC is not self-explanatory, you could map constants to the target message type(in message mapping) which would explain the reason for the fault.
    Regards,
    Smitha.

  • How to handle multiple exception types in JSF 2?

    I'm trying to handle multiple exception types in JSF2, including a default error page for any unexpected exception types. The problems I'm having are:
    1) ViewExpiredException is handled only when no generic exception handler is specified
    2) "Regular" exceptions like NullPointerException are never handled
    My managed bean:
    @Named
    @SessionScoped
    public class MyController implements Serializable {
    /* A method that does nothing */
    public void doNothing() {
        //do nothing
    /* Generate a null pointer exception on purpose */
    public void generateNpe() throws NullPointerException {
        Object x = null;
        x.toString();
    My test page to generate the exception:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Test page</title>
    </h:head>
    <h:body>
        <h:form>
            <h:commandButton id="button1" value="do nothing" action="#{myController.doNothing}" />
            <h:commandButton id="button2" value="generate NPE" action="#{myController.generateNpe}" />
        </h:form>
    </h:body>
    </html>
    My web.xml:
    <!-- Redirect all NPEs to this page; this never works! -->
    <error-page>
        <exception-type>java.lang.NullPointerException</exception-type>
        <location>/error/error003.jsf</location>
    </error-page>
    <!-- Redirect all VEEs to this page; this works fine if the next section is excluded -->
    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/error/error002.jsf</location>
    </error-page>
    <!-- This grabs everything, even with the previous sections defined.  If I exclude this error-page section, VEE works fine but NPE still does not get redirected -->
    <error-page>
        <exception-type>java.lang.Exception</exception-type>
        <location>/error/error001.jsf</location>
    </error-page>My questions are as follows:
    1) How can we handle "regular" java exceptions like NPE?
    2) How can we define a catch-all for unexpected exception types, while still respecting specific exception handlers for VEE, etc?
    Thanks,
    Benjamin

    Is your data model right? If you are adding in one and deleting in another it sounds to me more like a process that an entity, in which case you may revisit your data model and simplify it, add in a session bean with the process method to co-ordinate between the two.
    However, if you want to map multiple different tables within a single entity bean it is possible and just part of the mapping. How you actualyl specify it depends on which implementation you are working with.
    Cheers,
    Peter.

Maybe you are looking for