Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

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 http://service.sap.com/connectors. For Linux this must be in /usr/sap/rfcsdk - check that librfccm.so 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/ld.so.conf, 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 http://service.sap.com/connectors.

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
      uby.exe.
    • 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'

to:

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" 🙂

Credits:

  • 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

10 Comments