问题
I would like to execute RFC function on explicit destination using JCo.
I've modified existing JCo 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 mine registered program.
I presumed I just need to assign the destionation as a new property like the ones bellow 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
回答1:
For calling a registered external RFC server program please read
- SAP Note 1877907 - Support of extern-to-extern RFC communication with JCo 3.0
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.
回答2:
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.
来源:https://stackoverflow.com/questions/51082276/how-to-execute-rfc-function-on-explicit-destination-using-jco