Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Manisha_Rao
Explorer
11,097
Overview

SAP BTP capabilities can be used to expose the data as an API or connect it to a database via python application deployed on the platform. The complete process includes to offer easy app deployment and ETL via known connection details through python codes, allowing the data to be refined as per the usage for further modelling in HANA or DWC.

 

The Prerequisites

  1. BTP Sub-Account

  2. Authorization and Trust Management Service in BTP

  3. Job Scheduling Service in BTP for data integration

  4. Business Application Studio or any Python ide with cloud foundry application installed in the project file


 

Python Application Project Setup

  1. Manifest.yml – This file is first read by BTP and creates the application based on the given services and the same is bind.


        


Fig 1 Sample of Manifest.yml




  1. Runtime.txt – States the runtime environment and its version to use.



Fig 2 Sample of Runtime.txt




  1. Requirements.txt – Used to specify all the python library that is imported in the python file so that the application upon deploying can be installed in the BTP app environment.



Fig 3 Sample of Requirements.txt


 

Data Consumption

Data can be consumed from an open API connection along with right authentication through python code, and from any database tables through standard connectors such as mysql or hdbcli which can be accessible in the python code.

  1. Consumption from API


The API data can be accessed via python scripting where the API is authenticated and then it can be used to send request to get data from the API endpoint.


Fig 4 Sample of API call from Ariba


 

  1. Consumption from Table


Standard connectors such as mysql or hdbcli connector can be used in the python code to connect to database for read or write operations. The sensitive credentials such as username and password can be stored in the user provided variable section of the BTP app.

  • Code to access user provided variables:



Fig 5 Sample of DWC Connection code snippet


 

  • Setting up user provided variables in BTP:



Fig 6: Sample of DWC Connection variables stored in SAP BTP


 

Deployment of Python Application

Deployment to BTP can be done through Cloud Foundry CLI 7.4.0, which is by default available in business application studio (BAS).

In case of any other IDE the CF.EXE file must be available in same folder as manifest.yml and the command prompt of system should also open on same project file.

Step 1: Login to your cloud foundry system using command
cf login

Step 2:

Application deployment done in 2 ways depending on the need.

 

  1. ETL load


For the data load, the application is expected to shut down so that the individual python file can be triggered as and when using job scheduler task.
cf push --task

The task attribute in command represents to shut down the app after deployment.

 

Job Scheduling: In the Job scheduler dashboard create a task. For the same app different ETL files can be added as they are triggered based on python files.


Fig 7: Sample of task creation in Job Scheduler


 

  1. API Creation


For creating the API, flask library can be used in the python code.

The following command is used to deploy the application in BTP.
cf push app_name

In this case, the app continues to be in run state and the data is available in application route URL in SAP BTP. For the same app different API can be created based on the routes set in the flask code.


Fig 8: Sample of created API available in SAP BTP


 

  1. Docker Image for AI-ML


In case of AI-ML codes where the libraries that are used are very RAM effective and would take the BTPs disk usage completely resulting into failure of deployment, Docker image can be created to such use cases and then deploy the app with docker image to run the code smoothly in BTP.

 
cf push app_name --docker-image docker_image_path --docker-username user_name

 

BTP platform provides easy and simple way to utilize the capabilities of python in SAP Environment, with only basic subscriptions and needs of ETL and API creations.

Conclusion

After reading the blog you will have learnt how to deploy the python application in SAP BTP platform for various required purposes such as API creations and ETL. Do let me know in comments if the blog was helpful!

Hope you have enjoyed the blog!

 

Reference

Developing Python in the Cloud Foundry Environment

Create a Python Application via Cloud Foundry Command Line Interface

 
1 Comment
Labels in this area