how to connect to SAP in Ruby on Rails

4.3k views Asked by At

I want to retrieve information from SAP to Ruby on Rails.

I found this one, but I'm confused how to install and use it, can someone explain about? It would be appreciated.

Thank you very much.

4

There are 4 answers

2
Joseph Le Brech On BEST ANSWER

You can use soap with sap, try using this library Savon

0
emrass On

Are you running JRuby? If so, you can easily use SAP JCo (SAP Java Connector) for connecting to RFC-enabled function modules (and BAPIs). There are tons of examples on the web how to use SAP JCo, like this one: http://www.vogella.de/articles/SAPJCo/article.html.

Compared to a web service call using Savon, this should be much more simple

0
jensblond On

At our company "Wer liefert was" we connected the SAP Plattform with our Ruby on Rails Stack through a AMQP Bus with JSON REST APIs.

The Goal was, that we switch off our nightly database import and make an instant update of the items possible.

The problem, that SAP has no native method for adding messages to the AMQP Bus, was solved by a ruby proxy app, which provided a REST API that could be called by SAP after a item was saved. The proxy app than added a message to the AMQP bus that was consumed by an importer script.

The connection from our Rails app was also solved with REST APIs that are provided by the SAP System.

0
Ulrich Anhalt On

I use the library written by Piers Harding. You need to download the nwrfcsdk library from sap and then follow the installation process as shown in the README of ruby-sapnwrfc.

You can call remote enabled sap function modules - for example ENQUEUE_READ like in the following simple example:

#!/usr/bin/env ruby

require 'sapnwrfc'
require 'rubygems'

conn = SAPNW::Base.rfc_connect(:client => '100',
                               :sysnr  => '01',
                               :lang   => 'EN',
                               :ashost => 'host',
                               :passwd => 'pw',
                               :trace  => 0,
                               :user   => 'sapuser')

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 2000 < cnt
  puts "more than 2000 entries"
end
conn.close