Skip to end of metadata
Go to start of metadata

This page contains frequently asked questions (FAQ), related to SAP and scripting languages. Any feedback for extending and improving this list would be greatly appreciated.

General questions


Getting started with scripting languages

Where can I found information about getting started with PHP?

Where can I found information about getting started with Ruby?

Connecting to an SAP backend system

How can I connect to an SAP backend system in a scripting application?

There are several ways to access SAP backend. Two possibilities are via web services or RFC.

  • PHP and RFC
    When working with RFC connections and PHP one must use the SAPRFC library to make a connection to the R/3 or NetWeaver backend system.
    Using SAPRFC
    <?php
    // saprfc-class-library
    require_once("saprfc.php");
    
    // Create saprfc-instance
    $sap = new saprfc(array(
                       "logindata"=>array(
                       "ASHOST"=>"hostname" // application server
                       ,"SYSNR"=>"00"       // system number
                       ,"CLIENT"=>"000"     // client
                       ,"USER"=>"username"  // user
                       ,"PASSWD"=>"xxxxxxx" // password
                       )
                ,"show_errors"=>false       // let class printout errors
                ,"debug"=>false));
    ?>
    
  • PHP and web services
    When working with web service connections the standard PHP SoapClient class or the nusoap package can be used.
    Using PHP's SoapClient
    <?php
    // Create the SoapClient object.
    $client = new SoapClient( 'http://hostname:50000/ServiceNameService/Config1?wsdl');
    
    try
    {
        $result = $client->webMethod(array ('param1'=>$param1val,
                                            'param2'=>$param2val,
                                            'param3'=>$param3val));
    }
    catch( SoapFault $e )
    {
        echo $e->faultstring;
    }
    
  • Ruby and RFC
    When working with RFC connections and Ruby one must use the SAP::Rfc library to make a connection to the R/3 or NetWeaver backend system.
    Using SAP::Rfc
    // sap::rfc-class-library
    require "SAP/Rfc"
    
    // Create sap::rfc-instance
    rfc = SAP::Rfc.new(:ashost => "hostname",
                       :sysnr  => "00".to_i,
                       :lang   => "EN",
                       :client => "000".to_i,
                       :user   => "username",
                       :passwd => "XXXXXXX",
                       :trace  => 1)
    
  • Perl and RFC
    Perl works easily with the SAP RFC. Download the SAP::Rfc or sapnwrfc (RFC SDK supplied by SAP for NW2004+) from CPAN and compile against the appropriate SAP RFC library.
    Using SAP::Rfc
    use SAP::Rfc;
        $rfc = new SAP::Rfc(
                          ASHOST   => 'myhost',
                          USER     => 'ME',
                          PASSWD   => 'secret',
                          LANG     => 'EN',
                          CLIENT   => '200',
                          SYSNR    => '00',
                          TRACE    => '1' );
    
      my $it = $rfc->discover("RFC_READ_TABLE");
    
      $it->QUERY_TABLE('TRDIR');
      $it->ROWCOUNT( 2000 );
      $it->OPTIONS( ["NAME LIKE 'RS%'"] );
    
      # or pass a list of hash refs like so:
      $it->OPTIONS( [ { TEXT => "NAME LIKE 'RS%'" } ] );
    
      $rfc->callrfc( $it );
    
      print "NO. PROGS: ".$it->tab('DATA')->rowCount()." \n";
      print join("\n",( $it->DATA ));
    
      $rfc->close();
    

Since which version are RFC and WS available?

RFC functionality between two SAP systems or between an external system and an SAP system has been available since Release 2.1 of the SAP system. Up to Release 3.0 of the SAP system, RFCs are executed directly using the application server; in later versions, the load can be distributed across application servers by using a pre-activated message server. (source)

What access rights do I need to make RFC calls?

RFC Trusted/Trusting Systems states authorization object S_RFCACL is needed, which can be checked using the AUTHORITY_CHECK_TRUSTED_SYSTEM function module. However, this did not work for me - the SCRIPTUSR apparently does not have this authorization, but is able to make RFC calls.

Introduction to RFC Client Programs states: Logon to an SAP system is possible with a DIALOG user or a CPIC user

What is a BAPI? What is a RFC? What is the difference?

Business Application Programming Interface (BAPI) is a business method defined on a business object inside a SAP system. A Remote Function Call (RFC) is used as the technical way to call this method.

I have a different version of librfc. Can I use it?

The RFC library is downward and upward compatible, so you should be able to use it. We recommend that you use the newest version available for your operating systems. (Source: SAP Note 413708)

Where can I find a list of connectors, which version numbers, functionality, and installation howto, for all supported languages?

List of runtime SAP connectors for scripting languages

Where can I get the 'librfc' library?

In the Service Marketplace: RFC Library. Please also note the mentioned SAP Notes about current version, download location and additional required libraries.

Is the ... connector Unicode-aware?

