1

I would like to execute RFC function on explicit destination using JCo.

I've modified existing JCo program StepByStepClient.java and I'm able to execute RFC function exactly the same way like using SAP GUI se37 when the "RFC target sys" field is empty. For my demo purposes I was invoking TH_USER_LIST function.

Then I registered my own JCo server with Program Id MY_PROG_ID, then added tcpip destination MY_DEST using sm59 with "Registered Server Program"="MY_PROG_ID".

I'm now able to invoke TH_USER_LIST on my JCo server using se37 with RFC target sys = "MY_DEST".

I would like to be able to execute the same implementation of TH_USER_LIST on my JCo server using JCo client but I'm still invoking the default implementation and not my registered program.

I presumed I just need to assign the destination as a new property like the ones below but it did not help.

    connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "appserver");
    connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,  "00");
    connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "000");
    connectProperties.setProperty(DestinationDataProvider.JCO_USER,   "JCOTESTER");
    connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "JCOTESTERSPASSWORD");
    connectProperties.setProperty(DestinationDataProvider.JCO_LANG,   "en");

Please advise

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48

2 Answers2

1

For calling a registered external RFC server program please read

for the required destination configuration parameters.

Instead of jco.client.ashost and jco.client.sysnr you need to specify jco.client.tpname, jco.client.gwhost and jco.client.gwserv. In addition, you probably need another destination to an ABAP system for querying the required RFC meta data. This destination needs to be specified as property jco.destination.repository_destination.

Trixx
  • 1,796
  • 1
  • 15
  • 18
  • Perfect, I got it working, e.g. JCO_ASHOST=>JCO_GWHOST, JCO_SYSNR=>"sapgw"+JCO_GWSERV, JCO_TPNAME=program_id, JCO_REPOSITORY_DEST=original destination name. Many thanks!!! – Jaromir Flidr Jun 29 '18 at 09:05
  • Glad to hear that. Instead of using the symbolic service name `"sapgw00"`, which requires that `etc/services` is maintained appropriately, you may also specify the port number `"3300"` directly for _jco.client.gwserv_. – Trixx Jun 29 '18 at 10:30
0

DestinationDataProvider.JCO_ASHOST and DestinationDataProvider.JCO_SYSNR are the correct properties for specifying the target system. But only setting properties is not enough. You also have to get the new JCoDestination object with having these properties from JCoDestinationManager.getDestination("MYDESTNAME") and then use this destination for executing the call.

By the way, I recommend to throw all this file creation stuff out of your Java program and directly edit the appropriate MYDESTNAME.jcoDestination property files manually for getting into the topic.

Trixx
  • 1,796
  • 1
  • 15
  • 18
  • Well as I stated above I got it working, e.g. invoking the default "RFC target sys". However I want to invoke **another** implementation using JCo like I **can** do using se37 with **different** "RFC target sys". I've tried to put the value of "RFC target sys" as `DestinationDataProvider.JCO_DEST` (and a few others) but still invoking the default implementation with JCo. – Jaromir Flidr Jun 28 '18 at 13:32
  • "RFC target sys" is not an RFM parameter. It is functionality of SE37 which means to pick and use the specified destination from SM59 instead of a local execution. So this is "MYDESTNAME" from my example. If you want to execute the RFM on a different target, either specify a different JCO_ASHOST for `MYDESTNAME.jcoDestination` or use a different destination name with a different set of connection parameters. There is no other way. What you want is not possible and makes no sense. Why should I call system A and tell it to execute it on system B? In this case one would directly address system B. – Trixx Jun 28 '18 at 15:41
  • Could you please elaborate "use a different destination name with a different set of connection parameters"? What exactly should be different and how? My client is now opening just single destination which finally ends up executing the default implementation and not my registered program. Not sure what do you mean by system B, there is just one SAP with one registered server program. – Jaromir Flidr Jun 28 '18 at 16:06
  • Oh, now I see you edited your question after my answer. This is now a completely different question. – Trixx Jun 28 '18 at 16:13
  • Please see my other answer for your modified question about calling a registered external RFC server program (instead of an ABAP system). – Trixx Jun 29 '18 at 07:38