cancel
Showing results for 
Search instead for 
Did you mean: 

Ruby and Perl NetWeaver RFC Connector

former_member583013
Active Contributor
0 Kudos

This thread follow Piers blog <a href="/people/piers.harding/blog/2007/02/28/netweaver-rfc-gives-the-next-generation-ruby-and-perl-connectors RFC gives the Next generation Ruby and Perl Connectors</a>

Post your comments, troubles and recommendations.

Greetings,

Blag.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Has anyone been able to use the new sapnwrfc connector?

I followed the instructions and has successfully built and installed the sapnwrfc gem (version 0.12). But when I try to test the install with test_connect.rb, I got the following error:

D:\dev\ruby\sap\sapnwrfc-0.12\test>d:\ruby\bin\ruby test_connect.rb

E, [2007-04-20 19:25:05#676] ERROR -- : Could not load nwsaprfc. Make sure nwrfcsdk libraries are properly installed: 14001: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. - d:/ruby/lib/ruby/gems/1.8/gems/sapnwrfc-0.12-i386-mswin32/ext/nwsaprfc/nwsaprfc.so

d:/ruby/lib/ruby/gems/1.8/gems/sapnwrfc-0.12-i386-mswin32/lib/sapnwrfc.rb:163: warning: already initialized constant SAP_LOGGER

E, [2007-04-20 19:25:05#676] ERROR -- : Could not load nwsaprfc. Make sure nwrfcsdk libraries are properly installed: 14001: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. - d:/ruby/lib/ruby/gems/1.8/gems/sapnwrfc-0.12-i386-mswin32/ext/nwsaprfc/nwsaprfc.so

d:/ruby/lib/ruby/gems/1.8/gems/sapnwrfc-0.12-i386-mswin32/ext/nwsaprfc/nwsaprfc.so: 14001: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. - d:/ruby/lib/ruby/gems/1.8/gems/sapnwrfc-0.12-i386-mswin32/ext/nws

aprfc/nwsaprfc.so (LoadError)

from d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:33:in `require'

from d:/ruby/lib/ruby/gems/1.8/gems/sapnwrfc-0.12-i386-mswin32/lib/sapnwrfc.rb:171

from d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:33:in `gem_original_require'

from d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:33:in `require'

from test_connect.rb:7

Any suggestion how to fix the problem? Thanks!

Kenny

Former Member
0 Kudos

I think you need to search through the above thread, and other threads in the forum, as you are looking at the same dependency issues. Use depend.exe to examine nwsaprfc.so to find out what is incorrectly installed on your windows machine.

Former Member
0 Kudos

I have tried depends.exe. The only missing DLL is MSJAVA.DLL (Microsoft JVM). I downloaded it from internet and saved it into my system32 directory. But that didn't fix the problem.

Former Member
0 Kudos

Using Ruby version 1.8.5 and rubygems 0.9.2 and sapnwrfc 0.12 - if I run this at the command line:

[code]

ruby -rrubygems -e 'gem "sapnwrfc"; require "sapnwrfc";'

[/code]

I get this:

[code]

piers@gecko:~/code/ruby/sapnwrfc$ ruby -rrubygems -e 'gem "sapnwrfc"; require "sapnwrfc";'

stderr initialized

piers@gecko:~/code/ruby/sapnwrfc$

[/code]

If you don't get something that (ie. some library load error), then it means that your sapnwrfc, or your nwrfcsdk is not installed properly. If you believe that you have installed the above correctly) including Ruby and rubygems versions) then you must have a library dependency or system path type issue for the libraries being loaded.

Piers.

former_member583013
Active Contributor
0 Kudos

Ok....First problem -:'( I download and install the following gem...

<b>sapnwrfc-0.07-mswin32.gem</b>

Then....I create the .yml file...

[code]

ashost: Huroncebrio

sysnr: "00"

client: "000"

user: bcuser

passwd: minisap

lang: EN

trace: 2

[/code]

Then....My lovely <b>SE16</b> example....

[code]

  1. specify a YAML base config file or pass connection

  2. parameters directly to rfc_connect()

require 'sapnwrfc'

SAPNW::Base.config_location = 'sap.yml'

SAPNW::Base.load_config

conn = SAPNW::Base.rfc_connect

  1. get the system and connection details

attrib = conn.connection_attributes

$stderr.print "Connection Attributes: #{attrib.inspect}\n"

  1. lookup the dictionary definition of an Function Module

fds = conn.discover("RFC_READ_TABLE")

$stderr.print "Parameters: #{fds.parameters.keys.inspect}\n"

  1. create an instance of a Function call

fs = fds.new_function_call

  1. populate the parameters - structures and table

#rows now take hashes of field name/value pairs

fs.IMPORTSTRUCT = { 'query_table' => 'SPFLI',

'delimiter' => '|'}

  1. execute the RFC call

fs.invoke

$Fields = Array.new

$Data = Array.new

$Data_Fields = Array.new

$Data_Split = Array.new

itab.fields.hashRows {|field| $Fields.push(field) }

$Fields_Len = $Fields.length

itab.data.hashRows {|field| $Data.push(field.to_s.strip!) }

$Data_Len = $Data.length

for i in 0...$Data_Len

$Data_Fields = $Data<i>

$Data_Split = $Data_Fields.split("|")

for i in 1...$Fields_Len

print $Data_Split<i>.to_s.strip, "|"

end

print "\n\n"

end

print "Exit"

[/code]

However....I getting the following error...

<i>

cannot load C Ext nwsaprfc.c

</i>

Greetings,

Blag.

Former Member
0 Kudos

OK - by the look of it you might have a dependency problem. Where did you install the SDK with the libraries (that Ulrich put the links up for see the blog post )? The libraries will need to go in your search path - the most straight forward is into the system32 diretory (but I'll defer to those win32 specialists out there).

Cheers.

former_member583013
Active Contributor
0 Kudos

Hi Piers:

I have copied the files in the following locations with the same problem...

<b>

C:\Windows

C:\Windows\System32

C:\Ruby\bin

C:\Ruby\lib

</b>

I even restarted my laptop.... -:'( Any advice or I'm just too dumb to install things without using an Installer....

Greetings,

Blag.

Former Member
0 Kudos

Hi -

do you have the "depends" (I think that is what it is called) utility? If you run it against the nwsaprfc.so lib (installed by the GEM), then hopefully it will say if any of it's dependent libraries/dll are missing.

Cheers.

former_member583013
Active Contributor
0 Kudos

Hi Piers:

I download and use the Dependency Walker, then I copied some missing DLL's...

The problems didn't went out, so I download this

<a href="http://www.liutilities.com/products/campaigns/plib/rbplib/?id=top">Registry Booster</a>

And it fixed a lot of internal problems...But still I need this DLL

<b>DRVADODB.dll</b>

I can't find it on the web...But as I read, it's supposed to a SAP one...I got MiniSap installed, so that maybe why I don't have all the necessary dll's....

Greetings,

Blag.

0 Kudos

Hi Alvaro,

One of the requirements for using the ruby gem is to have the VC 8.0 Runtime installed. It's the most common reason for sapnwrfc not loading. You can find it at MS:

http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displa...

Best regards,

Olivier.

former_member583013
Active Contributor
0 Kudos

Thanks Olivier....But still having the same problem...I need the <b>DRVADODB.dll</b> or at least that's what the Dependency Walker telling me...Or I need to reboot after installing the Visual C++ 2005 Redistributable Package?

Greetings,

Blag.

Former Member
0 Kudos

Please restart, and then perhaps you can show what the dependency chain looks like.

I don't have much experience with win32 development, but I the machine that I tried it on DRVADODB.dll doesnt show in the dependency tree at all (win XP, Office home etc, with complete SAPGUI install).

Cheers.

former_member583013
Active Contributor
0 Kudos

Piers:

This is a picture of my Depends analysis....Hope it helps -:)

<a href="http://singlepath.freecoolsite.com/Depends.jpg">Blag Depends Analysis</a>

Greetings,

Blag.

Former Member
0 Kudos

Hi Alvaro -

YOu are looking at the wrong file - this is the native lib from the old saprfc package - the one that you should be looking for is nwsaprfc.so.

Cheers.

former_member583013
Active Contributor
0 Kudos

Your right Piers...My mistake....This is the correct file and the Depends tree....

<a href="http://singlepath.freecoolsite.com/Depends_2.jpg">Depends Tree</a>

It seems that my DLL files are wrong....Or something like that...

MPR.dll and MSVCR80.dll

Greetings,

Blag.

Former Member
0 Kudos

Right - this is curious, as it looks very much like something to do with the "VC 8.0 Runtime" as Olivier pointed out.

Cheers.

0 Kudos

MSVCR80.dll is one distributed with vcredist_x86 (the VC 2005 Runtime).

Don't worry about DRVADODB.dll. It's a "delay load dll" and I also have some like this in my depends on a working installation.

Best regards,

Olivier

Former Member
0 Kudos

Hi Alvaro -

Can you confirm that you have run the vcredist_x86.exe installer (the latest VC runtime that Olivier pointed to) AFTER you have tried installing the sapnwrfc GEM? This is very important as it will give us a base line to work from.

Cheers,

Piers Harding.

former_member583013
Active Contributor
0 Kudos

Of course Piers...I installed it as Olivier told me....And when I install it, the GEM was already installed to...

Greetings,

Blag.

0 Kudos

Alvaro,

Starting with VC 2005 the runtime dlls are no more found in the search path (System directory). Look at the MSVCRT*.dll locations on my machine:

Directory of C:\WINNT\system32

01/04/2002 08:37 PM 344,064 msvcr70.dll

02/21/2003 05:42 AM 348,160 msvcr71.dll

08/04/2004 09:00 AM 343,040 msvcrt.dll

08/04/2004 09:00 AM 253,952 msvcrt20.dll

08/04/2004 09:00 AM 61,440 msvcrt40.dll

5 File(s) 1,350,656 bytes

Directory of C:\WINNT\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.163_x-ww_681e29fb

06/05/2006 02:14 PM 626,688 msvcr80.dll

1 File(s) 626,688 bytes

Directory of C:\WINNT\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd

09/23/2005 12:29 AM 626,688 msvcr80.dll

1 File(s) 626,688 bytes

Directory of C:\WINNT\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c

09/22/2005 04:48 PM 1,171,456 msvcr80d.dll

1 File(s) 1,171,456 bytes

Directory of C:\WINNT\WinSxS\x86_Microsoft.Windows.CPlusPlusRuntime_6595b64144ccf1df_7.0.0.0_x-ww_2726e76a

08/04/2004 08:00 AM 322,560 msvcrt.dll

1 File(s) 322,560 bytes

Directory of C:\WINNT\WinSxS\x86_Microsoft.Windows.CPlusPlusRuntime_6595b64144ccf1df_7.0.2600.2180_x-ww_b2505ed9

08/04/2004 12:57 AM 343,040 msvcrt.dll

1 File(s) 343,040 bytes

As you can see msvcrt80 dlls are no more placed in the system directory. There are placed in a specific place in WinSxS and registered somewhere in the registry. This can only be done properly if you run the Visual C++ Runtime.

A manifest embedded in the the application describe the dlls the application was built with and is used for the OS to provide the app with the correct dlls. You can put as many msvcrt80.dll around your OS as long as they are not registered properly the module won't work.

Hope this helps,

Best regards,

Olivier.

Former Member
0 Kudos

Hmmm - I've just gone back to your original post, and noticed something. In this example you are doing a direct "require 'sapnwrfc'".

Have you tried modifying this to use gems, as this is what you have installed?

When you use the gem file you should be doing:

require 'rubygems'

require_gem 'sapnwrfc'

Cheers.

Former Member
0 Kudos

I've been reliably informed that require_gem is nolonger needed in version 1.8.5 of Ruby - is this the version that you are using?

Cheers.

former_member583013
Active Contributor
0 Kudos

I'm using 1.8.2 with updated gems, so I got the message telling me that require_gem is obsolete and should be using gem instead....

Could be that I need to upgrade to 1.8.5???

However...I got this simple error....

uninitialized constant SAPNW

I know that SAPNW is a base class, so I don't know what should I initialized it....

Greetings,

Blag.

Former Member
0 Kudos

OK - it would be helpful to upgrade to 1.8.5, but I guess we still need to solve your VC Runtime issues too.

SAPNW is the base namespace - as would normally be defined by the module statement in Ruby. This is created when the C extension nwsaprfc.so is loaded, so this proves that it hasnt been loaded successfully when you get an error about it.

Cheers.