Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SAP Fiori Odata Service Creation


  • SAP Fiori apps use OData to display and update data in back-end server (SAP or Non-SAP).
  • OData (Open Data Protocol) is a standardized protocol for creating and consuming data APIs.
  • OData builds on core protocols like HTTP and commonly accepted methodologies like REST.
  • Odata supports message formats like JSON, XML.
  • OData provides definitions for:
    • Simple Types
    • Complex Types
    • Associations between entries
    • Navigation Paths between entries
    • Custom behavior (known as function imports) beyond the standard QUERY, CREATE, READ, UPDATE, DELETE (QCRUD) operations
  • Here we see how to create a Odata-Service which consumes RFC of SAP-R3 (Back-end) server.
  • This is a example of business scenario where we need to display/update data of SAP-R3 (Back-end) server in SAP UI5 Application. Then SAP UI5 Applcation consumes Odata-Service which in-turn consumes RFC of SAP-R3.
  • This blog is part of below parent blog:
    • SAP Fiori App Implementation: Custom apps

Steps to create OData service (which consumes RFC):

This is example to consume RFC in Odata-Service.

Functionality of RFC is like on invoke it returns MARA table details

  1. Pre-requisites:
    • RFC of SAP-R3 (back-end) system
    • In SAP-Fiori (front-end) system:
      • One RFC-Destination connecting to SAP-R3 (back-end) System
      • T-code    ‘SEGW’
  2. Go-to t-code ‘SEGW’ -> click on icon ‘Create Project’
  3. Enter details as shown in screen
  4. Click ‘ok’ icon, OData project gets created
  5. Now we need to create a “Entity-Type” which is meta structure to hold RFC table output
    • Select ‘Entity-Types’ -> right click -. ‘Create’
    • Enter names as per input.
    • here ‘Entity Type’ is like Data Type and  ‘Entity Set’ is like variable of Data Type.
    • With ‘Entity Set’ name we consume ODataService in UI5 App
    • Click ‘Ok’ icon
    • Now, add column (property) in ‘Entity Type’
    • Double Click on Properties -> In center panel click on ‘Append Row’ icon to add new elements
    • For example purpose, we need only two column details Material Number and its Type, then create two elements
    • And mark ‘Material’ as a key element
    • Now Save and click on icon ‘Generate Runtime Objects’,
    • Click ok in next pop-up
    • Enter package details
    • as a success below screen should appear
  6. Redefine EntitySet method to consume RFC
    • Once Meta structure is been defined, next is to consume RFC
    • For that go to ‘Service Implementation’ -> ‘*_DPC_EXT’
    • ‘_DPC_EXT’ has method ‘_GET_EntitySet’ which we need to Re-Define, for same we can follow below screen
    • Once method gets re-defined, we can see it in folder Redefinitions.
    • Now in ‘_GET_EntitySet’ method we need to do some ABAP Code logic
      • When SAP UI5 Application calls this OdataService with this EntitySet name i.e. ‘MateriallistSet’, GET_ENTITYSET method gets invoked.
      • Here we can write logic to call RFC of SAP-R3 (Back-end) server.
      • RFC returns output in table format, which we need to map structure of OData-Entity-Type ‘Materiallist’
      • Below code can be written for same:
              ls_Material  TYPE          ZCL_ZTEST_ODATA_DPC_EXT=>TS_MATERIALLIST,
        * Calling SAP R3's RFC via RFCDestination
          GT_MARAITEM    =  lt_Material
        IF SY-SUBRC EQ 0.
        LOOP AT lt_Material INTO ls_Material. 
         APPEND  ls_Material TO ET_ENTITYSET.  "Map output to Service's Entity structure
         Clear ls_Material.
    • Now activate the ‘GET_ENTITYSET’ method and ‘_DPC_EXT’.
  7. Thus, a OData Service has been created, which consumes RFC of back-end system.
  8. Now next is to register the Service for same, we can follow below link:
    • SAP Fiori Odata Service Registration & Activation
  9. Once service gets registered, it can be consumed in SAP UI5 Application for display/upload of back-end data.

This post first appeared on Web Service Testing A Blackjack GUI And API, please read the originial post: here

Share the post

SAP Fiori Odata Service Creation


Subscribe to Web Service Testing A Blackjack Gui And Api

Get updates delivered right to your inbox!

Thank you for your subscription