Skip to Content
avatar image
Former Member

Connect to R/3 with the connector framework

Hi,

I am trying to call a RFC function from R/3 using the new connector framework instead of JCO.

However, I'm not quite sure how to create complex data type for the input parameters. I get the parameter structure but I don't know how to create the IRecordSet object to send in the input parameters record.

Any help would be appreciated.

Thank you.

Regards,

Rui Gonçalves

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Dec 21, 2003 at 06:37 PM

    Check the JCO examples.

    It is the same. Sap CF just offers the connection management.

    BR,

    Oliver

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Sure...

      public static IConnection getConnection(String sapSystemAlias,

      IPortalComponentRequest componentRequest)

      throws IllegalArgumentException {

      // check if passed attributes are null

      if (componentRequest == null) { throw new IllegalArgumentException(

      "IComponentRequest object can not be null!"); }

      if (sapSystemAlias == null) {

      // use default system alias

      //sapSystemAlias = defaultSAPSystemAlias;

      }

      ILogger logger = PortalLog.getLogger();

      com.sap.security.api.IPrincipal user = componentRequest.getUser();

      Locale locale = componentRequest.getLocale();

      ConnectionProperties properties = new ConnectionProperties(locale, user);

      IConnection connection = null;

      try {

      IConnectorGatewayService connectorGatewayService = (IConnectorGatewayService) PortalRuntime

      .getRuntimeResources().getService(IConnectorService.KEY);

      connection = connectorGatewayService.getConnection(sapSystemAlias,

      properties);

      } catch (Exception e) {

      logger.severe(e, "Exception while creating a connection.");

      }

      return connection;

      }

      It makes also sense to have a central method to close connections...

      public static boolean closeConnection(IConnection connection) {

      boolean succesful = false;

      if (connection != null) {

      try {

      connection.close();

      succesful = true;

      } catch (ResourceException re) {

      PortalLog.getLogger().severe(re,

      "Connection to SAP could not be closed!");

      }

      }

      return succesful;

      }

      and interactions...

      public static boolean closeInteraction(IInteraction interaction) {

      boolean success = false;

      if (interaction != null) {

      try {

      interaction.close(); // close interaction

      success = true;

      } catch (Exception e) {

      String message = "Exception closing interaction.";

      PortalLog.getLogger().severe(e, message);

      }

      }

      return success;

      }

      Regards,

      Kai

      Message was edited by: Kai