Blog Layout

Use case 1: process monitoring

flabouch • Jan 31, 2021

I will not tackle the discussion on where to start the Robot/RPA/Automation journey in this series of blog posts. I will only describe and share use cases we have seen being successful at our customers. I will start with the easiest ones, and increase the complexity. Increasing the complexity not always increase the return on investment, as there are many factor to look at.

In SAP all modules have inter-dependancy, but most of the time in a small-medium size companies, the team are different and organised in silo. therefore one doesn't know the impact of his process on the other team, or at least not fully.

The last two recents case we had was between supply chain and finance, and between customer service and quality team:

  • In the first case, the finance team was doing accruals on the freight cost, based on average price per kg per route and per Incoterms entered by the supply chain team. As you can imagine, the freight cost indication was not always kept up to date, or even not created when a new route was entered in the system, triggering less accurate accruals management by the finance team.
  • In the second case, the customer service had a process in place to send automatically Certificate of Analysis to their customer based on the product and batch, but in some cases the QM team didn't release the document yet and therefore the email was not being generated. Not sending the Certificat of Analysis was triggering issue, and in worse case financial penalty from the customers.

In both case, it is possible to create exception report or some other kind of automatic process directly in SAP. But our customers do not have the in house capabilities, and the return on invest via a full SAP solution was not appealing. Therefore their solution was to have manual check done by each team.

An easy way to perform this monitoring at a very low cost consist on using BAPI/RFC to check the database for specific condition and then generate action. In this case the action was to send an email to the team to let them know that an action was required from them in a specific case (case and reference included in the email).

This can be perform with only few line of code:

  1. Connect to SAP using pyRfc
  2. Execute a request (SQL like) on the database
  3. trigger the email via smtplib

Connect to SAP . You can check previous block post for details:

 conn = Connection(ashost='x.x.x.x', sysnr='XX', client='xx', user='**', passwd='***') 

Execute a Sql like request:

 options = [{'TEXT': "field = 'value'"}]
fields_return = ['field1', 'field2', 'filed3', 'field4']
rows_at_a_time = 100 
rowskips = 0
result = conn.call('RFC_READ_TABLE', QUERY_TABLE = 'table', OPTIONS = options, ROWSKIPS = rowskips, ROWCOUNT = rows_at_a_time, FIELDS = fields_return, DELIMITER=";") 

On the code above, the options variable indicate your filter, for a given field and value.

Fields_return indicate the fields of the table you want as part of the answer from the server.

rows_at_a_time, indicate how many rows max you will get as a result.

rowskips, indicate the rows at which you will start.

Last but not least the RFC call to the table you need and with the different parameters.

Once done you only need to parse the result and generate the email via smtplib or any other way you would like.

I need to admit I am not a huge fan of using RFC_READ_TABLE as there are couple of flows, but it is very handy for small dataset and simple query.

In both mentioned use cases the cost of development and run is offset in less than a month.

SII Spain Integration thru API
14 Jul, 2023
SII in Spain: What is it, why does your company need to comply, and how to do it?
Integrating VIES VAT Validation with your ERP
By flabouch 19 May, 2022
How to integrate and automate VIES VAT number validation of EU commission with your ERP.
SAP Idoc parser python library
By flabouch 12 May, 2022
SAP Idoc parser in Python
Share by: