Prerequisites from BTP Side
SAP BTP AccountAccess to SAP Business Technology Platform (BTP) with appropriate entitlements.SAP Cloud Connector SetupSAP Cloud Connector installed and configured to connect your on-premise S/4HANA system to SAP BTP.Destination configured in BTP cockpit pointing to your on-premise system.Connectivity Service and Destination ServiceSAP BTP Connectivity service and destination service instance on the BTP account.Cloud Foundry EnvironmentCloud Foundry space set up in your BTP subaccount to deploy the application.
Use Case:
Lets take a simple use case for creating a RAP service on S4, which is a wrapper API call on the reprocess IDOC function module.
For this we will create a RAP service on the S4 box, than activate the service with the /IWFND/MAINT_SERVICE and activate the ICF Node as well.
Note: In this blog we will not go through the steps of setting cloud connector and destination on the BTP account. We will assume that destination with cloud connector setup is already available on the BTP.
Step 1: Create and activate the RAP service on the S4 Box.
We will create a unmanaged rap scenario with custom entity and than we will create a service definition and top of service definition we will create service binding.
Lets create the class for the query implementation.
We are calling the FM to reprocess the idoc and checking the relevant table to get the latest reprocessed idoc status for the same.
Now we will create a service definition and service binding for the custom entity created.
Service Definition
And overall project will look something like this.
Here i have created two types of service bindings v2 and v4 but we will be using only v2 for this.
So overall we created below 4 artifacts.
1. Custom entity
2. Class
3. Service definition
4. Service binding
Now to test the service we will publish the service first and than call the generated url
if you see the image, i have published the service and after publish we also got the custom entity that we have created, click on the service url and it will open in browser asking for authentication of S4 user id and password.
Once the authentication is successful you should be able to see this.
Now lets open the SAP GUI so that i can show you the ICF node activation, which is generally taken care by basis team.
Open the Tcode: /IWFND/MAINT_SERVICE
Here you can find your activated service binding and make sure all components of the service looks as it is in the image.
Assuming cloud connector and destination is setup on BTP.
With this we completed the S4 box setup, now its ready to communicate with other external systems.
Step 2: Creating the Destination service and Connectivity service on the BTP Account.
Login in to BTP account and lets create 2 service instances with service keys.
1. Destination service, this will help us to get the destination details, Destination service gets all the registered destinations on the BTP, from which we can filter out the destination that is up for our S4 onprem box.
Destination service will give us all the relevant things like user id passwd, location and etc. for that destination.
Service key for the destination service
2. Connectivity Service, Since we are trying to get the data out of onprem system we will have to use connectivity service from btp, which will provide us proxies, this proxies will be use to call the onprem odata url.
It is important to paste here the service keys for better understanding since we will be using many things from the service key into our application
Step 3: Lets create a python application to call the onprem service.
Important things to consider here.
By using destination and connectivity service we cannot test the application on local system, we will have to deploy our app on CF to test the same.
We will use the flask requests and certain other libraries for the python programming
file: .env file to store all the secrets this secrets are from the service keys only.
File: Requirements.txt
File: Runtime.txt
python-3.11.*
file: manifest.yaml
file:idocapis.py (should be same as mentioned in Manifest.yml file
Load all the required libraries.
define the function to get the token
Define function to get the list of all destinations on the BTP
Define the function to construct the URL for the odata call
Define function to get token for the connectivity service
Define function to call the odata service with connectivity things
Now lets define the final route in flask to call this service
One thing to note here the RESOURCE variable will depend on the destination url of the onprem that is setup on BTP.
STEP 4: Deployment
Lets deploy the app on the CF by pushing the app to the cloud foundry from the BAS
Use command cf push after successful authentication for your cloud foundry space.
After the deployment on the cloud we can get the url that is generated on the cloud.
Testing the application:
Lets create a small python program to call this API in local now to test it.
You should get response coming from your S4 onPrem system.
Thanks for staying till the end!!!😊
Prerequisites from BTP SideSAP BTP AccountAccess to SAP Business Technology Platform (BTP) with appropriate entitlements.SAP Cloud Connector SetupSAP Cloud Connector installed and configured to connect your on-premise S/4HANA system to SAP BTP.Destination configured in BTP cockpit pointing to your on-premise system.Connectivity Service and Destination ServiceSAP BTP Connectivity service and destination service instance on the BTP account.Cloud Foundry EnvironmentCloud Foundry space set up in your BTP subaccount to deploy the application.Use Case:Lets take a simple use case for creating a RAP service on S4, which is a wrapper API call on the reprocess IDOC function module.For this we will create a RAP service on the S4 box, than activate the service with the /IWFND/MAINT_SERVICE and activate the ICF Node as well.Note: In this blog we will not go through the steps of setting cloud connector and destination on the BTP account. We will assume that destination with cloud connector setup is already available on the BTP. Step 1: Create and activate the RAP service on the S4 Box. We will create a unmanaged rap scenario with custom entity and than we will create a service definition and top of service definition we will create service binding.Lets create the class for the query implementation. We are calling the FM to reprocess the idoc and checking the relevant table to get the latest reprocessed idoc status for the same.Now we will create a service definition and service binding for the custom entity created.Service DefinitionAnd overall project will look something like this.Here i have created two types of service bindings v2 and v4 but we will be using only v2 for this.So overall we created below 4 artifacts.1. Custom entity2. Class3. Service definition4. Service bindingNow to test the service we will publish the service first and than call the generated urlif you see the image, i have published the service and after publish we also got the custom entity that we have created, click on the service url and it will open in browser asking for authentication of S4 user id and password.Once the authentication is successful you should be able to see this.Now lets open the SAP GUI so that i can show you the ICF node activation, which is generally taken care by basis team.Open the Tcode: /IWFND/MAINT_SERVICEHere you can find your activated service binding and make sure all components of the service looks as it is in the image.Assuming cloud connector and destination is setup on BTP.With this we completed the S4 box setup, now its ready to communicate with other external systems.Step 2: Creating the Destination service and Connectivity service on the BTP Account.Login in to BTP account and lets create 2 service instances with service keys.1. Destination service, this will help us to get the destination details, Destination service gets all the registered destinations on the BTP, from which we can filter out the destination that is up for our S4 onprem box.Destination service will give us all the relevant things like user id passwd, location and etc. for that destination.Service key for the destination service2. Connectivity Service, Since we are trying to get the data out of onprem system we will have to use connectivity service from btp, which will provide us proxies, this proxies will be use to call the onprem odata url.It is important to paste here the service keys for better understanding since we will be using many things from the service key into our applicationStep 3: Lets create a python application to call the onprem service.Important things to consider here.By using destination and connectivity service we cannot test the application on local system, we will have to deploy our app on CF to test the same.We will use the flask requests and certain other libraries for the python programmingfile: .env file to store all the secrets this secrets are from the service keys only. File: Requirements.txtFile: Runtime.txtpython-3.11.*file: manifest.yamlfile:idocapis.py (should be same as mentioned in Manifest.yml fileLoad all the required libraries.define the function to get the tokenDefine function to get the list of all destinations on the BTPDefine the function to construct the URL for the odata callDefine function to get token for the connectivity serviceDefine function to call the odata service with connectivity thingsNow lets define the final route in flask to call this serviceOne thing to note here the RESOURCE variable will depend on the destination url of the onprem that is setup on BTP. STEP 4: DeploymentLets deploy the app on the CF by pushing the app to the cloud foundry from the BASUse command cf push after successful authentication for your cloud foundry space.After the deployment on the cloud we can get the url that is generated on the cloud.Testing the application:Lets create a small python program to call this API in local now to test it.You should get response coming from your S4 onPrem system.Thanks for staying till the end!!!😊 Read More Technology Blog Posts by Members articles
#SAP
#SAPTechnologyblog