1

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.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
piam
  • 653
  • 6
  • 13

4 Answers4

2

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
Ulrich Anhalt
  • 172
  • 2
  • 11
1

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.

jensblond
  • 45
  • 5
1

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

Joseph Le Brech
  • 6,541
  • 11
  • 49
  • 84
  • thank you very much, could you please give me more details about it. – piam Jan 26 '12 at 10:12
  • sap is pretty much a closed platform, you'd have to contact a specialist on the wsdl interface for soap. other than that interfacing WITH it should be a piece of cake with savon. – Joseph Le Brech Jan 26 '12 at 10:16
1

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

emrass
  • 6,253
  • 3
  • 35
  • 57