Skip to Content
Technical Articles
Author's profile photo Krishna Chaitanya Nandimandalam

SAP SAP S/4HANA integration with SAP Conversational AI Chatbot using MS Teams App Studio – Part 2

Hello Experts,


Wishing you a very Happy new year!

Hope you have already been through the first part of this blog post series.

In this series, we will do an end to end integration from the S/4 Hana system to SAP Conversational AI Chatbot and then access the chatbot from the MS Teams. we will access the Purchase Order, Purchase Requisition and Sales Order header details using the Chatbot via the Teams Application. For a detailed overview do check the first part.

For now let’s quickly dive in to the technical details.

Agenda for the blog post:

  • Activate standard OData service for PO and PR OData service.
  • Create a basic CDS view to be exposed as SO OData Service.
  • Cloud connector configuration


  1. Access to S/4 Hana system (preferably S/4 Hana 1709 and above)
  2. Purchase Order – Standard OData service MM_PUR_PO_MAINT_V2_SRV should be activated
  3. Purchase Requisition – Standard OData service MM_PUR_PR_PROFNL_MAINTAIN_SRV should be activated 
  4. S/4 Hana system with the OData Service as mentioned above.
  5. Access the Community edition of SAP CAI Chatbot
  6. Local setup of eclipse with ADT plugin installed.
  7. Basic understanding ABAP project and CDS view creation in the Eclipse.

Ensure the below URLs are working fine for your system,

Caution : – Make sure you replace your system HOST, PORT, PURCHASEORDERNUMBER and PURCHASEREQUISITIONNUMBER in the provided URL Link.  

Purchase Order URL: https://HOST:PORT/sap/opu/odata/sap/MM_PUR_PO_MAINT_V2_SRV/C_PurchaseOrderTP(PurchaseOrder=’PURCHASEORDERNUMBER‘,DraftUUID=guid’00000000-0000-0000-0000-000000000000’,IsActiveEntity=true) 

Purchase Requisition URL:  https://HOST:PORT/sap/opu/odata/sap/MM_PUR_PR_PROFNL_MAINTAIN_SRV/C_PurchaseReqnHeader(PurchaseRequisition=’PURCHASEREQUISITIONNUMBER‘,DraftUUID=guid’00000000-0000-0000-0000-000000000000’,IsActiveEntity=true) 

Sales Order: For Sales Order Header details, let’s create custom OData service on VBAK table, we will perform the below steps: 


Create a new Data Definition in the eclipse and name it zsapbot01. Copy the below code to the newly created file. 

@AbapCatalog.sqlViewName: 'ZSAPBOT001'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales Order Details and Post'
@Metadata.allowExtensions: true

@ObjectModel.modelCategory: #BUSINESS_OBJECT
@ObjectModel.compositionRoot: true

@ObjectModel.transactionalProcessingEnabled: true
//@ObjectModel.writeDraftPersistence: 'zvbak'
//@ObjectModel.draftEnabled: true
@ObjectModel.writeActivePersistence: 'vbak'
@ObjectModel.createEnabled: true
@ObjectModel.updateEnabled: true
@ObjectModel.deleteEnabled: true

@OData.publish: true

//@ObjectModel.writeActivePersistence: 'zsapbot01'

