How to handle JCO.AbapException on JCO call in ABAP

10-11  Source: Network gathering  Views:2 

Advertisement
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
Related articles
  • How to handle lock object in BDC  call transcation method? 11-30

    Hi, how to handle lock object in BDC  call transcation method? Thanks In advances.If you are updating Z-fields then you need to create a lock entry, before you use call transaction. After creating lock object, please use FM Enqueue_<lockname> before

  • How to handle currency & unit fields in call transaction? 11-30

    Hi, Can any one tell me How to handle currency & unit fields in call transaction? & how to dael with error for this fields? whith some sort of coding. Thanks In Advance. PravinHi Pravin, The same topic has been discussed in the following thread: H

  • How to handle JCO.AbapException on JCO call in ABAP 10-11

    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:    

  • How to handle multiple connection through JCO 10-11

    Hello JCo Experts, My requirement is as follows: > I need to create a Web Dynpro Java Application > I have multiple users (different Users on SAP System). > I need to execute BAPI/Module Functions through these multiple users. Example: Users: A a

  • How to handle unsaved data in portal through webdynpro ABAP ? 10-11

    Hi Experts ,      I  need to handle unsaved data in SAP Enterprise Portal through webdynpro for ABAP . I got a sdn link which explained some code for this.. http://help.sap.com/saphelp_nw70/helpdata/EN/45/b76f4169e25858e10000000a1550b0/frameset.htm I

  • How to handle JCO Exceptions at JCO (RFC) function call 11-30

    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 A

  • Jco connection error while calling Custom FM in CRM Internet Sales Application 10-11

    Hi , I am trying to do some customisation in the CRM ISA 4.0 development component. Have followed the steps given in the Development and Extension Guide and tutorial PDF Steps done for Custom RFC Call 1.       Create RFCs 2.       Edit file backendob

  • JCO Exception in Background calling 10-11

    Hi, i am trying to upload data using sap standard uplaod programs throug a java application using JCO. Unfortunately these standard programs sometimes pops up with a info message and i am getting these exceptions for Suppressing unwanted SAP GUI scre

  • How to create an instance of JCO.Table 11-30

    hi, I am facing a problem while migrating from JCO Client service to Connector Framework. Basically i get the output in the format of IRcordSet after calling Back End system. I need to convert this to JCO.Table to continue in my code so that i wont c

  • How to handle the call transaction in method of a custom business object 10-11

    Hello all, There is a custom report " RPTCORAPP" for approving leaves . As per my requirement i have develop a copy of leave workflow and for approval process i have call  "RPTCORAPP" in Custom method of custom object. i have made a tr

  • How to create a model and JCO connection 10-11

    Hi all,          The Userid and Password given while creating new model at Singleserver/Load balancing tab should be same as the userid and password given while creating JCO connection. i.e in JCO creation  while mapping modeldata to Application data

  • How to handle special characters in NWDI 10-11

    Dear All I am trying to update the Description from JSP form. Through JCO we are calling the RFC of ABAP. We are passing these description from Java to RFC of ABAP and this RFC update the text in Database. We have noticed that if there is some specia

  • How to handle rpc/encoded style messages using BizTalk? 10-11

    I am integrating with a lot of services and one of our customers has a service with rpc/encoded style I could consume and generate schema from their wsdl file via BizTalk consume WCF wizard. Once I am trying to call the service with request message t

  • Suggestions on how to handle "Hacked Skype Account... 10-11

    I. User Can Still Access Account Run a full anti-virus scan (and other security scans available in your computer).  This may help to detect and remove any elements that the hacker may have used in gaining access to your account. 2.  Immediately Chang

  • How To Handle Error Message In TCD Recording? 10-11

    Hi All,   I tried recording a transaction (my own transaction) by not enterring value in an obligatory field. the error message came. but when i executed the script, it showed an error. but actualy, the error message was expected right? how to handle

  • How to handle error message during PAI? 10-11

    Hi Experts, Need help here. In my dialog screen, I have a field which is typed 'QUAN'. In entering different format , e.g. with non numeric value or a negative value, an error message appear and it does not process the MODULES inside the chain or FIE

  • Please tell me how to handle list item in this concern 10-11

    please tell me how to handle list item in this concern My problem is: i have a category table with column categoryname(varchar type) I want to display the records of categoryname in a drop down list (i.e., list item ) So ..please tell me how to do it

  • Duplicate check via BAS (ADDRESS_SEARCH)-- how to handle non-crm customer? 10-11

    Dear all, I'm implementing a duplicate check and using the BADI Address_search. Within this BADI I use the method "Address_Search" for calling a third party software tool with customer information. This tool checks whether the entered customer i

  • Missing start boundary exception, caused by an empty Part, how to handle? 10-11

    Hello, i wrote an application that automatically handles mails from laboratories. The only essential part of the mail is the attachment, where chemical analyses are submitted (from permitted addresses, recognized by whitelist and fileheader of the at

  • How to handle Big FIles in SAP PI Sender file adapter 10-11

    Hi all , I have developed a interface , where it is File to Proxy, it is fine when i do with small and normal files The structure contain one  Header unbounded  detail and one  Trailer, how to handle when the file size is more than 40 MB Thanking you