Git Product home page Git Product logo

pyrfc's Introduction

PyRFC - The Python RFC Connector

Description

The pyrfc Python package provides Python bindings for SAP NetWeaver RFC Library, for a comfortable way of calling ABAP modules from Python and Python modules from ABAP, via SAP Remote Function Call (RFC) protocol.

Platforms & Prerequisites

The pyrfc has been initially built with Python 2.6 and wheels are provided for Python 2.7 and 3.6, on 64 bit Linux and Windows platform.

OS X and ARM platforms are currently not supported either, as SAP NW RFC Library is not available for those platforms.

On Windows platforms the Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package (KB973544), or newer, must be installed, per SAP Note 1375494 - SAP system does not start after applying SAP kernel patch.

To start using pyrfc you need to obtain SAP NW RFC Library from SAP Service Marketplace, following these instructions.

A prerequisite to download is having a customer or partner account on SAP Service Marketplace and if you are SAP employee please check SAP Note 1037575 - Software download authorizations for SAP employees.

SAP NW RFC Library is fully backwards compatible, supporting all NetWeaver systems, from today, down to release R/3 4.0. You can therefore always use the newest version released on Service Marketplace and connect to older systems as well.

Usage examples

In order to call remote enabled ABAP function module (ABAP RFM), first a connection must be opened.

>>> from pyrfc import Connection
>>> conn = Connection(ashost='10.0.0.1', sysnr='00', client='100', user='me', passwd='secret')

Using an open connection, we can invoke remote function calls (RFC).

>>> result = conn.call('STFC_CONNECTION', REQUTEXT=u'Hello SAP!')
>>> print result
{u'ECHOTEXT': u'Hello SAP!',
 u'RESPTEXT': u'SAP R/3 Rel. 702   Sysid: ABC   Date: 20121001   Time: 134524   Logon_Data: 100/ME/E'}

Finally, the connection is closed automatically when the instance is deleted by the garbage collector. As this may take some time, we may either call the close() method explicitly or use the connection as a context manager:

>>> with Connection(user='me', ...) as conn:
        conn.call(...)
    # connection automatically closed here

Alternatively, connection parameters can be provided as a dictionary, like in a next example, showing the connection via saprouter.

>>> def get_connection(connmeta):
...     """Get connection"""
...     print 'Connecting ...', connmeta['ashost']
...     return Connection(**connmeta)

>>> from pyrfc import Connection

>>> TEST = {
...    'user'      : 'me',
...    'passwd'    : 'secret',
...    'ashost'    : '10.0.0.1',
...    'saprouter' : '/H/111.22.33.44/S/3299/W/e5ngxs/H/555.66.777.888/H/',
...    'sysnr'     : '00',
...    'client'    : '100',
...    'trace' : '3', #optional, in case you want to trace
...    'lang'      : 'EN'
... }

>>> conn = get_connection(TEST)
Connecting ... 10.0.0.1

>>>c.alive
True

Installation & Documentation

For further details on connection parameters, pyrfc installation and usage, please refer to pyrfc documentation, complementing SAP NW RFC Library programming guide and documentation provided on SAP Service Marketplace.

pyrfc's People

Contributors

bsrdjan avatar haserver avatar

Watchers

James Cloos avatar Martin Jonsson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.