Class: Sina

sap.bc.ina.api.sina.sinabase. Sina

<private> new Sina()

Sina base class. Use the getSina() factory in sap.bc.ina.api.sina instead of using this private constructor directly.
Since:
  • SAP HANA SPS 08
Source:

Methods

createChartQuery(properties) → {sap.bc.ina.api.sina.sinabase.ChartQuery}

Creates and returns a chart query for simple analytics.
Parameters:
Name Type Description
properties Object Configuration object.
Since:
  • SAP HANA SPS 06
Source:
Returns:
The instance of a chart query. See sap.bc.ina.api.sina.sinabase.ChartResultSet for the result set format.
Type
sap.bc.ina.api.sina.sinabase.ChartQuery
Example

Create a query that returns a result set suitable for a bar or pie chart:

var query = sap.bc.ina.api.sina.createChartQuery()
.dataSource({ schemaName : "SYSTEM",
              objectName : "J_EPM_PRODUCT"
 })
.addDimension("CATEGORY")
.addMeasure({ name : "CATEGORY",
              aggregationFunction : "COUNT"
}); //end of query
var resultSet = query.getResultSetSync();
var elements = resultSet.getElements();
// contents of elements:
[
                {
                  "label": "Others",
                  "labelRaw": "Others",
                  "value": "13",
                  "valueRaw": 13
                },
                {
                  "label": "Notebooks",
                  "labelRaw": "Notebooks",
                  "value": "10",
                  "valueRaw": 10
                },
                {
                  "label": "Flat screens",
                  "labelRaw": "Flat screens",
                  "value": "9",
                  "valueRaw": 9
                },
                {
                  "label": "Software",
                  "labelRaw": "Software",
                  "value": "8",
                  "valueRaw": 8
                },
                {
                  "label": "Electronics",
                  "labelRaw": "Electronics",
                  "value": "5",
                  "valueRaw": 5
                }
              ]

createGroupBarChartQuery(properties) → {sap.bc.ina.api.sina.sinabase.GroupBarChartQuery}

Creates a chart query that delivers a result set suitable for a group bar chart.
Parameters:
Name Type Description
properties Object Configuration object.
Since:
  • SAP HANA SPS 06
Source:
Returns:
The instance of a chart query. See sap.bc.ina.api.sina.sinabase.GroupBarChartResultSet for the result set format.
Type
sap.bc.ina.api.sina.sinabase.GroupBarChartQuery
Examples

Grouped bar chart query with two dimensions and one measure:

var query = sap.bc.ina.api.sina.sina.createGroupBarChartQuery({
     dataSource : { "schemaName"  :  "SYSTEM" ,
                    "objectName"  :  "J_EPM_PRODUCT" },
     dimensions : ['YEAR', 'COUNTRY'],
     measures   : [{ name: 'PROFIT', aggregationFunction: 'SUM' }]
 });
 var resultSet = query.getResultSetSync();
 var elements = resultSet.getElements();

Grouped bar chart query with two dimensions and one measure:

var query = sap.bc.ina.api.sina.sina.createGroupBarChartQuery();
query.dataSource({ schemaName : "SYSTEM",
                   objectName : "J_EPM_PRODUCT"
});
query.addDimension('CURRENCY_CODE');
query.addDimension('CATEGORY');
query.count('PRODUCT_ID');
var resultSet = query.getResultSetSync();
var elements = resultSet.getELements();
// contents of elements:
[
                {
                  "label": "EUR",
                  "value": [
                    {
                      "label": "Notebooks",
                      "value": [
                        {
                          "label": "COUNT",
                          "value": {
                            "value": "6",
                            "valueRaw": 6
                          }
                        }
                      ]
                    },
                    {
                      "label": "Others",
                      "value": [
                        {
                          "label": "COUNT",
                          "value": {
                            "value": "5",
                            "valueRaw": 5
                          }
                        }
                      ]
                    },
                    {
                      "label": "Software",
                      "value": [
                        {
                          "label": "COUNT",
                          "value": {
                            "value": "3",
                            "valueRaw": 3
                          }
                        }
                      ]
                    }
                  ]
                }
                ]

createLineChartQuery(properties) → {sap.bc.ina.api.sina.sinabase.LineChartQuery}

Creates a chart query that delivers a result set suitable for a line chart.
Parameters:
Name Type Description
properties Object Configuration object.
Since:
  • SAP HANA SPS 06
Source:
Returns:
Instance of a chart query. See sap.bc.ina.api.sina.sinabase.LineChartResultSet for the result set format.
Type
sap.bc.ina.api.sina.sinabase.LineChartQuery
Example

Line chart with two dimensions and one measure:

var queryProperties = {
    dataSource      : { schemaName  : "SYSTEM",
                                       objectName  : "J_EPM_PRODUCT"
                                     },
                   dimensionX      : {name: 'CATEGORY'},
                   dimensionLine   : {name: 'CURRENCY_CODE'},
                   measureY        : {name: 'PRODUCT_ID', aggregationFunction: 'COUNT'}
               };
               query = sap.bc.ina.api.sina.sina.createLineChartQuery(queryProperties);
