Connecting SAP in Ruby on Rails

SAPRuby on RailsProgramming

Try downloading nwrfcsdk library from sap and follow instructions mentioned in Readme to perform the installation. Use function Module like ENQUEUE_READ to perform remote call as below −

#!/usr/bin/env ruby
require 'sapnwrfc'
require 'rubygems'
conn = SAPNW::Base.rfc_connect(:client => '800',
                               :sysnr  => '01',
                               :lang   => 'EN',
                               :ashost => 'hostname',
                               :passwd => 'pw',
                               :trace  => 0,
                               :user   => 'username')
sm12 = Hash.new
# lookup the dictionary definition of an Function Module
fds = conn.discover("ENQUEUE_READ")
# create an instance of a Function call
func = fds.new_function_call
func.GUNAME = ""
func.invoke
cnt = func.NUMBER
if 1000 < cnt
  puts "more than 1000 entries"
end
conn.close

In case you are running JRuby, you can use SAP Java Connector to connect to RFC enabled BAPI’s and Function module. Note down following points about SAP Java Connector SAP JCo −

  • SAP Java Connector is a middleware component that can be used for the development of SAP-compatible components and applications in Java. Using SAP JCo, you can set up bidirectional calls to SAP server.
  • You can use SAP Java Connector to connect to desktop applications and with Web server applications.
  • SAP JCo can be used with SAP Business Connector to communicate with external Java applications.
  •  You can also use SAP JCo to integrate Java EE server with the ABAP environment.

You can refer to below link regarding SAP JCo configuration −

SAP Help


raja
Published on 23-Apr-2018 21:12:38
Advertisements