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

<!--
.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 :wink:





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/>







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

 
6 Comments