var resultSet = query.getResultSetSync();
var elements = resultSet.getEements();
// contents of elements (shortened):
[
                 {
                   "label": "EUR",
                   "value": [
                     {
                       "x": "Notebooks",
                       "y": 6
                     },
                     {
                       "x": "Others",
                       "y": 5
                     },
                     {
                       "x": "Software",
                       "y": 3
                     },
                     {
                       "x": "Speakers",
                       "y": 3
                     },
                     {
                       "x": "Electronics",
                       "y": 2
                     },
                     {
                       "x": "Flat screens",
                       "y": 2
                     },
                     {
                       "x": "Laser printers",
                       "y": 2
                     },
                     {
                       "x": "Mice",
                       "y": 2
                     },
                     {
                       "x": "PC",
                       "y": 2
                     },
                     {
                       "x": "Workstation ensemble",
                       "y": 2
                     }
                   ]
                 },
                 {
                   "label": "USD",
                   "value": [
                     {
                       "x": "Others",
                       "y": 4
                     },
                     {
                       "x": "Flat screens",
                       "y": 2
                     },
                     {
                       "x": "Handhelds",
                       "y": 2
                     },
                     {
                       "x": "High Tech",
                       "y": 2
                     },
                     {
                       "x": "Notebooks",
                       "y": 2
                     },
                     {
                       "x": "Software",
                       "y": 2
                     },
                     {
                       "x": "Electronics",
                       "y": 1
                     },
                     {
                       "x": "Graphic cards",
                       "y": 1
                     },
                     {
                       "x": "Handheld",
                       "y": 1
                     },
                     {
                       "x": "Headset",
                       "y": 1
                     }
                   ]
                 }
              ]

createSearchQuery(properties) → {sap.bc.ina.api.sina.sinabase.SearchQuery}

Creates and returns a search query for text queries.
Parameters:
Name Type Description
properties Object Configuration object.
Since:
  • SAP HANA SPS 06
Source:
Returns:
The instance of a search query. See sap.bc.ina.api.sina.sinabase.SearchResultSet for the result set format.
Type
sap.bc.ina.api.sina.sinabase.SearchQuery
Examples

Simple search for the term "basic" in view J_EPM_PRODUCT. If the term is found in a column marked in the view as freestyle search relevant, the content of columns in the attributes array is returned, in this case PRODUCT_ID, TEXT, CATEGORY, PRICE, and CURRENCY_CODE. The return attributes do not have to be marked as freestyle search relevant though. Note that the suggestion query does not make use of the freestyle search relevant property. So if you set this property to false in the view, you will not get a search result using a suggestion as search term.

var query = sap.bc.ina.api.sina.createSearchQuery({
                dataSource          : { schemaName  : "SYSTEM",
                                        objectName  : "J_EPM_PRODUCT" },
                attributes          : [ "PRODUCT_ID",
                                        "TEXT",
                                        "CATEGORY",
                                        "PRICE",
                                        "CURRENCY_CODE"],
                searchTerms         : "basic",
                skip                : 0,
                top                 : 5
               });
