Skip to Content

Remote Enable your RFC_HOST_TO_IP to return Host IP to JCo

Recently I found a quite of lot information sharing at SDN related to RFC’s. I read the blogs My new best friend, Mr. RFC_VERIFY_DESTINATION by Craig and RFC_READ_TABLE – my old faithful – what has happened to you? by Piers and found them very useful. I was working on a JCo application and wanted to use RFC function module RFC_HOST_TO_IP to display the IP address of an RFC host using the Host name. The real problem was that this function module is not Remote Enabled.

image

Hence I was not able to access the Repository using JCo because of com.sap.mw.jco.JCO$Exception: (104) RFC_ERROR_SYSTEM_FAILURE: The function module “RFC_HOST_TO_IP” not released for ‘remote’ calls.

Then after a few modifications by copying the standard function module and I was able to get the required result. Here in this blog I am explaining the steps that I followed to get the host IP address.

First I copied the standard code to a new function module ZC1_RFC_HOST_TO_IP.

I set the Processing Type as Remote Enabled Module.

image

Then in the importing and exporting parameters tab make the Parameter Type as TYPE for RFCHOST and RFCIP.

image
image

And in the Include for Sub Programs keep only the following code, which is sufficient for the required purpose.

And now just activate and execute the program the required IP Address will be displayed.

image

Then coming to the JCo part things are as usual and the following code fetched the IP address for a RFC Host.

And the Java code returned the correct IP Address.

image

Apart from working similar to the standard function module this also helps me to the IP using the JCo. Thus I thought it was nice to share this every one so that we can customize some good function modules as Remote Enabled for our External Applications.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Kathirvel Balakrishnan Post author
    Hi Durai,

    Nice code sample from you. It would have better if it was a blog, as the discussions and comments will drill much deeper into other perspectives.

    I tried them with JCo and you with ABAP and hope some will post some other variation soon..

    Cheers
    Kathir~

    (0) 
  2. balaji uppalapati
    Hello,

    I was going through your posting, wondering about how did you generate java code? can you provide more information on what tool did you use to generate code?.

    Thank you,
    Balaji

    (0) 
  3. Ilja Farber
    I’m wondering each time I see similar articles.
    What shows the example here?
    It converts host name to IP, translated to java
    something like Inet4Address.getByName. It does this in ABAP, and despite it use kernel call (= may not work in the next release) somebody could reuse the code.
    But why the author spends the horrible java program to invoke the ABAP function??? Just to demenstrate the common pitfalls related to Java Connector. Let me list the issues in the short java example:
    1. connection leak, because the connection is never closed
    2. memory wasting, because the repository is not global (even small examples should define the repositories to be able to share them with other threads/components)
    3. instable behaviour, because the repository should be create with a pool of connections instead of “single” client
    4. deployed on a java application server it could stops the AS because of System.exit.

    So I really wondering, what is the benefit of your “blog”.

    (0) 

Leave a Reply