cancel
Showing results for 
Search instead for 
Did you mean: 

Call back in JCo3.0.1 server programming

Former Member
0 Kudos

I need setup a JCo server, which provides one function named F, and registered into a gateway. Both SAP system S1 and S2 can call function F. When S1 call F, F need call several BAPIs on S1 server. Similarly, when S2 call F, F need call these BAPIs on S2 server.

In my opinion, I need get a JCoDestination object to call back.

Does JCo3.0.1 support my requirement? If yes, is their any sample code for me?

Thanks!

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

The answer is using "BACK":

JCoDestination destination = JCoDestinationManager.getDestination("BACK");

And function meta data need to be specified in the client custom repository.

Former Member
0 Kudos

Hi Kevin,

I have exactly same requirement. Could you please provide more details of your implementation like custom repository and how its linked , accessed at run time.  destination back is used only in server thread. how you achieved this.

Thanks in advance.

Regards.

Prashant

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Prashant,

CustomRepository is not related at all to destination BACK. The instance of JCoDestination you get returned when requesting for BACK will ensure automatically that it can be used only within a server thread context. there's nothing left to do for an application. JCo runtime already takes care of this.

Best regards,

Markus

Former Member
0 Kudos

thanks Markus,

The base problem here is that we are not able to implement the BACK destination for the JCo server. On exexcution we encounter following error:

  (128) JCO_ERROR_NOT_SUPPORTED: A callback can only be executed in a server thread

So, could you share some piece of sample code or can point on the below code that we have implemented:

  //JCo connection details

  JCoDestination dest = JCoDestinationManager.getDestination("DEMO_CONNECT");

  JCoDestination dest2 = JCoDestinationManager.getDestination(JCoDestination.BACK);

  //JCo server connection details

  Properties props = new Properties();

                props.put(ServerDataProvider.JCO_GWHOST, "HOSTD6");

                props.put(ServerDataProvider.JCO_GWSERV, "sapgw00");

                props.put(ServerDataProvider.JCO_PROGID, "JCOSERVER01");

                props.put(ServerDataProvider.JCO_CONNECTION_COUNT, "2");

                props.put(ServerDataProvider.JCO_TRACE, "1");

                CustomServerDataProvider.defineServer("BACK_CONN", props);

  //JCo Custom repository creation details

  JCoCustomRepository cR = JCo.createCustomRepository("MyCustomRepository");

  JCoFunctionTemplate STFC_CONNECTION = dest.getRepository().getFunctionTemplate("STFC_CONNECTION");

  JCoFunctionTemplate STFC_CONNECTION_BACK = dest.getRepository().getFunctionTemplate("STFC_CONNECTION_BACK");

  cR.addFunctionTemplateToCache(STFC_CONNECTION);

  cR.addFunctionTemplateToCache(STFC_CONNECTION_BACK);

  //JCo server connection callin details

  JCoServer mRFCServer = JCoServerFactory.getServer("BACK_CONN");

  mRFCServer.setCallHandlerFactory(new DefaultServerHandlerFactory.FunctionHandlerFactory());

  mRFCServer.setRepository(cR);

  mRFCServer.start();

  //executing the STFC_CONNECTION_BACK using the BACK Destination

  JCoContext.begin(dest2);

  JCoFunctionTemplate temp = dest.getRepository().getFunctionTemplate("STFC_CONNECTION_BACK");

  JCoFunction func = temp.getFunction();

  func.getImportParameterList().setValue("REQUTEXT", "TEST CONNECTION");

  func.getImportParameterList().setValue("NRBACK", "1");

  func.execute(dest2);

  System.out.println(func.getExportParameterList().getValue("ECHOTEXT"));

  System.out.println(func.getExportParameterList().getValue("RESPTEXT"));

  JCoContext.end(dest2);

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Prashant,

the question is: Where do you invoke the code below //executing the STFC_CONNECTION_BACK using the BACK Destination? This should be part of a JCoFunctionCallHandler implementation. BTW, callbacks from ABAP to JCo - the other wa round - are no longer supported with JCo 3.0.

From the exception you get, yuo obviously invoke it at a different place.

Best regards,

Markus

Former Member
0 Kudos

Hi Markus,

Our scenario is detailed below:

1. Starting a standalone connection with SAP using JCo3 and then calling BAPI BAPI_DOCUMENT_CHECKIN_REPLACE2 to check in a document in DMS.  This BAPI will be having path to a local file ( on presentation server ) and this should be checked in .

2. In this BAPI , during checkin process SAP standard code is there in which a call back is made using function RFC_START_PROGRAM with destination BACK. I have checked a function with this name doesn't exist in SAP. So we suspect SAP is trying a Callback to Jco and trying to find out this function. We are getting error RFC_START_PROGRAM not found. It is having parameter for starting saphttp.exe file .- for registering the server on gateway.

Any pointers please wrt BACK or any other method?

Thanks and Regards.

Prashant

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos


Hi Prashant,

JCo 3.0 does no longer support RFC_START_PROGRAM fro security reasons. Moreover, you obviously mixed up a few things: When using destination BACK in ABAP, you try to do a callback to JCo, which is not supported with JCo 3.0. But according to note 796709, you can also specify a concrete destination for saphttp in the BAPI BAPI_DOCUMENT_CHECKIN_REPLACE2. Have you tried this already?

Regarding destination BACK it seemed to me so far that you like to do a callback to ABAP from an JCo Server program.

Best regards,

Markus

Former Member
0 Kudos

You answered my question that JCo 3.0 does not support RFC_START_PROGRAM and destination BACK.  Thanks .

I tried setting up a destination in BAPI BAPI_DOCUMENT_CHECKIN_REPLACE2 but it seems only destinations of type TCP/IP with activation type "start on Front-end work station" and "start on Application server" works fine.  And both of them have shortcomings. Like Front end work station necessitates SAP GUI installation at JCo client and Application server requires mounting of files to SAP because local path is not recognized by it ( Open dataset  ) is used . 

We are going ahead with mounting of files unless something else comes our way.

Thanks a lot for your support!

Best Regards.

Prashant