var resultSet = query.getResultSetSync();
var elements = resultSet.getElements();
// contents of elements:
[{ "PRODUCT_ID":{"label":"PRODUCT_ID","valueRaw":"HT-1000","value":"HT-1000"},
    "TEXT":{"label":"TEXT","valueRaw":"Notebook Basic 15 with 1,7GHz - 15","value":"Notebook Basic 15 with 1,7GHz - 15"},
    "CATEGORY":{"label":"CATEGORY","valueRaw":"Notebooks","value":"Notebooks"},
    "PRICE":{"label":"PRICE","valueRaw":"956.00","value":"956.00"},
    "CURRENCY_CODE":{"label":"CURRENCY_CODE","valueRaw":"EUR","value":"EUR"}},
    // second result item:
    {"PRODUCT_ID":{"label":"PRODUCT_ID","valueRaw":"HT-1001","value":"HT-1001"},
    "TEXT":{"label":"TEXT","valueRaw":"Notebook Basic 17 with 1,7GHz - 17","value":"Notebook Basic 17 with 1,7GHz - 17"},
    "CATEGORY":{"label":"CATEGORY","valueRaw":"Notebooks","value":"Notebooks"},
    "PRICE":{"label":"PRICE","valueRaw":"1249.00","value":"1249.00"},
    "CURRENCY_CODE":{"label":"CURRENCY_CODE","valueRaw":"EUR","value":"EUR"}},
    // third result item:
    {"PRODUCT_ID":{"label":"PRODUCT_ID","valueRaw":"HT-1002","value":"HT-1002"},
    "TEXT":{"label":"TEXT","valueRaw":"Notebook Basic 18 with 1,7GHz - 18","value":"Notebook Basic 18 with 1,7GHz - 18"},
    "CATEGORY":{"label":"CATEGORY","valueRaw":"Notebooks","value":"Notebooks"},
    "PRICE":{"label":"PRICE","valueRaw":"1570.00","value":"1570.00"},
    "CURRENCY_CODE":{"label":"CURRENCY_CODE","valueRaw":"USD","value":"USD"}},
    // fourth result item:
    {"PRODUCT_ID":{"label":"PRODUCT_ID","valueRaw":"HT-1003","value":"HT-1003"},
    "TEXT":{"label":"TEXT","valueRaw":"Notebook Basic 19 with 1,7GHz - 19","value":"Notebook Basic 19 with 1,7GHz - 19"},
    "CATEGORY":{"label":"CATEGORY","valueRaw":"Notebooks","value":"Notebooks"},
    "PRICE":{"label":"PRICE","valueRaw":"1650.00","value":"1650.00"},
    "CURRENCY_CODE":{"label":"CURRENCY_CODE","valueRaw":"EUR","value":"EUR"}},
    // fifth result item:
    {"PRODUCT_ID":{"label":"PRODUCT_ID","valueRaw":"HT-8000","value":"HT-8000"},
    "TEXT":{"label":"TEXT","valueRaw":"1,5 Ghz, single core, 40 GB HDD, Windows Vista Home Basic, 512 MB RAM","value":"1,5 Ghz, single core, 40 GB HDD, Windows Vista Home Basic, 512 MB RAM"},
    "CATEGORY":{"label":"CATEGORY","valueRaw":"Notebooks","value":"Notebooks"},
    "PRICE":{"label":"PRICE","valueRaw":"799.00","value":"799.00"},
    "CURRENCY_CODE":{"label":"CURRENCY_CODE","valueRaw":"EUR","value":"EUR"}}
 ]

The same search as in the previous example but now with term highlighting. If the term "basic" is found in the TEXT attribute, it will be returned as <b>basic</b>. The parameter maxLength defines the length of chars to be returned. The parameter startPosition defines start position of chars to be returned. The maxLength and startPosition parameters can be omitted. In this case, the default values shown in the example below are used.

var searchQuery = sap.bc.ina.api.sina.createSearchQuery({
 dataSource          : { "schemaName"  :  "SYSTEM" ,
                         "objectName"  :  "J_EPM_PRODUCT" },
 attributes          : [ "PRODUCT_ID",
                         { attributeName: "TEXT", highlighted:true,
                           maxLength:30000, startPosition:1 } ],
 searchTerms         : "basic",
 skip                : 0,
 top                 : 5
});
 var resultSet = searchQuery.getResultSetSync();
 var searchResults = resultSet.getElements();

The same search as in the previous example, but now with the snippet function. If the term "basic" is found in the TEXT attribute the content is shortened and will begin and end with three dots (...) In addition to the snippet, the search term is highlighted the same way as in the highlighted function (see previous example). It is therefore not necessary to use highlighted and snippet for the same attribute.

var searchQuery = sap.bc.ina.api.sina.createSearchQuery({
 dataSource          : { "schemaName"  :  "SYSTEM" ,
                         "objectName"  :  "J_EPM_PRODUCT" },
 attributes          : [ "PRODUCT_ID",
                         { attributeName: "TEXT", snippet:true } ],
 searchTerms         : "basic",
 skip                : 0,
 top                 : 5
});
 var resultSet = searchQuery.getResultSetSync();
 var searchResults = resultSet.getElements();

createSuggestionQuery(properties) → {sap.bc.ina.api.sina.sinabase.SuggestionQuery}

Creates and returns a suggestion for text queries.
Parameters:
Name Type Description
properties Object Configuration object.
Since:
  • SAP HANA SPS 06
Source:
Returns:
The instance of a suggestion query.
Type
sap.bc.ina.api.sina.sinabase.SuggestionQuery
Example

Getting suggestions asynchronously for attributes CATEGORY and PRODUCT_ID. Note that, other than the search query, the suggestion query does not make use of the freestyle search relevant property set in the view. So if you set this property to false in the view, you will get a suggestion but a search using the suggestion as a search term will show no results.

 var properties = {
     dataSource : { "schemaName"  : "SYSTEM",
                   "objectName"  : "J_EPM_PRODUCT"
                  },
     searchTerms : "s*",
     top   : 10,
     skip  : 0,
     onSuccess : function(resultset) {
                       var suggestions = resultset.getElements();
                       console.dir(suggestions);
     },
     onError :   function(error){
                       console.error(error);
     },
     attributes : ["CATEGORY","PRODUCT_ID"]
 };
 var suggestion_query = sap.bc.ina.api.sina.sina.createSuggestionQuery(properties);
 suggestion_query.getResultSet(); //returns immediately, see onSuccess on how to go on