Skip to Content

<!–
.code {
background-color: #E4E5E8 ;
margin-left: 0pt;
}
–>

You’ve got a problem…


You need RFC access to R/3, but your requirement won’t allow you to use
the RFC protocol, so what do you do? Well, one thing you could do is to
use the SOAP-based RFC interface to the Web Application Server, that
comes as standard since 6.10.
This is a great little generic interface for performing RFCs via an HTTP-based SOAP interface.

The handler is found as part of the SOAP service configuration, as
defined in transaction SICF. The ICF path is:
/default_host/sap/bc/soap/rfc.

The service definition then translates into the URL
http://seahorse.local.net:8000/sap/bc/soap/rfc (for my system – insert
your own host name).

Within this, the defined handler list is CL_HTTP_EXT_SOAPHANDLER_RFC.
This class is a native ICF handler that pulls an HTTP request off the
wire, and converts it into a SOAP request, parses it, performs the
associated RFC call, and then parcels up the result as a SOAP Response,
back on to the wire.


Perl, and SOAP::Lite


I have built up a little example here of how you can use Perl, and a
module called SOAP::Lite to create a simple SOAP client.  SOAP::Lite is
the Swiss Army Chainsaw of the SOAP interface world – it has features
for just about anything you can think of from debugging/tracing through
to WSDL, and UDDI.  Because of this, it is not only a great tool for
binding to R/3, but it is invaluable for debugging SOAP implementations.


Example


The example below shows how to build up a request, and make a call to the
RFC_READ_REPORT function module.  I ran this against my NW4 vanilla
implementation – you may need to alter things like the User, and
Password values, as well as the hostname of the HTTP call.

What you need:

Perl – for this example, even win32 should work 😉

The environment I used for this was:

    1. RedHat 9
    2. Perl 5.8.0
    3. SOAP::Lite 0.60, and tested with 0.55
    4. SAP NetWeaver 4 evaluation system, should work with R/3 6.x+


Figure 1. Service configuration in SICF <br/>
image


The complete example:



#!/usr/bin/perl
use Data::Dumper;
#use SOAP::Lite +debug;
#use SOAP::Lite +trace;
use SOAP::Lite;


my $user = ‘developer’;
my $pass = ‘developer’;
my $hostname = ‘seahorse.local.net’; # change this to your target
my $sr = “”;
my $namespace = “rfc:”;
my $muri = “urn:sap-com:document:sap:rfc:functions”;
my $mn = “RFC_READ_REPORT”;

  1. setup the namespace


my $s = new SOAP::Lite->uri( $muri );

  1. define the encoding


$s->encoding(‘ISO-8859-1’);

  1. this is the helper routine for constructing the document


import SOAP::Data ‘name’;

  1. build up the request document


my @parms = ( name( ‘PROGRAM’=> “SAPLGRAP” ), name( ‘QTAB’=> \name(item => \name( LINE => “”))) );
my $methname =  ‘RFC_READ_REPORT’;
my $meth =  $namespace.$methname;
my $element =  $methname.’.Response’;

  1. show the serialized document


$sr = $s->serializer->autotype(0)->readable(1)->method( $namespace.’RFC_READ_REPORT’ => @parms );
print “RFC_READ_REPORT SOAP: $sr\n”;

  1. do the call


my $som =  $s->uri($muri)->proxy(“http://$user:$pass\@$hostname:8000/sap/bc/soap/rfc“)->$meth( @parms );

  1. show the contents of QTAB


print “//Envelope/Body/$element/QTAB \n”;
print Dumper($som->valueof(“//Envelope/Body/$element/QTAB/item/*”));
</pre>
<br/>
The output produced is:


RFC_READ_REPORT SOAP:


<SOAP-ENV:Envelope xmlns:xsi=”http://www.w3.org/1999/XMLSchema-instance
xmlns:SOAP-ENC=”http://schemas.xmlsoap.org/soap/encoding/
xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsd=”http://www.w3.org/1999/XMLSchema
SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/


 

To report this post you need to login first.

6 Comments

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

  1. Gary Morris
    Thanks Piers,
    These posts on PERL and SAP have reminded me why I have been playing around with trying to learn PERL for several years.  I am not a programmer yet. I spend most of my waking hours dealing with SAP Security, but I have so many ideas I want to implement and I am always drawn to PERL as the perfect tool for me. All my needs seem to be met with PERL and now that I have read your examples of using it to communicate with SAP I have almost instantly seen all my ideas come to life. This is going to be so much fun I can’t hardly sleep… (I know what your thinking.. “get a life”..) Well maybe not you, cause your one of us. 🙂
    Thanks Piers, keep it coming.  This is the kind of stuff I can really use, I am not going to be building any Business Applications, but what your showing me is exactly what I need to build the “toolz” for my job. 
    (0) 
    1. Evan Hunt
      I have developed a Metadata repository tool in javascript using SOAP/XMLA and SOAP/RFC to lookup the catalog content and whereused relationships between characteristics, key figures, calculated key figures, structures, restricted key figures and the queries, workbooks and web templates.
      (0) 
  2. Eddy De Clercq
    Hi,

    It’s a great article, but it’s rather tedious in use. What about WSDL? Did you ever got it work?
    We have troubles when it’s used on authentication based server (as yours)?
    Normally, it’s as simple as
    print SOAP::Lite
    ->service(‘https://user:passwd@urlofwsdl‘)
    ->somews(‘param’);
    We always get 401s for it. It seems that the WAS is blocking this access.

    Any comments/suggestions would be very helpful.

    Eddy

    (0) 

Leave a Reply