It took me some time to get a working Perl module sapnwrfc to call RFC capable SAP function modules within Perl. Several tries with different software versions (ActiveState Perl, StrawBerry Perl 32 vs. 64 bit, SAP NW RFC SDK and different compilers like MinGW and Microsoft C compiler) were not successfull. With the following steps I succeeded finally. 🙂

 

Install a current Strawberry Perl 64 bit package from http://strawberryperl.com. In my case it was 5.24.1.1.

Download the current version of the SAP NW RFC SDK x64 bit from https://launchpad.support.sap.com/#/softwarecenter

You can find it with the following categories:

Support Packages and Patches => By Category => Additional Components => SAP NW RFC SDK => SAP NW RFC SDK 7.20

In my case the current version was 7.20 PL42 x64.

Extract the downloaded file with sapcar -xvf NWRFC_42-20004568.SAR

I renamed the folder to C:\nwrfcsdk_x64.

Create .def and .a files for the MinGW compiler / linker with the following commands in the directory C:\nwrfcsdk_x64:

gendef *.dll
dlltool –dllname icuin34.dll –def icuin34.def –output-lib icuin34.a
dlltool –dllname icudt34.dll –def icudt34.def –output-lib icudt34.a
dlltool –dllname icuuc34.dll –def icuuc34.def –output-lib icuuc34.a
dlltool –dllname libsapucum.dll –def libsapucum.def –output-lib libsapucum.a
dlltool –dllname libicudecnumber.dll –def libicudecnumber.def –output-lib libicudecnumber.a
dlltool –dllname sapnwrfc.dll –def sapnwrfc.def –output-lib sapnwrfc.a

 

Start command prompt with cmd.exe and start the program cpan.

Start the command get sapnwrfc to download the Perl module sapnwrfc from CPAN.

Leave the cpan environment with the exit command. Change directory to C:\Strawberry\cpan\build\sapnwrfc-0.37-0.

Build the Makefile(s) with the following command. Adapt the folder names according to your setup.

perl Makefile.PL –source=C:\nwrfcsdk_x64 –addlibs “C:\nwrfcsdk_x64\lib\sapnwrfc.a C:\nwrfcsdk_x64\lib\libsapucum.a”

 

Use a simple example like from http://search.cpan.org/dist/sapnwrfc/sapnwrfc-cookbook.pod to test the installation:

use strict;
use warnings;
use utf8;
use sapnwrfc;

SAPNW::Rfc->load_config('sap.yml');
my $conn = SAPNW::Rfc->rfc_connect;

my $rd = $conn->function_lookup("RPY_PROGRAM_READ");
my $rc = $rd->create_function_call;
$rc->PROGRAM_NAME("SAPLGRFC");

eval {
$rc->invoke;
};
if ($@) {
    die "RFC Error: $@\n";
}

print "Program name: ".$rc->PROG_INF->{'PROGNAME'}."\n";
my $cnt_lines_with_text = scalar grep(/LGRFCUXX/, map { $_->{LINE} } @{$rc->SOURCE_EXTENDED});
$conn->disconnect;

 

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply