Call Java in ABAP?

Hi,
When I want to call a function module in Java I use JCO. Is there also a way to "call Java code" in ABAP?
Bye,
Chris

/people/gregor.wolf3/blog/2004/08/26/setup-and-test-sap-java-connector-outbound-connection
http://help.sap.com/saphelp_erp2005/helpdata/en/6f/1bd5c6a85b11d6b28500508b5d5211/frameset.htm
Regards,
Rich Heilman

Similar Messages

  • Call java from ABAP

    JCo connectivity is used to call RFCs from Java. can i call Java from abap?
    thanks in advance.....
    regards,
    Sundararamaprasad

    Hi Sundar ,
             This link will surely give u an idea about calling java fro ABAP using Jco.
    http://www.thespot4sap.com/Articles/SAP_Netweaver_Java_Connector.asp
    regards,
    aravindh.

  • How to Call Java from ABAP

    Hi all,
    I have installed JCO & created the RFC in SAP. i have used below code to test my RFC connection & it's working fine.
    But In the below report, where to call the JAVA Program & what code i should use to call java code .
    Actually my ABAP requirement is to download a file. Then i need to call JAVA program, inside ABAP, to encrypt the downloaded file. Here, Java program is used to encrypt the file. Now question is, how to call the Java program inside the ABAP code.  Please advice with the code sample. Thanks a lot.
    REPORT  z_jco_test.
    PARAMETERS: requtext LIKE sy-lisel.
    DATA: echotext LIKE sy-lisel,
          resptext LIKE sy-lisel,
          rfctest TYPE TABLE OF rfctest,
          wa_rfctest TYPE rfctest.
    wa_rfctest-rfcdata1 = requtext.
    wa_rfctest-rfcdata2 = 'Hello World'.
    APPEND wa_rfctest TO rfctest.
    CALL FUNCTION 'RFC_PING'
      DESTINATION 'JCO'.
    CALL FUNCTION 'STFC_CONNECTION'
      DESTINATION 'JCO'
      EXPORTING
        requtext = requtext
      IMPORTING
        echotext = echotext
        resptext = resptext
      TABLES
        rfctest  = rfctest.
    WRITE: 'Echo Text: ', echotext.
    WRITE: 'Response Text: ', resptext.
    LOOP AT rfctest INTO wa_rfctest.
      WRITE: / 'rfcdata1: ', wa_rfctest-rfcdata1.
      WRITE: / 'rfcdata2: ', wa_rfctest-rfcdata2.
    ENDLOOP.

    Hi,
    You might accomplish your goal using external operating system commands.
    1) Define in SM69 an external command, letu2019s say ZJAVA. This command will execute a script on the operating system, letu2019s call it calljava.sh.
    2) In script calljava.sh you just call java, passing some parameters. For example, java $1 $2 $3 $4 $5 $6 $7
    3) In your ABAP program you call the ZJAVA external command and pass parameters to it. Of course, one of the parameters must be your Java program name.
      CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
        EXPORTING
          commandname                   = l_command
          additional_parameters         = l_param
          trace                         = 'X'
        IMPORTING
          status                        = l_status
          exitcode                      = l_exitcode
        TABLES
          exec_protocol                 = l_exec_protocol_itab
        EXCEPTIONS
          no_permission                 = 1u2026

  • Calling java from abap

    Hi Colleauge,
        I have a scenario in which i have a program in java. This program expects few parameters and this java program needs to be called from an ABAP program.
    Please let me know how can i achieve this.
    Thanks & Regards,
    Ritwik.

    Hi
    the concept of Web Dynpro is common for Java as well as SAP.
    if you have the SAP Netweaver Developer Studio on your machine you can use it to generate proxies for the Java-SAP calls (and maybe SAP-Java too). This will generate Java classes (which will use JCo) and these classes can be used on your Java system.
    You will get help from this concept.
    Regards,
    Shamma

  • ABAP Calling JAVA Function or Method

    Hi Friend,
    I need help in how to proceed using  ABAP  and Call JAVA Function . I know that  we need to use RFC enabled Function modules. I was able to connect  using JAVA Connector which was provided by SAP For communicating with JAVA Apps. The approach for connecting the JAVA to SAP is working fine.  But I  have browsed through various website but failed to find any information.Now i am looking forward to help from you friends to solve my problems .
    The Requirement is mentioned below:-
      1. Prerequiste for SAP ABAP calling a third Party software which is working in JAVA Platform (like any middle ware which might be hardware or software).
      2. Sample Code  like calling a Text  ' Hello  to the world  calling JAVA from ABAP'.
      3. Steps and process so that it would be helpful.
    Timely help would be appreciated.
    Rajiv Christopher.

    1.Middleware is JCO RFC provider it comes with SAP so no need any third party Adapter.
    2.
    " The ECHOTXT parameter should contain the text of REQUTXT.Information on
    " calling the function module should be returned in RESPTXT, indicating, for
    " example, in which system and when the function module call was processed.
    data:ECHOTEXT type SY-LISEL,
         RESPTEXT type SY-LISEL.
    CALL FUNCTION 'STFC_CONNECTION' DESTINATION '<Your JCO destination name>' " which one you have developed in SM59 as TCP/IP
      EXPORTING
        requtext       = 'ABAP Calls JAVA'
    IMPORTING
       ECHOTEXT       = ECHOTEXT
       RESPTEXT       = RESPTEXT.
    if sy-subrc = 0.
      WRITE:/'---------------------------------------------------------------------'.
      WRITE: / 'establish a link to the ABAP application server with logon data'.
      WRITE:/'---------------------------------------------------------------------'.
      write:/ ECHOTEXT .
      else.
          WRITE:/'---------------------------------------------------------------------'.
      WRITE: / 'Not establish a link to the ABAP application server with logon data'.
      WRITE:/'---------------------------------------------------------------------'.
      endif.
    Check the sample code and Let me know will you get ECHOTEXT ?
    Kanagaraja L
    Edited by: Kanagaraja  Lokanathan on Jan 6, 2010 1:27 PM

  • Error while calling java program from ABAP

    Hi Experts,
    We are trying for RFC inbound scenario.
    We followed the below blog
    /people/gregor.wolf3/blog/2004/08/26/setup-and-test-sap-java-connector-outbound-connection
    We are working with SAP JCO 3.0.2
    We are getting the error : 'STFC_CONNECTION' could not be found in the server repository.
    After I run the Java server program if I execute the RFC destination directly from SM 59 it is showing successful messages.
    If I stop the java program then this RFC is failing. Based on this we concluded that RFC to Java connection is working fine.
    But as mentioned in blog if we call the RFC Destination from ABAP program it is giving the below error,
    'STFC_CONNECTION' could not be found in the server repository.
    If we test the RFC destination using RFC_TRUSTED_CHECK standard FM we are getting the below error.
    'RFCPING' could not be found in the server repository.
    We create the RFC destination of Type : TCP/IP as exactly mention in the blog.
    Please help us in resolving this issue.
    Thanks
    Prince

    Pabi,
    Using the RFC connection,we can establish a link between Java and SAP.
    Afterwards,hope we can call Java program from ABAP.
    Below is the sample piece of code to establish RFC connection(link) between Java and SAP.
    DATA: REQUTEXT LIKE SY-LISEL,
          RESPTEXT LIKE SY-LISEL,
          ECHOTEXT LIKE SY-LISEL.
    DATA: RFCDEST like rfcdes-rfcdest VALUE 'NONE'.
    DATA: RFC_MESS(128).
    REQUTEXT = 'HELLO WORLD'.
    RFCDEST = 'JCOSERVER01'. "corresponds to the destination name defined in the SM59
    CALL FUNCTION 'STFC_CONNECTION'
       DESTINATION RFCDEST
       EXPORTING
         REQUTEXT = REQUTEXT
       IMPORTING
         RESPTEXT = RESPTEXT
         ECHOTEXT = ECHOTEXT
       EXCEPTIONS
         SYSTEM_FAILURE        = 1 MESSAGE RFC_MESS
         COMMUNICATION_FAILURE = 2 MESSAGE RFC_MESS.
    IF SY-SUBRC NE 0.
        WRITE: / 'Call STFC_CONNECTION         SY-SUBRC = ', SY-SUBRC.
        WRITE: / RFC_MESS.
    ENDIF.
    Regards,
    Sree

  • How to call  java program from ABAP

    Hi Experts,
         My requirement is to call java programs from ABAP. For that i have set up SAP JCO connection by using this link http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/739. [original link is broken] [original link is broken] [original link is broken] Connection gets sucessfully. After this how to call java program from ABAP as per our requirement. Please help me out.
      Also i tried this way also.. but while executing the DOS Command line appear & disappear in few seconds. So couldnt see the JAVA output. Please help me out to call java programs in ABAP..
    DATA:command TYPE string VALUE 'D:Javajdk1.6.0_20 injavac',
    parameter TYPE string VALUE 'D:java MyFirstProgram'.
    CALL METHOD cl_gui_frontend_services=>execute
    EXPORTING
    application = command
    parameter = parameter
    OPERATION = 'OPEN'
    EXCEPTIONS
    cntl_error = 1
    error_no_gui = 2
    bad_parameter = 3
    file_not_found = 4
    path_not_found = 5
    file_extension_unknown = 6
    error_execute_failed = 7
    OTHERS = 8.
    Thanks.

    This depends on the version of your Netweaver Java AS. If you are running 7.0, you will have to use the Jco framework. The Jco framework is deprecated since 7.1 though. If you want to build a RFC server in 7.1 or higher, it is adviced that you set it up through JRA.
    Implement an RFC server in 7.0:
    http://help.sap.com/saphelp_nw04/helpdata/en/6a/82343ecc7f892ee10000000a114084/frameset.htm
    Implement an RFC server in 7.1 or higher:
    http://help.sap.com/saphelp_nwce72/helpdata/en/43/fd063b1f497063e10000000a1553f6/frameset.htm

  • Error when calling Java Web Services from ABAP.

    Hello experts:
        In my project, I will call Java Web Services with ABAP coding. With WSDL, I generated a proxy class and created a HTTP connection (t-code: SM59) and a logical port (t-code:lpconfig) for this proxy class. But when running, I would receive the folllowing errors:
       SOAP:1.023 SRT: Processing error in Internet Communication Framework: ("ICF Error when receiving the response: HTTP COMMUNICATION FAILURE")
       If I used HTTPS, there is no problem.
    Regards
    Bob

    Hi Bob,
    It might be the possibility that your java web server is configured to listen only on HTTPS.
    If your HTTPS is working fine, then first check with your JAVA server for HTTP connectivity, then try it calling through ABAP.
    Regards,
    Piyush

  • Calling Java program from ABAP

    Hi All,
    my ABAP program downloads one file to one folder. Then one Java program is running to Encrypt the file.
    Now , they want to call the JAVA program in ABAP, so that they can encrypt the file before downloading.
    Is it possible to call a Java program from ABAP ? If Yes, please give me the detailed procedure.
    Thanks
    pabi

    Pabi,
    Using the RFC connection,we can establish a link between Java and SAP.
    Afterwards,hope we can call Java program from ABAP.
    Below is the sample piece of code to establish RFC connection(link) between Java and SAP.
    DATA: REQUTEXT LIKE SY-LISEL,
          RESPTEXT LIKE SY-LISEL,
          ECHOTEXT LIKE SY-LISEL.
    DATA: RFCDEST like rfcdes-rfcdest VALUE 'NONE'.
    DATA: RFC_MESS(128).
    REQUTEXT = 'HELLO WORLD'.
    RFCDEST = 'JCOSERVER01'. "corresponds to the destination name defined in the SM59
    CALL FUNCTION 'STFC_CONNECTION'
       DESTINATION RFCDEST
       EXPORTING
         REQUTEXT = REQUTEXT
       IMPORTING
         RESPTEXT = RESPTEXT
         ECHOTEXT = ECHOTEXT
       EXCEPTIONS
         SYSTEM_FAILURE        = 1 MESSAGE RFC_MESS
         COMMUNICATION_FAILURE = 2 MESSAGE RFC_MESS.
    IF SY-SUBRC NE 0.
        WRITE: / 'Call STFC_CONNECTION         SY-SUBRC = ', SY-SUBRC.
        WRITE: / RFC_MESS.
    ENDIF.
    Regards,
    Sree

  • Calling Java API from ABAP using JCo (Part 2)

    Hello,
    This is an additional question to thread Calling Java API from ABAP using JCo
    Has anyone managed to get the input parameter value
    input.getString("REQUTEXT")
    that is being passed from ABAP?
    If yes, what kind of setting you need to do? Because when I execute, it has no value.
    Thus, the below ECHOTEXT parameter returns blank value:
    output.setValue(input.getString("REQUTEXT"),"ECHOTEXT");
    When I debug by printing the below line, the input XML is indeed without value:
    System.out.println(input.toXML());
    Anybody knows how to pass input variable from ABAP to JAVA using JCo?
    rgs,
    hiroshi

    Hallo Hiroshi,
    as far as I can see, you are doing it the right way. The problem might be that the ABAP program does not fill in this parameter because something went wrong in the SAP System.
    Have you tried setting a breakpoint (an HTTP session - remote breakpoint) and tried checking step by step if the value is being processed and put into the REQUTEXT field?
    Bye,
    Sameer

  • Calling java class from abap function moduile

    Is it possible to call java class from function module.
    i am a java guy. my need is to call a java class from a  function module in the backend. which in turn performs certain functions.
    i would be highly obliged if someone could let me know if this is possible.
    regards
    Srikumar V

    Hi Srikumar ,
    you can call a java webservice in ABAP .
    u can call the webservice and via that u can trigger the java class..
    Regards
    Renu

  • Calling Java API from ABAP using JCo

    I need to call Java API from ABAP & BSP also. For this I have got useful information related to JCo from following blog:
    /people/gregor.wolf3/blog/2004/08/26/setup-and-test-sap-java-connector-outbound-connection
    But, I am facing one problem. On executing Java program myExample5.java (recommended by Gregor Wolf) from command line I get following error message:
    Server JCOSERVER01 changed state from [ STOPPED ] to [ STARTED ]
    Exception in server JCOSERVER01:
    com.sap.mw.jco.JCO$Exception: (129) JCO_ERROR_SERVER_STARTUP: Server startup failed at Thu Apr 26 13:46:32 IST 2007.
    This is caused by either a) erroneous server settings, b) the backend system has
    been shutdown, c) network problems. Will try next startup in 1 seconds.
    Connect to SAP gateway failed
    Connect_PM  TPNAME=JCOSERVER01, GWHOST=gateway, GWSERV=3300
    LOCATION    CPIC (TCP/IP) on local host
    ERROR       hostname 'gateway' unknown
    TIME        Thu Apr 26 13:46:32 2007
    RELEASE     640
    COMPONENT   NI (network interface)
    VERSION     37
    RC          -2
    MODULE      ninti.c
    LINE        336
    DETAIL      NiPGetHostByName2: hostname 'gateway' not found
    SYSTEM CALL gethostbyname_r
    COUNTER     1.
    Can anyone please help me out. Do I need to do any setting?
    I'll surely reward points.
    Thanks & Regards,
    Nilesh Kumar

    Hi Nilesh,
    From the error i think that the error is with the hostname.
    Please enter the the Application Server IP/Hostname.
    If you are loggin to SAP System "XX1" from SAP GUI. Then click the change Item tab and see Application server name/IP let say "XX2" for hostname or "xx.xx.xx.xx" for IP.
    Replace <i>srv[0] = new Server("gateway","sapgw00","JCOSERVER01",repository);</i>
    with <i>srv[0] = new Server("XX2","sapgw00","JCOSERVER01",repository);</i>
    If App Server is IP then replace with
    <i>srv[0] = new Server("xx.xx.xx.xx","sapgw00","JCOSERVER01",repository);</i>
    Let me know if it is throwing any error.
    Thanks,
    Prashil

  • Calling Java Services from ABAP code

    Hi,
    How to call Java services (not web service) from ABAP code?
    I have a requirement where JAVA team has developed some services that can be called from URL or from a Java application.
    Ex:  when this URL is executed,
    http://localhost:8080/artemis7_802/triton/mycompany.remoteFunctions.RequirementsList.a7x?requestid=3023&requestname=I6PRAO1&skill=SAP&skill=JAVA
    It returns a XML file on browser.
    And I have no idea about the 2nd way i.e. from Java application!
    Now, how can ABAP call these java methods?
    I heard that something can be done via maintaining RFC destinations in SM59 to call Java services? Can this be done with my requirement?
    Please help.
    Thanks and regards,
    Amey

    Posted it in WD ABAP forum.

  • JCo Outbound( calling Java Function from ABAP )

    HI,
    I want to call a JAVA function from ABAP.I have installed the JCo toolkit and included the sapjco.jar file in the classpath of my system.
    When i execute the program(Example5.java,provided with sapjco.zip) from the command prompt,it is working fine,the server listens to the calls made from ABAP via RFC destination.
    But if i copy the same program in NWDS in a JAVA project,to run it from there as JAVA application,after including the sapjco.jar file in the project JAVA build path,i get the following error,marked by a red cross ,at the head of the program,even before i run it.
    <b>This compilation unit indirectly references the missing type com.sap.jdsr.writer.DsrIPassport (typically some required class file is referencing a type outside the classpath)</b>
    What changes do i need to make,to run it from NWDS?
    I tried to include the sapjcorfc.dll file along with the sapjco.jar in the java build path,but it doesn't help.
    Please tell how to solve this issue?
    Regards,
    Siddhartha

    hello sid,
    which jco version are you using?
    are you using the same jco lib when running in command
    line and in nwds?
    if you are, try checking the order of the your classpath.
    your jco lib (which you are using in command line) should
    come first in order prior to the default libraries in your project.
    regards
    jo

  • Call Java Program from ABAP Program

    Dear all,
    In our scenario, we need to let ABAP call services provided by a standalone Java program. From online help I found some overview introduction and I'd make the called program a registered program in a RFC with type "T" (TCP/IP Connection). Can anybody give some concrete documentation? A step-by-step guide would be greatly appreciated.
    Best Regards
    Jerome

    check this thread
    Re: Calling Java API from ABAP using JCo

Maybe you are looking for