define view zsapbot01 as select from vbak as so
    association [1..1] to vbkd as _businessData on $projection.vbeln = _businessData.vbeln and _businessData.posnr = '000000' {
    key so.vbeln,


For annotation file, create a new Metadata Extension file and name it as zsapbot01. Copy the below code to the newly created file. 

@Metadata.layer: #PARTNER
annotate view zsapbot01
    @UI:{ selectionField: [{ position: 10 }],
        lineItem: [ { position: 10 } ],
        identification: [ { position: 10 } ],
        identification: [ { label: 'VBELN' } ]
    @UI:{ lineItem: [ { position: 20 } ],
        identification: [ { position: 20 } ],
        identification: [ { label: 'CONFIRMED' } ]
    @UI:{ lineItem: [ { position: 40 } ],
        identification: [ { position: 40 } ],
        identification: [ { label: 'RECOVERED' } ]
    @UI:{ lineItem: [ { position: 50 } ],
        identification: [ { position: 50 } ],
        identification: [ { label: 'DECEASED' } ]
    @UI:{ lineItem: [ { position: 30 } ],
        identification: [ { position: 30 } ],
        identification: [ { label: 'CASE TODAY' } ]
    @UI:{ lineItem: [ { position: 60 } ],
        identification: [ { position: 60 } ],
        identification: [ { label: 'DECEASED' } ]

Once done activate both the views. After activation, check if the OData service “ZSAPBOT01_CDS” is activated in the SICF tcode. If yes, we need to register the CDS based OData service “ZSAPBOT01_CDS” in /iwfnd/maint_service . Once done we need to test the Sales Order OData service using the below url.

Caution:- Open the below url in browser (replace HOST, PORT and SALESORDERNUMBER with the values of host, port and a valid Sales Order Number). 


Once we have activated the OData service, we need the Cloud connector to ensure our Cloud foundry trial account has access to this service. 

Let us configure the cloud connector: 

Prerequisites for the same are as follows: 

Let us start with the SAP Cloud connector setup: 

  1. Login to SAP Cloud connector > Open SAP Cloud Connector using the URL > Enter the user name and password and click Login
  2. Click the button “Add Subaccount”Click%20the%20button%20Add%20Subaccount
  3. Add subaccount window/page is displayed and to fill this page we need to go the SAP BTP trial account  Create%20Subaccount
  4. Open the SAP BTP Trial account and > click on the Enter Your Trial Account and then > click on the trial subaccount as depicted in the image belowEnter%20details%20in%20the%20Add%20Subaccount%20window
  5. For the details to be entered in the Add subaccount page/popup window, please find the screenshot below > Region and Subaccount to be entered as per the mapping > Display Name: enter “caibot” > Login E-mail and Password: Enter the SAP BTP trial account Email and passwordLocation ID: Enter “sapcai” > Click Save
  6. The Subaccount has been added and is visible in the subaccount dashboard. Now we have successfully established trust between the SAP cloud connector and the SAP BTP trial account. In the next steps we will add the systems to be exposed using the SAP Cloud connector. (ensure your SAP Cloud connector always remains inside your company domain)
  7. Select the subaccount “caibot” in the displayed field 
  8. Click on “Cloud To On-Premise” in the left side panel as highlighted below 
  9. Go to access control tab as in the above image and add a system in the “Mapping Virtual To Internal System” by clicking the + button
  10. Select the backend type and the protocol as http or https as per the onPrem configurations.
  11. Provide the internal host and port number. Check TCode SMICM for the same or connect with the Basis team for this.Internal%20Host%20and%20port%20number%20%28check%20with%20basis%20team%20for%20the%20same%29
  12. Provide the virtual host and the port. Though we can provide any value for virtual host and port but in order to reduce complexity lets keep the value of virtual host same as internal host and virtual port same as the internal port. The virtual host and port will be used in the Destinations ( to be created in the next blog) using which the OData can be consumed in the node JS application.
  13. Click Finish to create a mapping successfully and you can see the same in the Mapping (Mapping virtual to internal system) table. Now the backend SAP system has been successfully added.
  14. Repeat steps 8 -13 for any other system to be added.
  15. Though the system has been added the status is not coming green yet. For the same, select a line item from the Mapping Virtual to Internal System (Mapping) table and click the + button on the Resources table just below the Mapping table
  16. Add Resource window will popup, enter the details as displayed in the image below and click the save button.
  17. Once done check the status of connection via the highlighted button in the actions column, if successful the status will come as green




Solution Diagram

We are now at the end of this blog post. During the course of this blog post we have successfully identified and activated OData service for PO and PR. For SO we have create a custom CDS view to exposed as an OData Service. registered the same in /iwfnd/maint_service. Since the service is available inside the company domain only, we have configured the SAP Cloud Connector (SCC) to expose the service to the SAP BTP trial account.

In the next blog post we will create destinations using which we can consume the OData service in SAP BTP applications. For the same we need to create Connectivity and Destination instance. Once done we will create a node JS application to consume the OData service and expose it as a public API.

Feedback :

Thanks for taking your time to go through this article, we hope you liked the content. We would appreciate, if you can spare few minutes to leave us feedback on your experience.


See you in the next part of this blog post 🙂 🙂

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Paul PINARD
      Paul PINARD

      Thanks for sharing your knowledge! 👍Looking forward to the next one!

      Author's profile photo Prasad Dixit
      Prasad Dixit

      Very informative.  Good blog. Looking for the next one.

      Author's profile photo Alok Ranjan
      Alok Ranjan

      Thanks for the detailed steps, looking for next part.