cancel
Showing results for 
Search instead for 
Did you mean: 

JCO Connection to a backend SAP system in Hybris 5.3

0 Kudos

Hello Experts,

I am trying to call a SAP CRM RFC from a Hybris service layer class. However, the connection object always seems to be null and throws up an exception. I have followed the steps in the below link.

https://wiki.hybris.com/display/release5/sapcorejco+Extension+-+Technical+Guide#sapcorejcoExtension-...

Below is my code: package com.sap.trial.services;

 import de.hybris.platform.sap.core.bol.backend.BackendType;
 import de.hybris.platform.sap.core.bol.backend.jco.BackendBusinessObjectBaseJCo;
 import de.hybris.platform.sap.core.jco.connection.JCoConnection;
 import de.hybris.platform.sap.core.jco.exceptions.BackendException;
 
 import com.sap.conn.jco.JCoFunction;
 
 
 /**
  * 
  */
 @BackendType("ERP")
 public class ZCallSampleSAPRFCBackend extends BackendBusinessObjectBaseJCo
 {
 
     //    @Resource
     //    private JCoManagedConnectionContainer managedConnectionContainer;
     JCoConnection conn = null;
 
 
     public String getUserName()
     {
         conn = getDefaultJCoConnection();
         String name = "";
         try
         {
             final JCoFunction function = conn.getFunction("Z_READ_UNAME");
             conn.execute(function);
             name = function.getExportParameterList().getString("EV_UNAME");
         }
         catch (final BackendException e)
         {
             e.printStackTrace();
         }
         return name;
     }
 
 
 }
 

Can you please help to point what I am missing in this flow:

PS: I have setup the RFC destination in hmc and the ping also works fine from there.

Pradeep

Accepted Solutions (0)

Answers (6)

Answers (6)

0 Kudos

Hi,

The link falsely ended with a dot. https://answers.sap.com/questions/12759659/sap-jco-integration-issue-spring.html

Thanks, Wesley

0 Kudos

Thank you Pradeep

0 Kudos

Hi Pradeep,

I was wondering if you could help us out with our issue trying to make jco work. We reported an issue in here, https://answers.sap.com/questions/12759659/sap-jco-integration-issue-spring.html. Unfortunately, without a reply.

I explored the forum and I think you could help us out.

Thanks.

0 Kudos

Hi Sagar,

Could you perhaps help us out?

Thanks.

0 Kudos

Hi, The link you provided below doesnt seem to exist. Can you please explain the issue you have? Pradeep

0 Kudos
 below is an extract from the spring xml of the service layer



 <bean id="bpbackend" class="com.trail.be.ZCallSampleSAPRFCBackend" parent="sapCoreBackendObjectJCo">
         <property name="moduleConfigurationAccess" ref="ztrail" />
         <property name="defaultConnectionName" value="JCoStatefulServiceUser" />
         <property name="businessPartner" ref="businessPartner" />
     </bean>
 
     <bean parent="sapCoreModuleConfigurationAccess" id="ztrail">
         <property value="ztrail" name="moduleId" />
     </bean>
 
     <bean id="businessPartner" class="com.trail.beans.BusinessPartner"/>
 
0 Kudos

Hi Sagar,

Yes, I did manage to solve it. You will need a SAP Base configuration as well along with the RFC destination within which you will specify the RFC destn. Then in the Base store configuration you need to add the SAP Base Configuration.

After these configurations, you will need to inject the correct SAP JCO layer beans into your service layer class.

Hope this helps.

Pradeep

0 Kudos

Hi Pradeep, I am also facing the same issue. Can you please let me know the solution if you got one? Thanks, Sagar

Former Member
0 Kudos

Hi,

Can you please check, whether you spring bean definition extends "sapCoreBackendObjectJCo".

It would inject "JCoStateless" value and would try to fetch JCO connection from managedConnectionContainer.

Cheers,

Pavels