Skip to Content

Introduction

SAP Cloud for Customer has out of the box OData services in the area of Sales and Services. It provides “c4codata” service definition having standard entities like Account, Opportunities, Leads, Service Request, and Employee etc. In this document we will build a portal widget using SAP Web IDE on HANA Cloud Platform consuming standard OData service “c4codata.svc” of SAP Cloud for Customer. In this application we will read the Opportunity data from SAP Cloud for Customer using basic authentication.

In case your application requires logged in user identity propagation and support of Single-Sign-On (SSO) then you need to setup “OAuth2SAMLBearerAssertion” destination. You can following link for setting up such a destination

https://scn.sap.com/docs/DOC-66705

You can check the C4C OData documentation here.

Note – If the attached pictures are not clear then click on them to open it in a separate dialog box.

Prerequisites

  1. HCP account – you should have access to HCP trial or production account
  2. SAP Cloud for Customer OData service – you should have access to https://<your c4c tenant>/sap/byd/odata/v1/c4codata/$metadata

So let’s get started.

Create the destination

The destination is used by the WebIDE application to make the outbound call to SAP Cloud for Customer OData service. It contains the connection details for the remote communication.

  • Login into HCP trial or production account.

Note – In this example I am using HCP trial account.

  • Switch to account level on your cockpit and click on the Destinations tab

/wp-content/uploads/2015/10/pic1_a_806577.png

  • Click on New Destination & provide details for the destination
    1. a. Name: c4codata
    2. b. Type: HTTP
    3. c. Description: C4C Odata Account
    4. d. URL: https://<your C4C tenant>
    5. e. Proxy Type: Internet
    6. f. Cloud Connector Version: 2
    7. g. Authentication: BasicAuthentication
    8. h. User: <user_name>
    9. i. Password: <pass_word>
    10. j. Also add additional properties along with value as shown in the picture below
    11. k. At the end click on Save

/wp-content/uploads/2015/10/pic2_806578.png

  • As a result you should see now your new destination listed “c4codata”

/wp-content/uploads/2015/10/pic3_802483.png

Create the HTML5 Application using WebIDE

Now let’s create the HTML5 application.

  • Go to the Subscription Tab as shown below and click on “webide” link on the right side page

/wp-content/uploads/2015/10/pic4_a_806595.png

  • It opens up the WebIDE overview page with a link to launch WebIDE in “Application URL”. Click on it to open the WebIDE.

/wp-content/uploads/2015/10/pic5_a_806596.png

  • Create a new project using the File menu. Choose File->New->Project from Template

/wp-content/uploads/2015/10/pic6_a_806606.png

  • It opens the guided wizard with first steps to select a template. For this example we select the “SAP Fiori Master Detail Application” and press Next

/wp-content/uploads/2015/10/pic7_a_806608.png

  • In the second step give the project name. In this example we use the name as “c4copportunitylist” and press Next

/wp-content/uploads/2015/10/pic8_a_806609.png

  • In third step perform following
    1. Select “Service URL” in the Sources list
    2. In the service information section, in “Select a system” drop down choose the destination which we created earler “c4codata”. Pl note unless you define additional properties as mentioned above in the destination your destination will not appear in the drop down.
    3. In the URL text field past the following URL – “/sap/byd/odata/v1/c4codata” and press the arrow button next to it. It should populate the metadata of the odata service in the “Details” section.
    4. Press Next

/wp-content/uploads/2015/10/pic9_a_806610.png

  • In fourth step provide the details for Master Section, Detail Section and Navigation Section. The Master details appear in the left side as a list. Details section and Navigation section comes in the right side as shown in the picture shown below. In this example we are mapping the attributes for Master and Details Section. You will find the detail of the mappings in the next pictures. Do such mapping and proceed to next step

/wp-content/uploads/2015/10/pic10_802491.png

/wp-content/uploads/2015/10/11_a_803646.png

/wp-content/uploads/2015/10/12_a_803647.png

  • In the fifth step confirm your changes by pressing the Finish button. Now a new project “c4copportunitylist”should appear under local folder in WebIDE.

/wp-content/uploads/2015/10/pic13_a_806559.png

  • Expand the project and select the “index.html” and click on “Run” button. A new browser tab should open and your application should run with similar data

/wp-content/uploads/2015/10/pic14_a_806560.png

  • So let’s now make the above application as portal widget so that it can be consumed in Cloud Portal. To do so we need to create an XML file that contains widget specification. To generate specification XML file go to WebIDE menu Tools->Preference->Optional Plugin  and enable SAP “HANA Cloud Portal plugin” and save.

/wp-content/uploads/2015/10/pic15_a_806567.png

  • After saving the preference, don’t forget to refresh the screen else you would not find the menu option to generate the specification xml file. Now go back to development by clicking Tools->Development
  • Right click on the project and click New->Spec XML for Cloud Portal Widget. It open up a wizard for Open Social features

/wp-content/uploads/2015/10/pic16_a_806570.png

  • Select “Compliance with the OpenSocial 0.9 spec” and press Next and Finish

/wp-content/uploads/2015/10/pic17_a_806568.png

  • Now a new spec.xml should get added to you project

/wp-content/uploads/2015/10/pic18_a_806569.png

  • Now deploy the application to HCP using deploy menu option

/wp-content/uploads/2015/10/pic19_a_806571.png

  • Provide credential to log into HCP account and confirm the deployment by pressing Deploy button. Close the successful deployment message and open the HCP cockpit->HTML5 Applications. You should find your “c4copportunitylist” application listed in the table

/wp-content/uploads/2015/10/pic20_a_806572.png

  • Click on the application name and it should open the application overview page. Click on the application URL to open the application in new browser tab to check if the application is running or not. Start it if it is not running. Note down the application URL like for this application

https://c4copportunitylist-c4cpartnerdemo.dispatcher.us1.hana.ondemand.com

/wp-content/uploads/2015/10/pic21_a_806573.png

  • Now open the SAP HANA Cloud Portal by going to HCP cockpit->Services->SAP HANA Cloud Portal->Go to Service

/wp-content/uploads/2015/10/pic22_a_806574.png

  • Go to Content tab. And click on “+ Add Widget”. Keep the type of widget as URL, provide suitable name and description and provide the URL of the application which we noted above. Press save.

/wp-content/uploads/2015/10/pic23_a_806575.png

  • Now the widget should appear in the Content Catalog. You can use it in the Portal site as shown below.

/wp-content/uploads/2015/10/pic24_a_806576.png

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply