Skip to Content
Technical Articles
Author's profile photo Niels Perfors

SAP Commissions – Python API

Dear all,

In this post I’d like to introduce to you a python package that I wrote and published – python-sapcommissions. A python wrapper for the SAP Commissions REST API.

TL;DR: Check out the package on GitHub: niro1987/python-sapcommissions

A bit about myself

I’ve been working with SAP Commissions for a few years now, and in my work I’ve used the REST API on some occasions. As an example, I have a Power Automate solution that checks daily for specific batch names in Validate and Transfer pipelines via the REST API, and notifies me if none were found. Another to run Comp and Pay, generate reports and notify the team when the new calculation results are available.

The python package

It’s really just a convenience script that wraps around the SAP Commissions REST API and transforms the response to python class objects. To install the package with pip, run the following command:

pip install python-sapcommissions

Import Connection and an endpoint of your choosing. In this example we’ll use Participants.

from sapcommissions import Connection
from sapcommissions.endpoints import Participants

Initialize a new Connection by providing the tenant, environment, username, and password.

prod = Connection("CALD", "DEV", "Username", "Password")

In this example we will use the Participants endpoint to get a list of all participants from the system. The list() method returns a generator object. Convert the generator to a list if you want to retrieve all instances.

participants = Participants(prod).list()

# Convert to list
all_users = list(participants)

# For loop
for participant in participants:
  ...  # Do something

# List Comprehension
participant_ids = [participant.payeeId for participant in participants]

Apart from just reading data from the environment, you can also create, update and delete instances on an endpoint and even run various pipelines. If you’re interested, head over to the full documentation on GitHub: niro1987/python-sapcommissions.

I hope this package can help you to simplify your work as it does mine.


Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Krishna Yeluri
      Krishna Yeluri

      Good one, Niels. This is definitely a handy solution for the Ops.