Skip to Content

Ruby On Rails and SAP

Last August, I wrote a weblog about SAP on Rails, and not on the skids. In a follow up to that I’d like to explain how to import the example into an Eclipse environment called RadRails. RadRails is a specialised Eclipse install that contains a set of plugins for developing native Ruby, and Ruby on Rails applications.

The point of this blog entry is to explain how to import that example into RadRails, thus enabling all the IDE lovers out there to explore the example in their favourite environment.

All kidding aside – RadRails is a nice way to break into Rails development as it aids in visualising how a Rails application holds together.

Getting the necessary packages

The instructions for installation vary according to your OS. I will explain for both Linux, and win32.

The basic breakdown is as follows:

  • Make sure that you have the RFCSDK
  • Install Ruby
  • Install RubyGems
  • Install Rails
  • Install RadRails
  • Import and configure the Exrates example
  • Install SAP::Rfc for Ruby

Install the RFCSDK

Ensure that you have the RFCSDK installed on your platform available from For Linux this must be in /usr/sap/rfcsdk – check that is available in /usr/sap/rfcsdk/lib, and that it can be found at run time (you may have to add /usr/sap/rfcsdk/lib into /etc/, and run ldconfig to do it).

For win32 (I’ve tested this on XP SP2) – make sure that the RFCSDK has been installed correctly, most likely as part of the SAP GUI client install, if you can’t get it from

Install Ruby, RubyGems, and Ruby on Rails

Detailed instructions for installing Ruby On Rails are found on the rails Website. The following is the guide for the impatient:

  • Install Ruby from here – it is *VERY* important to use this version for windows. For Debian: apt-get install ruby1.8 ruby-1.8-dev irb ri (more details here ). For other flavours of Linux, I’m afraid you’ll have to figure that out for yourself, as I use Ubuntu a Debian derivative.
  • Install Ruby Gems – get gems from here, extract the archive, and then from the command line execute “ruby setup.rb” in the zip files root directory.
  • Install Rails – from the command line execute “gem install rails –include-dependencies”
  • For windows users it’s a good idea to reboot now, as not everything that is running will have picked up the new path etc. pointing to ruby

Install RadRails

Make sure you have a working JRE – you can get one from here – I used version 5 update 06.

Obtain and install RadRails – 0.6.2 can be downloaded from here. This is availble as a standalone IDE, and as a Plugin – what I show here is only dealing with the standalone version.

Importing the Exrates example

  • Download the Eclipse project directory for the ExRates example from here. Unpack the archive, somewhere handy.
  • launch RadRails, and when it asks for a workspace, point it at the rails sub directory that was unpacked above.
  • Once the application is launched we need to get some settings right:
    • ruby installation – navigate to Window => Preferences => Ruby => Installed Interpreters. Change the entry “mine” to point to your installed ruby. For windows, this will most likely be C:
      uby in
    • Again, in the preferences panel – set the locations of rdoc, and ri

You should now have a workspace that looks like this:

Installing SAP::Rfc for Ruby

This part is dependent on you successfully installing the RFCSDK above.

If you are running win32 then download the saprfc 0.16 gem and install from the command line with: “gem install saprfc-0.16-mswin32.gem”. Because this is a gem based install, the way that this is loaded into an application for use is different. Because of this you will need to modify SAP4Rails.rb. Navigate to this file in RadRails Exrates/lib/SAP4Rails.rb. change line 3 from: require ‘SAP/Rfc’


require 'rubygems' require_gem 'saprfc'

Under Linux, get the SAP::Rfc software, unpack and follow the build instructions in the README file, which are basically:

ruby extconf.rb make make install

Running the Exrates example

  • Reconfigure the SAP RFC connection information – navigate in the left hand file panel to the config/sap.yml file. Modify the connection setting here, before launching the server, to point to your own R/3 system.
  • Run the ExRates WEBRick server (bottom Servers tab), and then check the console to see if the server started correctly (botton Console tab) – then point browser at http://localhost:3000

You should now see a running server:

Trouble Shooting

If the WEBrick server does not appear to start correctly, then check the console, and the rails/Exrates/server.log, and development.log. Most times the problems are going to be with the ruby, and rails install.

As this example was developed under Linux, I have noticed that the ExratesServer defined in the bottom panel Servers tab of RadRails, needs to be recreated under windows. To do this, highlight the entry, and delete (Red X for “Remove” at top of panel). Then go File => New => Server => WEBRick Server. This should give you a dialog box with Project, Name, and Port – accept the defaults, and try starting the server again.

If there is a problem with the RFC connection, then this will appear on the console log, and further debug information should be available in the rails/Exrates/dev_rfc file.

Wrapping it up

Hopefully, you now have everything up and running – Now all I need to do is to get Craig to add this one into the “Box” 🙂


  • Thanks go to Olivier Boudry, who tirelessly helped out with debugging win32 gem build issues.
  • Thanks also to Craig for picking up the ball and running with it

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Community User
    Well this was the last piece of the puzzle, Python is added and should be available soon for download so the next stop was Ruby. Which you’ve just done a bit more than half the work for me. Now to just do it myself and get it included.

    Thanks Piers!!!!

  2. Scott Barden
    Thanks Piers, I wasn’t aware of RadRails, so far I’ve resisted doing Rails stuff (I’m just an Rails/Ruby newby, your previous article got me interested) on the PC because of a lack of decent editor – been using TextMate on the mac…

    Downloading now. Once I get a bit more comfortable with the basic ActiveRecord stuff, I’ll certainly take a look at how you’ve added SAP integration.


  3. Nathan Leach
    Just curious if you or anyone else has tried using Instant Rails in developing connections to SAP.  On the surface it doesn’t seem like it would be any different, but it’s always the details that matter.  Maybe it’s worthy of a future article?


    1. Piers Harding Post author
      Thats really cool if the base package for Debian is Ruby 1.8.4 (required for Rails 1.1.2).  My Ubuntu 5.10 install doesn’t have it, but bleed Dapper Drake  (Ubuntu 6.06 I think) does (which I have on my other machine).
      Piers Harding.
  4. Srinadh Karumuri
    I tried the Exrates on my windows and it worked on the first run without any issues. I tried the same on our Solaris where SAP R/3 was installed and was unable to run the sample. I found the under the directory /sapmnt/PS8/exe an dadded it to LD_LIBRARY_PATH.
    When I try to compile SAP::Rfc I get bunch of errors starting with:
    saprfc.c:20:20: saprfc.h: No such file or directory
    saprfc.c:21:21: sapitab.h: No such file or directory
    saprfc.c:47: error: parse error before “install_docu”
    saprfc.c:47: error: parse error before “handle”

    Do I need to install SAP client on this Solaris machine?
    Sorry for my ignorance if I missed anything obvious.

    Thank you,


Leave a Reply