on 05-16-2020 1:27 PM
I'm working on a 731 SP15 SAP system, with the Eclipse 2020-03 and the last ABAP Core Development Tools etc. The goal is to create an Eclipse plug-in, that can call an RFC FM on the backend. I can't use the BADI as showcased by christian.drumm here as I'm not on a high enough release.
To get started, I've used the HelloWorld template, and replaced the text to be displayed in the popup with information retrieved from the backend via RFC. I've followed the example JCo in the JCo SAP Help but I'm having trouble getting it working.
In the example, we create the destinations by defining them in the file system. Alternatively, we can create our own implementation of DestinationDataProvider and register that. The problem I seem to be having is that in the Eclipse environment, the ADT have already registered a data provider. I've dug around, but can't find how I can get a list of the destinations that ADT uses/creates when an ABAP Project is created.
I don't know how to get from the project to the name of the destination that ADT must be using for all its work.
What I'd like ideally is something like:
IProject project = ProjectUtil.getActiveAdtCoreProject(selection, null, null,
IAdtCoreProject.ABAP_PROJECT_NATURE);
String projectDestinationName = someMethodThatGetsDestinationFrom(project);
JCoDestination destination = JCoDestinationManager.getDestination(projectDestinationName);
TL:DR It would be so nice to be able to call an RFC from a plugin in Eclipse, using the credentials stored with an ABAP Project. Any suggestions?
You can get the destination ID from the project using
String destinationId = com.sap.adt.project.AdtCoreProjectServiceFactory.createCoreProjectService().getDestinationId(project);
Then you should be able to work directly with the underlying JCo destination
JCoDestination destination = JCoDestinationManager.getDestination(destinationId);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That works lovely. Funnily enough I'd tried something similar, but couldn't get it to work. I tried your solution, and it still didn't work... until I actually opened the project within Eclipse. So it seems the destination isn't registered in JCo until it's opened.
In my defence, I was expecting this
IProject project = ProjectUtil.getActiveAdtCoreProject(selection, null, null,
IAdtCoreProject.ABAP_PROJECT_NATURE);
if (project == null) {
MessageDialog.openInformation(window.getShell(), "No selection", "No ABAP Project selected");
} else {
MessageDialog.openInformation(window.getShell(), "Playground", getResult(project));
}
to catch that before I attempted to get the destination.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.