There are three variants of system connections: if both the client and the server are unicode aware, unicode is used directly. If only one side uses unicode, encoding is done on this side. If neither of the systems use unicode, the client (calling side) is doing the conversion according to the codepages.

  • PHP: the connector requires the non-unicode librfc. open: how well does librfc handle conversions? is this dependend on the php part also?
  • Ruby, Phyton, Perl: open

Do I need the RFC SDK?

No, you don't need the SDK for using the runtime connectors if you're using connectors' binaries. However, if you want to compile it yourself or want to change the connectors get it from http://service.sap.com/swdc -> Download -> Support Packages and Patches -> Additional Components -> SAP RFC SDK.

Does SAP Webservices support all SOAP features?

According to this page the following features are not supported: SOAP Actor, SOAP Encoding, binary Attachments, non-HTTP(s) transport binding.

How can I create my own Webservices?

To create custom Webservices on a SAP backend you can follow these links for Java and ABAP based Webservices.

Which licence I need to use LIBRFC32.DLL in my application?

You can use the librfc without any special license. But the redistribution of the library is not allowed. So if you want to sell your system to other SAP customers, you must not deliver the librfc with your system, but the SAP customers should download the latest version from the SAP Service Marketplace. (source)

Which ports are needed for RFC/WS access? I need to configure my firewall.

This PDF lists all IP Ports used by SAP applications.

SAP Scripting Framework


What is SAP Scripting Framework?

The SAP Scripting Framework is a set of tools that help scripting developers to import SAP backend systems into a repository and then generate backend calls in a number of scripting languages.
For more information, please visit this page: SAP Scripting Framework.
Download is available here: Scripting Languages Tool (Preview)

Scripting in a Box


What is Scripting in a Box?

Scripting in a Box is a package, containing a web server; MySQL database software; scripting runtimes for PHP, Perl, Ruby and Python; Eclipse development environment. All these products can be installed with a single installation procedure and configured easily.
Download is available here: Scripting in a Box.

3 Comments

  1. Anonymous

    You have  shown PHP as webservice friendly but there is one point that needs clarification

    PHP SOAPCLIENT works well for the default sap-client;
    if the user password is for a different client seems to fail

    Say 300 and 600 are 2 SAP-clients and 300 is default;
    WSDL for 600 works but with a user belonging to 600
    I cannot login as there is no provision for specifying sap-client in 

    $client = new SoapClient(
     $wsdl,
     array( "login" => $user,
            "password" => $passwd ) );

    Same thing works fine for users of sap-client 300

    Please help

    Regards
    -jnc

  2. Anonymous

    PHP SOAPCLIENT works well for the default sap-client  and ONLY WSDL 1.1;

    if the user password is for a different client seems to fail

     

    Say 300 and 600 are 2 SAP-clients and 300 is default

    WSDL for 600 works but with a user belonging to 600

    I cannot login as there is no provision for sap-client in

    $client = new SoapClient(

    $wsdl,

    array( "login" => $user,

             "password" => $passwd ) );

     

    Works fine if user belongs to 300(default)       

     

    ===================================================

    PHP SoapClient Does NOT support WSDL 2.0 as generated by ECC6 Wizard

    It only supports WSDL 1.1 as prevailed in 4.7 era; luckily still supported

     

    Read

    http://phpwebservices.blogspot.in/2008/01/what-is-missing-in-php-soap-extension.html

     

    http://wso2.org/project/wsf/php/2.0.0/docs/install_guide.htmlhttp://wso2.com/products/web-services-framework/php/

     

    WS02 PHP Soap does support WSDL 2.0 but I think it best

    a) to stick to SAP PHP RFC

    b) use SOAPCLIENT WSDL 1.1 route

     

    It is time for a official SAP PHP that is as good as JCO!

    Is SAP Listening?

  3. Anonymous

    PHP SOAPCLIENT works well for the default sap-client  and ONLY WSDL 1.1;

    if the user password is for a different client seems to fail

     

    Say 300 and 600 are 2 SAP-clients and 300 is default

    WSDL for 600 works but with a user belonging to 600

    I cannot login as there is no provision for sap-client in

    $client = new SoapClient(

    $wsdl,

    array( "login" => $user,

             "password" => $passwd ) );

     

    Works fine if user belongs to 300(default)       

     

    ===================================================

    PHP SoapClient Does NOT support WSDL 2.0 as generated by ECC6 Wizard

    It only supports WSDL 1.1 as prevailed in 4.7 era; luckily still supported

     

    Read

    http://phpwebservices.blogspot.in/2008/01/what-is-missing-in-php-soap-extension.html

     

    http://wso2.org/project/wsf/php/2.0.0/docs/install_guide.htmlhttp://wso2.com/products/web-services-framework/php/

     

    WS02 PHP Soap does support WSDL 2.0 but I think it best

    a) to stick to SAP PHP RFC

    b) use SOAPCLIENT WSDL 1.1 route

     

    It is time for a official SAP PHP that is as good as JCO!

    Is SAP Listening?