Using Perl for SAP RFC – Part 1 – Installing Perl
Perl is a good scripting tools because of its availability across platforms and its vast CPAN library of modules. I wanted a program to query SAP using RFC calls. Microsoft Net requires the WCF LOB Adapter for SAP – which I did not have. So next choice was to look up the Sap::Rfc module for Perl. I was pleasantly surprised to see the NetWeaver RFC gives the Next generation Ruby and Perl Connectors that replaces SAP::Rfc. This new module uses the latest RFC Netweaver SDK and is much easier to use than its predecessor.
However compiling the module on Strawberry Perl was not easy. So I decided to document my experience in this blog.
*If you want to skip these steps, you can download my Perl compilation from the **PI-Monitor site at sourceforge.*
h3. Installing Perl
[Download and install Strawberry Perl | http://strawberryperl.com/releases.html] to C:strawberry. I prefer to use the portable zip file since you can just unzip it to C:strawberry without any side-effects.
h3. Installing the Netweaver RFC SDK
Then: Download -> Support Packages and Patches -> Entry by Application Group ->
Finally: On the page “Support Package and Patches”, choose “Additional Components” -> SAP NW RFC SDK” -> SAP NW RFC SDK 7.10.
- Select your operating system and download the SAR file. (In my case it was NWRFC_2-20002217.SAR).
- You need SAPCAR to uncompress this file. To get SAPCAR (Download->Support Packages and Patches -> Entry by Application Group. Then choose “Additional Components” -> SAPCAR -> SAPCAR 7.10)
- At the command line, uncompress the SAR file
SAPCAR_3-20002090.exe -xvf NWRFC_2-20002217.SARRead notes on compiling NWRFC for Perl
Perl needs a connection to CPAN network to install the modules. Before you can install modules, you need to setup your proxy settings. If you don’t need a proxy, ignore the first HTTP_PROXY command.
set HTTP_PROXY=http://proxyuser:proxypass@proxyhost:proxyport<br />set PATH=C:
wrfcsdklib;C:strawberryc in;C:strawberryperl in;%path%<br />cpan<br />cpan> install sapnwrfc<br />No libsapnwrfc installation found, usually in C:/Program Files/SAP/FrontEnd/SAPg
Which libsapnwrfc build path do you want to link against?* C:/nwrfcsdk</li><li><br />If you get an error “undefined reference to ‘RFC….” – you’ll need to manually modify the Makefile.<br />c:strawberryCPAN uildsapnwrfc-libSAPNWMakefile<br />Find the lines
LDLOADLIBS = and prefix c:
wrfcsdkliblibsapucum.lib <br />From the command line prompt
cd c:strawberryCPAN uildsapnwrfc-
Optionally cpan install Net::Amazon::S3 — if you want to upload files to Amazon S3.