how to create odata services for analytic queries.pdf

Upload: kandasami

Post on 01-Jun-2018

257 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    1/32

    SAP NetWeaver

    How-To Guide

    How to Create OData Service for

    Analytic Queries

    Applicable Releases:

    SAP NetWeaver Gateway 2.0

    Version 1.0

    December 2012

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    2/32

    i

    Copyright 2012 SAP AG. All rights reserved.

    No part of this publication may be reproduced or transmitted in anyform or for any purpose without the express permission of SAP AG.The information contained herein may be changed without priornotice.

    Some software products marketed by SAP AG and its distributors

    contain proprietary software components of other software vendors.

    Microsoft, Windows, Excel, Outlook, PowerPoint, Silverlight, andVisual Studio are registered trademarks of Microsoft Corporation.

    IBM, DB2, DB2 Universal Database, System i, System i5, System p,System p5, System x, System z, System z10, z10, z/VM, z/OS,OS/390, zEnterprise, PowerVM, Power Architecture, Power Systems,POWER7, POWER6+, POWER6, POWER, PowerHA, pureScale,PowerPC, BladeCenter, System Storage, Storwize, XIV, GPFS,HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, AIX,Intelligent Miner, WebSphere, Tivoli, Informix, and Smarter Planetare trademarks or registered trademarks of IBM Corporation.

    Linux is the registered trademark of Linus Torvalds in the UnitedStates and other countries.

    Adobe, the Adobe logo, Acrobat, PostScript, and Reader aretrademarks or registered trademarks of Adobe Systems Incorporated

    in the United States and other countries.

    Oracle and Java are registered trademarks of Oracle and its affiliates.

    UNIX, X/Open, OSF/1, and Motif are registered trademarks of the

    Open Group.

    Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame,

    VideoFrame, and MultiWin are trademarks or registered trademarks

    of Citrix Systems Inc.

    HTML, XML, XHTML, and W3C are trademarks or registered

    trademarks of W3C, World Wide Web Consortium, Massachusetts

    Institute of Technology.

    Apple, App Store, iBooks, iPad, iPhone, iPhoto, iPod, iTunes, Multi-

    Touch, Objective-C, Retina, Safari, Siri, and Xcode are trademarks orregistered trademarks of Apple Inc.

    IOS is a registered trademark of Cisco Systems Inc.

    RIM, BlackBerry, BBM, BlackBerry Curve, BlackBerry Bold,

    BlackBerry Pearl, BlackBerry Torch, BlackBerry Storm, BlackBerry

    Storm2, BlackBerry PlayBook, and BlackBerry App World are

    trademarks or registered trademarks of Research in Motion Limited.

    Google App Engine, Google Apps, Google Checkout, Google Data

    API, Google Maps, Google Mobile Ads, Google Mobile Updater,

    Google Mobile, Google Store, Google Sync, Google Updater, Google

    Voice, Google Mail, Gmail, YouTube, Dalvik and Android are

    trademarks or registered trademarks of Google Inc.

    INTERMEC is a registered trademark of Intermec TechnologiesCorporation.

    Wi-Fi is a registered trademark of Wi-Fi Alliance.

    Bluetooth is a registered trademark of Bluetooth SIG Inc.

    Motorola is a registered trademark of Motorola Trademark Holdings

    LLC.

    Computop is a registered trademark of ComputopWirtschaftsinformatik GmbH.

    SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAPBusinessObjects Explorer, StreamWork, SAP HANA, and other SAPproducts and services mentioned herein as well as their respectivelogos are trademarks or registered trademarks of SAP AG inGermany and other countries.

    Business Objects and the Business Objects logo,BusinessObjects, Crystal Reports, Crystal Decisions, WebIntelligence, Xcelsius, and other Business Objects products andservices mentioned herein as well as their respective logos aretrademarks or registered trademarks of Business ObjectsSoftware Ltd. Business Objects is an SAP company.

    Sybase and Adaptive Server, iAnywhere, Sybase 365, SQLAnywhere, and other Sybase products and services mentionedherein as well as their respective logos are trademarks orregistered trademarks of Sybase Inc. Sybase is an SAP company.

    Crossgate, m@gic EDDY, B2B 360, and B2B 360 Services areregistered trademarks of Crossgate AG in Germany and othercountries. Crossgate is an SAP company.

    All other product and service names mentioned are thetrademarks of their respective companies. Data contained in thisdocument serves informational purposes only. National productspecifications may vary.

    These materials are subject to change without notice. Thesematerials are provided by SAP AG and its affiliated companies("SAP Group") for informational purposes only, withoutrepresentation or warranty of any kind, and SAP Group shall not

    be liable for errors or omissions with respect to the materials.The only warranties for SAP Group products and services arethose that are set forth in the express warranty statementsaccompanying such products and services, if any. Nothing hereinshould be construed as constituting an additional warranty.

    These materials are provided as is without a warranty of anykind, either express or implied, including but not limited to, theimplied warranties of merchantability, fitness for a particularpurpose, or non-infringement.

    SAP shall not be liable for damages of any kind including withoutlimitation direct, special, indirect, or consequential damages thatmay result from the use of these materials.

    SAP does not warrant the accuracy or completeness of theinformation, text, graphics, links or other items contained withinthese materials. SAP has no control over the information that

    you may access through the use of hot links contained in these

    materials and does not endorse your use of third party web pagesnor provide any warranty whatsoever relating to third party webpages.

    SAP NetWeaver How-to Guides are intended to simplify theproduct implementation. While specific product features andprocedures typically are explained in a practical businesscontext, it is not implied that those features and procedures arethe only approach in solving a specific business problem usingSAP NetWeaver. Should you wish to receive additionalinformation, clarification or support, please refer to SAPConsulting.

    Any software coding and/or code lines / strings (Code)included in this documentation are only examples and are notintended to be used in a productive system environment. TheCode is only intended better explain and visualize the syntax andphrasing rules of certain coding. SAP does not warrant the

    correctness and completeness of the Code given herein, and SAPshall not be liable for errors or damages caused by the usage ofthe Code, except if such damages were caused by SAPintentionally or grossly negligent.

    Disclaimer:

    Some components of this product are based on Java. Any codechange in these components may cause unpredictable and severemalfunctions and is therefore expressively prohibited, as is anydecompilation of these components.

    Any Java Source Code delivered with this product is only to beused by SAPs Support Services and may not be modified oraltered in any way.

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    3/32

    ii

    Document History

    Document Version Description

    1.00 Draft Version of this guide

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    4/32

    iii

    Typographic Conventions Icons

    Type Style Description

    Example Text Words or characters quotedfrom the screen. Theseinclude field names, screentitles, pushbuttons labels,menu names, menu paths,and menu options.

    Cross-references to otherdocumentation

    Example text Emphasized words orphrases in body text, graphictitles, and table titles

    Example text File and directory names andtheir paths, messages,names of variables andparameters, source text, andnames of installation,upgrade and database tools.

    Example text User entry texts. These arewords or characters that youenter in the system exactly asthey appear in thedocumentation.

    Variable user entry. Anglebrackets indicate that youreplace these words andcharacters with appropriateentries to make entries in thesystem.

    EXAMPLE TEXT Keys on the keyboard, forexample, F2or ENTER.

    Icon Description

    Caution

    Important

    Note

    Recommendation or Tip

    Example

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    5/32

    iv

    Table of Contents

    1. Introduction .......................................................................................................................... 1

    2. Business Scenario............................................................................................................... 1

    3.

    Prerequisites ........................................................................................................................ 1

    4. Creating EasyQuery on BW ................................................................................................ 2

    5. Generating OData Service for EasyQuery ........................................................................ 3

    6.

    Registration and Activation of the Generated Service .................................................... 6

    7.

    Terminology ......................................................................................................................... 7

    8. Service Document ............................................................................................................... 9

    8.1 Service Document for a simple Query .......................................................................... 9

    8.2

    Metadata for an EasyQuery with Advanced Selection Options .................................... 9

    9. Metadata with Analytical Extension ................................................................................. 11

    9.1 Metadata for a simple EasyQuery .............................................................................. 11

    9.2

    Metadata for an EasyQuery with Advanced Selection Options .................................. 12

    10. Consuming the Service ..................................................................................................... 15

    10.1 Interacting with a simple Query .................................................................................. 15

    10.2

    Interacting with a Query with Advanced Selection Options ........................................ 21

    11. References ......................................................................................................................... 24

    12. Supported Features ........................................................................................................... 25

    13.

    Related Links ..................................................................................................................... 27

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    6/32

    How to Create OData Service for Analytic Queries

    1. IntroductionThis document focuses on generating SAP NetWeaver Gateway services for SAP BW queriesexposed via Easy Queries. Easy Query is one of the integrated services supported by SAP NetWeaverGateway.

    SAP NetWeaver Gateways SAP BW integration provides a generic tool allowing an administrator atcustomer side to easily expose existing SAP BW content as OData services.

    NOTE: Prior knowledge of the working of SAP NetWeaver Gateway is required to understand theinformation provided in this document.

    Now that you are here, we assume you are well aware of SAP NetWeaver Gateway. Read on to knowmore on one of the integrated services supported by Gateway, Easy Query!

    We will see how to generate SAP NetWeaver Gateway service for SAP BW queries exposed via EasyQueries. Gateways SAP BW integration shallprovide a generic tool allowing an administrator atcustomer side to easily expose existing SAP BW content as OData services.

    2.Business ScenarioWith the advent of the smartphone and multi-touch tablet, entrepreneurs and customers haverecognized the potential benefits of people centric applications for empowering employees with theright to instantly access data.

    People-centric applications very often include pieces of analytical information, which provides betterunderstanding of the business context, increase process efficiency, and support decision-making. It istherefore important to make the analytical data and functions in our business systems available asconsumption models accessible via OData. Analytic queries are the main tools for consuminganalytical data.

    SAP NetWeaver Gateway and SAP Business Warehouse (BW) Integration enables the SAP BWcontent to be exposed as OData for SAP Analytic services for light weight mobile consumption.SAP NetWeaver Gateway:

    Provides an easy way of integrating SAP BW functionalities by using Multidimensionalexpressions (MDX) and Easy Query.

    Enables the adoption of existing analytical content in consumption scenarios based on OData. Provides a simple representation of analytical data sets. Provides support for simple interactions.

    3.PrerequisitesThe Supported Release Information of SAP NetWeaver Gateway with Easy Query:

    GW SP05 BW 730 SP08 and above. BW 731 SP05and above

    Note: SAP NetWeaver Gateway with EasyQuery is also supported in GW SP04 and BW 730 SP05,SP06, SP07. BW 731 SP00 to SP04, but with limited features.

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    7/32

    How to Create OData Service for Analytic Queries

    4.Creating EasyQuery on BWThe Query Design: BEx Query Designer is used to choose or define an EasyQuery.

    To define a query as EasyQueryproceed as follows:

    1. Define an EasyQuery using BEx Query Designer. While defining choose one of the followingoptions:

    EasyQuery Without Advanced Selection Options

    EasyQuery With Advanced Selection Options: Here Input parameters are provided byCharacteristic Value Variable of processing type manual input / default valueIn simplewords, User will be prompted to enter value for the Input Variable to fetch the Result.

    2. Select By EasyQuery under Properties -> Extended tab, (refer the snapshot below for moredetails).

    More Details on EasyQuery on BW:

    Details onConfiguring Easy Queries

    Details onConsuming Easy Queries

    Details onBEx Query designer

    http://help.sap.com/saphelp_nw73ehp1/helpdata/en/35/0da8627e8040ada63550cf1fee5f6d/frameset.htmhttp://help.sap.com/saphelp_nw73ehp1/helpdata/en/35/0da8627e8040ada63550cf1fee5f6d/frameset.htmhttp://help.sap.com/saphelp_nw73ehp1/helpdata/en/35/0da8627e8040ada63550cf1fee5f6d/frameset.htmhttp://help.sap.com/saphelp_nw73ehp1/helpdata/en/b6/53d6c4e26a4504b8971c6e690d2105/content.htmhttp://help.sap.com/saphelp_nw73ehp1/helpdata/en/b6/53d6c4e26a4504b8971c6e690d2105/content.htmhttp://help.sap.com/saphelp_nw73ehp1/helpdata/en/b6/53d6c4e26a4504b8971c6e690d2105/content.htmhttp://help.sap.com/saphelp_nw73ehp1/helpdata/en/42/d21c5446076bb2e10000000a1553f6/content.htm?frameset=/en/1e/99ea3bd7896f58e10000000a11402f/frameset.htmhttp://help.sap.com/saphelp_nw73ehp1/helpdata/en/42/d21c5446076bb2e10000000a1553f6/content.htm?frameset=/en/1e/99ea3bd7896f58e10000000a11402f/frameset.htmhttp://help.sap.com/saphelp_nw73ehp1/helpdata/en/42/d21c5446076bb2e10000000a1553f6/content.htm?frameset=/en/1e/99ea3bd7896f58e10000000a11402f/frameset.htmhttp://help.sap.com/saphelp_nw73ehp1/helpdata/en/42/d21c5446076bb2e10000000a1553f6/content.htm?frameset=/en/1e/99ea3bd7896f58e10000000a11402f/frameset.htmhttp://help.sap.com/saphelp_nw73ehp1/helpdata/en/b6/53d6c4e26a4504b8971c6e690d2105/content.htmhttp://help.sap.com/saphelp_nw73ehp1/helpdata/en/35/0da8627e8040ada63550cf1fee5f6d/frameset.htm
  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    8/32

    How to Create OData Service for Analytic Queries

    5. Generating OData Service for EasyQueryThis section guides you to generate an OData service for an EasyQuery using the Service Builderapplication.

    To generate an OData services for an Easy Query proceed as follows:

    1. Go to the transaction SEGW. Choose to create a new project.

    2. Enter the details for the Project, Description, and Generation Strategy. In case the projectneeds to be transported the package should not be $TMP.

    3. In the context menu of the Data Model (of the new project), select Redefine BW Query

    Service..

    4. Enter the details as explained below in the Wizard to Redefine BW Query service: Select Access Type as Controller for Easy Queries (SAP BW) Enter the RFC Destination (F4 is also available to select the RFC Destination) Enter the Query Name or Press F4 to select the EasyQuery from the defined BW System

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    9/32

    How to Create OData Service for Analytic Queries

    5. Click to navigate to the second step of the wizard.6. Enter the details for the Model Provider Class, Data Provider Class, Model Name and Service

    Name along with the descriptions.Note:Version of Model and Service will be suggested by wizard itself.

    7. Click Next.8. Now the Model provider, Data Provider, Model and Service for BW Query is generated. You

    can view the generation status by clicking on (Display Log Icon) available in the Toolbar.

    9. In the third step of the Wizard, select all artifacts.Note:In the Wizard step 3 of 3: Redefine Service, user can select/deselect the artifacts . Thisis called as Redefinition of the service. For more details refer Redefining Services fromExternal Framework (SPI, BW Query, and GenIL)underRelated links

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    10/32

    How to Create OData Service for Analytic Queries

    10. Click to complete the wizard.

    The message Project XXX' has been checked; no errors were found is displayed.

    11. After the creation of the project, you have an option to change the names and labels of theartifacts.

    To Change the Node Names, Property Names and Labels follow the below steps:1. Switch to edit mode.

    2. Choose the Redefine Attribute button .3. The Node Name, Property Names and the Label fields can be edited.

    12. Click to generate the runtime objects.1. The model and service definition screen opens with pre-filled details of Model Provider,

    Data Provider classes and Service Registration Details.2. Under service registration, select the option to overwrite the extended service and click oncontinue.

    3. After successful generation, message Runtime objects for project XXX were generatedsuccessfully is displayed.

    ...

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    11/32

    How to Create OData Service for Analytic Queries

    6.Registration and Activation of the Generated

    ServiceNote:Before Service Registration, user should check if Gateway system is configured or not. If notconfigured, refer to Connection Settings to SAP NetWeaver Gatewayand Creating the SAP System

    Alias for ApplicationsunderRelated Links.

    To register an OData Service, double click on the Service Maintenance node. The ALV grid showingthe configured systems is displayed.

    1. Select the Gateway System where this service needs to be registered and click toregister the service.

    2. Click Yes when the warning popup. Provide the system alias configured from Gateway HUB tobackend. Click Enter to continue.

    For more details on system alias refer Service Maintenance underRelated Links.

    3. Add Service screen is displayed. Enter the package as $TMP and enter to continue.Note: In case the registered service needs to be transported, then package details need to beentered.

    4. The registration status changes to a green node indicating the service is activated.

    5. In Service Builder, Click to maintain the service. A new screen opens to Activate andMaintain Services.

    6. Click to open the service document in the browser. The URL is as followshttp://:/sap/opu/OData/sap//?$format=xml

    7. Open the metadata by changing the above URL as belowhttp://:/sap/opu/OData/sap//$metadata

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    12/32

    How to Create OData Service for Analytic Queries

    7.TerminologyWhen an EasyQuery is generated as an OData Service, the metadata of the OData Service willdisplay OData specific terms. This section provides a list of EasyQuery terms and also OData specificterms for EasyQuery.

    Basic EasyQuery Terminologies

    OData Specific terms for EasyQuery

    EasyQuery Terms OData Terms OData Terms (GW) Annotations Semantics

    Query withadvanced Selection

    Queryparameters

    Parameters entity

    sap: semantics="parameters

    Query resultStructures

    Query Result Resultentity

    sap:semantics=aggregate

    Characteristic Dimension Property of a ResultEntity

    sap: aggregation-Role="dimension"

    Key Figures Measure Property of a ResultEntity

    sap: aggregation-Role="measure"

    Query Variables ParameterProperty

    Property of theParameter Entity

    Can be either

    sap: parameter="mandatory

    sap: parameter="optional

    Is Total TotaledProperties

    Totaled Properties sap: aggregation-role="totaled-properties-list"

    Terms Description

    Query Access point for consuming logical data organized ina multi-dimensional cube structure.

    QueryCharacteristic : key, Text Query element used for creating perspectives ondata via drill-down and slicing.

    Characteristic members : Key, Text andAttribute

    Finite set of classifications representing the possibleinstances of a characteristic.

    A member has an ID, an associated text, andattributes.

    Key Figures Facts for a combination of characteristic members.

    Facts are key figure values with a definedaggregation behavior.Example, summation, average, minimum, maximum,etc.

    Characteristic Value Variables Placeholders for values assigned by the consumerthat may trigger extra logic before query execution,Example, Determines a certain perspective on thedata cube by setting a filter for some characteristic.

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    13/32

    How to Create OData Service for Analytic Queries

    RowID Entity Key Entity KeyHere itis ID for each resultentity

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    14/32

    How to Create OData Service for Analytic Queries

    8.Service Document

    8.1 Service Document for a simple Query

    Let us analyze how a service document for a simple easy query is represented in OData (GW). In thiscase we shall consider a query which does not require input parameter to get the results.

    Below is the pictorial representation of the Service Document.

    The Service document for an EasyQuery without Input Parameter:1.

    Lists only the Query result Entity set Indicates that the Result Entity type represents the Query Result Structure

    Below is the OData representation of the above EasyQuery

    8.2 Metadata for an EasyQuery with Advanced Selection OptionsLet us analyze how a service document looks in OData (GW) for an easy query which requires inputfor determining the Result. Below is the pictorial representation of the Service Document.

    The Service document for an EasyQuery with Input Parameter

    1. Lists the query parameter entity set.

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    15/32

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    16/32

    How to Create OData Service for Analytic Queries

    9.Metadata with Analytical Extension

    9.1 Metadata for a simple EasyQuery

    Let us consider an easy query which does not have any advanced selection options. It just consists offour characteristics and two key figures.

    EasyQuery in Query Designer:

    OData representation of the above EasyQuery

    Metadata URI: http://:/sap/opu/OData/sap//$metadata http://:/sap/opu/odata/sap/ZCL_SALESORDERHISTORY_SRV/$metadata

    In OData (GW) metadata shown above, apart from four characteristics and key figures you can seethere is more information like

    ID -> Unique Identification of an Row in entity

    Totaled Properties -> List of properties on which result is totaled

    Formatted Property of the Key Figure-> Contains the formatted value of the key figure

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    17/32

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    18/32

    How to Create OData Service for Analytic Queries

    OData (GW) metadata shown above represents:

    Query result structures in a result entity. This entity has Dimension, key Figures andFormatted Key Figures.

    Query result structures also contains ID (Unique Identification of a Row in an entity) and

    Totaled Properties(List of properties on which result is totaled).

    Query Variables in a Parameters entity. This entity has Query Variable and Query Variabletext.

    Parameters entity also contains Navigation Property Resultswhich will enable for thenavigation from parameters entity to Result entity. Below snapshots depicts the Navigation

    from Parameters to Result.

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    19/32

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    20/32

    How to Create OData Service for Analytic Queries

    10. Consuming the ServiceNow that we have metadata, we will analyze BW data in OData (GW) representation.

    10.1Interacting with a simple Query

    Here is a use case where the store Manager would like to analyze the sales order History(transactions) of an outlet. For easy understanding, below is the comparison between the Sales orderhistory as seen in the SAP BW system and in OData (GW) format. Below is the Table and Chartrepresentation of Sales Order history

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    21/32

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    22/32

    How to Create OData Service for Analytic Queries

    Now that we have results in OData format, let us see different cases of using the OData service:

    Case 1: Sales manager would like to fetch the Salesorder History for an Outlet (Fetch Non-aggregated Results on a Single Dimension ) .

    OData Request: In the above URL, add the $select OData command specifing the propertiesrepresenting measure (annotated as "sap: aggregation-role=measure") and the property representinga dimension (annotated as "sap: aggregation-role=dimension").

    For example:http://:/sap/opu/odata/sap/ZCL_SALESORDERHISTORY_SRV/SALESORDERHISTORYResults?$select=A4S3XRZGY594U6GMJ3SAB0BTQ4,A4S3XRZOMO7QJP35Z9MCNADSFW,A0VC_2STOR_T

    By executing the above URL, aggregated measure values of an outlet is returned in OData formatwhich is shown below:

    Case 2: Sales manager would like to see the SalesOrderHistory of the Customers of an outlet(Fetch Aggregated Measure Values on more than one Dimension)

    OData Request: In the $select OData command specifing the properties representing measure(annotated as "sap: aggregation-role=measure") and more than property representing a dimension(annotated as "sap: aggregation-role=dimension").

    For example:

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    23/32

    How to Create OData Service for Analytic Queries

    http:// :/sap/opu/odata/sap/ZCL_SALESORDERHISTORY_SRV/SALESORDERHISTORYResults?$select=A4S3XRZGY594U6GMJ3SAB0BTQ4,A4S3XRZOMO7QJP35Z9MCNADSFW,A0VC_2STOR_T,A0VC_2CUST

    By executing the above URL, the aggregated measure values i.e Salesorder of the Customersbelonging to an outlet and also the Salesorder history of an outlet is returmed in OData format. Sameis shown below :

    Case 3: Sales manager would like to see the PurchaseOrderHistory of a particular Customer ofan outlet . (Fetch Aggregated Measure Values on a Dimension restricted to certain condition)OData Request: You could filter out the result set by using $filter OData Command. $filter ODatacommand can be applied on those properties that are annotated "sap: aggregation-role=dimension".

    Note:

    $filter cannot be applied on those properties that are annotated as "sap: aggregationrole=measure" .

    $filter can be applied only on those propertiesfor which filterable enabled.

    For example:

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    24/32

    How to Create OData Service for Analytic Queries

    http:// :/sap/opu/odata/sap/ZCL_SALESORDERHISTORY_SRV/SALESORDERHISTORYResults?$select=A4S3XRZGY594U6GMJ3SAB0BTQ4,A4S3XRZOMO7QJP35Z9MCNADSFW,A0VC_2STOR_T,A0VC_2DPMT_T&$filter=A0VC_2CUST eq '10176982900'

    Tip:

    You could get the list of values for any dimension or dimension attribute by specifying them in$select OData command without any Measures. This gives you the list of members for thedimension.

    If you like to slice the aggregated values for a particular dimension, use ne operator with$filter OData command.

    In this usecase, the records belonging to Customer 10176982900 is retrieved first and then theaggregated value of each ProductCategory of an outlet is displayed. Same can be seen in thesnapshot shown below .

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    25/32

    How to Create OData Service for Analytic Queries

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    26/32

    How to Create OData Service for Analytic Queries

    Case 4: To fetch top N aggregated Values

    You could apply OData commands $top, $skip to your OData query request to fetch the top Naggregated value.

    OData Request :

    http:// :/sap/opu/odata/sap/ZCL_SALESORDERHISTORY_SRV/SALESORDERHISTORYResults?$select=A4S3XRZGY594U6GMJ3SAB0BTQ4,A4S3XRZOMO7QJP35Z9MCNADSFW,A0VC_2STOR_T,A0VC_2DPMT_T&$filter=A0VC_2CUST eq'10176982900'&$top=3&$skip=1

    Note:OData Command $orderby is not supported.

    Case 5: Sum of aggregated Measure Values

    You could apply OData command $select on measure values and totaledproperties (annotated as'sap-aggregation-role="totaled-properties-list"' in the Results Entity)

    OData Request:

    http://Host>:/sap/opu/odata/sap/ZCL_SALESORDERHISTORY_SRV/SALESORDERHISTORYResults?$select=A4S3XRZGY594U6GMJ3SAB0BTQ4,A4S3XRZOMO7QJP35Z9MCNADSFW&TotaledProperties

    10.2 Interacting with a Query with Advanced Selection OptionsIn this use case we have a business partner (referred as BP) who has ordered for a product withproduct ID and receives the Purchase Order details for the same. Now the BP likes to analyze thePurchase Order history of the products which was ordered.The below snapshot depicts the table and chart representation of the purchase order history details inSAP BW system.

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    27/32

    How to Create OData Service for Analytic Queries

    Now we will see how to analyze the same from OData (GW) generated service. To create a QueryOperation URI follow the below mentioned steps:Open the Service DocumentoftheOData (GW) generated service.

    1. Open the Service Document of the OData (GW) generated service as explained insection 6.Service Document for the EasyQuery in OData (GW) which has only Characteristics and KeyFigures and Characteristic Value Variables looks similar to the snapshot given below:

    2. Below is the step by step procedure of forming the Query URL.

    Search for Parameters in the service document and add the "href" attribute value to theURL.

    For example:

    http://:/sap/opu/odata/sap//< href attribute value >/

    http:// :/sap/opu/odata/sap/BUSINESSPARTNERORDERS/

    BUSINESSPARTNERORDERS Now add $select = to the above URI. This will display List of Entries for

    the selected

    http:// Host>:/sap/opu/odata/sap/BUSINESSPARTNERORDERS/BUSINESSPARTNERORDERS?$select=A0P_BP_SUPP

    From the response choose one entry and replace ?$select= with value of "

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    28/32

    How to Create OData Service for Analytic Queries

    http://:/sap/opu/odata/sap//EntitySetName(P1 = V1)/Results

    http:// :/sap/opu/odata/sap/BUSINESSPARTNERORDERS/BUSINESSPARTNERORDERS('100000025')/Results

    Note:

    URL always first identifies values for the parameters in the parameter entity set and then

    navigates to the query results for this parameterization. Example, service/Query (p1 ==v1)/Results.

    Even if a query parameter is annotated with sap:parameter="optional", the QueryParameter should be part of the URL .

    3. Once the above URL is executed, the results are aggregated based on the Input Variables and theaggregated results is displayed in OData format as shown below :

    Below is the mapping of data in SAP BW System and the same data in OData format

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    29/32

    How to Create OData Service for Analytic Queries

    Now lets see some of the usecases for the above generated OData service .

    Case 1: To Fetch the list of Values for a Query Variable

    You could apply OData command $select on an any Query Parameres (annotated as

    sap:parameter="optional"or sap:parameter="mandatory")to fetch the list of values .

    OData Request:

    http:// :/sap/opu/odata/sap/BUSINESSPARTNERORDERS/BUSINESSPARTNERORDERS? $select=A0P_BP_SUPPText,A0P_BP_SUPP

    Note:At a time $select can be applied only on one Query Parameter and the associated text.

    Case 2: To fetch the list of Values for a dependent dimension (Query parameter)

    You could apply $select OData command on the QueryParameter for which you would like to fetch listof values and apply $filter on the dependant dimension .

    Now how do you identify if a Query parameter has a dependant diimension.

    Well you can identify this by checking if the Queryparameter has an annotation sap:super-ordinate="Dependant Dimension"

    For example:

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    30/32

    How to Create OData Service for Analytic Queries

    12. Supported FeaturesAll the features that are supported in OData (GW) for EasyQuery are listed below:

    Topic Feature Description OData Terms OData(GW)

    Catalog List of available

    Queries/Resources

    Resource

    repository - noSAP Data Spectopic

    Implicitly provided

    via the metadatadocument

    Metadata Description Query/resourcedescription

    Structure Query Resultstructure

    Query ResultEntity

    Query ResultEntity

    Variables Fields forrestrictions, whichare not containedin result set

    Query InputEntity

    Value Help List of availablevalues for QueryVariables

    Query variableEntity

    Query variableEntity

    Characteristics inrows

    WhenCharacteristic isconfigured to bedisplayed as key

    sap: aggregation-role="dimension"

    sap: aggregation-role="dimension"

    OnlyCharacteristicText in rows

    WhenCharacteristic isconfigured to bedisplayed as Text

    sap: aggregation-role="dimension"

    sap: aggregation-role="dimension"

    BaseCharacteristic

    Context isprovided by thevalue of ananother property

    sap: super-ordinate

    sap: super-ordinate

    CharacteristicAttributes

    Attributes of acharacteristic

    sap: attribute-for sap: attribute-for

    Characteristic:Unit

    sap: unit sap: unit

    key figures : rawvalue

    sap:aggregation-role="measure"

    sap:aggregation-role="measure"

    key figures:formatted value

    sap: text for keyfigures- raw value

    sap: text for keyfigures- raw value

    key figures: unit sap: unittotals, subtotals sap: totals Transform BW

    tag to ODataannotation

    Texts fordimensions

    sap: text

    Date Property Date Property ofa Characteristicor Query Variable

    sap: display-format=DATE

    sap: display-format=DATE

    Mandatory orOption QueryVariables

    Represents if theparameterproperty is

    mandatory orOptional

    Can be either

    sap: parameter="mandatory

    sap: parameter=

    Can be either

    sap: parameter="mandatory

    sap: parameter=

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    31/32

    How to Create OData Service for Analytic Queries

    "optional "optional

    Single QueryVariable

    Interval Query

    Variables

    Can be

    annotated as

    sap: upper-boundary=

    or

    sap-lower-boundary=

    Can be either

    sap: upper-boundary=

    or

    sap-lower-boundary=

    RuntimeOperations

    Filter Filter $filter $filter (Supportedon both QueryVariables andDimension)

    Select Select $select $select(Supported onboth QueryVariables andProperties ofQuery Structure)

    Top N Top $top $top (Supported onlyon QueryStructure)

    Paging Skip $skip $skip

    ( Supported onlyon QueryStructure)

    Count Count Count

    Inline Count InlineCount $InlineCount

  • 8/9/2019 How to Create OData Services for Analytic Queries.pdf

    32/32

    How to Create OData Service for Analytic Queries

    13. Related LinksHelp Document Links:

    Creating the SAP System Alias for Applications

    http://help.sap.com/nwgateway->Development Information ->Developers Guide ->SAPNetWeaver Gateway Configuration Guide ->OData Channel Configuration -> Connection Settings:SAP NetWeaver Gateway to SAP Systems -> Creating the SAP System Alias for Applications

    Connection Settings to SAP NetWeaver Gateway

    http://help.sap.com/nwgateway->Development Information ->Developers Guide ->SAPNetWeaver Gateway Configuration Guide ->OData Channel Configuration -> Connection Settingson the Backend System-> Connection Settings to SAP NetWeaver Gateway

    Service Maintenance

    http://help.sap.com/nwgateway->Development Information ->Developers Guide ->SAPNetWeaver Gateway Developer Guide -> SAP NetWeaver Gateway Service Builder-> ServiceMaintenance

    Redefining Services from External Framework (SPI, BW Query, and GenIL).

    http://help.sap.com/nwgateway->Development Information ->Developers Guide ->SAPNetWeaver Gateway Developer Guide ->OData Channel -> SAP NetWeaver Gateway Cookbooks-> OData Channel Cookbooks ->Getting Started with the Service Builder -> Redefining Services ->Redefining Services from External Framework (SPI, BW Query, GenIL).

    Redefining the Gateway services

    http://help.sap.com/nwgateway->Development Information ->Developers Guide ->SAPNetWeaver Gateway Developer Guide ->OData Channel -> SAP NetWeaver Gateway Cookbooks-> OData Channel Cookbooks ->Getting Started with the Service Builder -> Redefining Services ->Redefining Gateway Services

    SCN Links:

    http://scn.sap.com/people/zoltan.albrecht/blog/2012/02/13/OData-consumption-of-easy-queries

    http://scn.sap.com/people/uwe.fischer/blog/2011/12/12/easy-queries-on-sap-netweaver-bw

    http://scn.sap.com/community/netweaver-gateway/blog/2012/12/08/transform-sap-bw-queries-into-odata-service-generation-and-activation

    http://scn.sap.com/people/zoltan.albrecht/blog/2012/02/13/odata-consumption-of-easy-querieshttp://scn.sap.com/people/zoltan.albrecht/blog/2012/02/13/odata-consumption-of-easy-querieshttp://scn.sap.com/people/uwe.fischer/blog/2011/12/12/easy-queries-on-sap-netweaver-bwhttp://scn.sap.com/people/uwe.fischer/blog/2011/12/12/easy-queries-on-sap-netweaver-bwhttp://scn.sap.com/community/netweaver-gateway/blog/2012/12/08/transform-sap-bw-queries-into-odata-service-generation-and-activationhttp://scn.sap.com/community/netweaver-gateway/blog/2012/12/08/transform-sap-bw-queries-into-odata-service-generation-and-activationhttp://scn.sap.com/community/netweaver-gateway/blog/2012/12/08/transform-sap-bw-queries-into-odata-service-generation-and-activationhttp://scn.sap.com/community/netweaver-gateway/blog/2012/12/08/transform-sap-bw-queries-into-odata-service-generation-and-activationhttp://scn.sap.com/community/netweaver-gateway/blog/2012/12/08/transform-sap-bw-queries-into-odata-service-generation-and-activationhttp://scn.sap.com/people/uwe.fischer/blog/2011/12/12/easy-queries-on-sap-netweaver-bwhttp://scn.sap.com/people/zoltan.albrecht/blog/2012/02/13/odata-consumption-of-easy-queries