cancel
Showing results for 
Search instead for 
Did you mean: 

JCo, BAPI (RFC) and Eclipse Plugins

matt
Active Contributor

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.

  1. Is it possible to get the destination (to use with JCoDestinationManager.getDestination) from the ABAP project
  2. Is it possible to see the registered destinations in the current DestinationDataProvider?
  3. Is it possible to add a new destination to the current DestinationDataProvider?

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?

BiberM
Active Participant

Just a thought: ADT itself uses Web Services for every communication with the backend. Would it be an option to define a Service and call the FM within?

matt
Active Contributor
0 Kudos

Hmm. I'll look into that approach.

But something somewhere has registered an implementation of DestinationDataProvider - which implies to me that JCo is being used somewhere.

Armin_Beil
Product and Topic Expert
Product and Topic Expert

The backend parts of ADT are modeled as REST resources. These resources are accessed

- via RFC/JCo when connecting to on-premise backends
- via HTTPS when connecting to cloud backends

I asked an expert for more details on the main questions.

matt
Active Contributor
0 Kudos

armin.beil.2 thanks. To confirm, this is on-premise backend.

Accepted Solutions (1)

Accepted Solutions (1)

sratz
Advisor
Advisor

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);
matt
Active Contributor

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.

Answers (0)