Tag: SAP

  • How to write back data to SAP HANA?

    How to write back data to SAP HANA?

    Preface

    This document assumes you are already using or used Timo’s  Extension write back to MYSQL. You can use same XAMPP, however since I already have npm on my machine I was using that as a webserver to host the PHP file which finally writes back the data to SAP HANA.

    Extensions work for both HANA 1.0 and also 2.0(XSA-HDI)

    Step 1: Create a New User on HANA if you don’t already have one

    Make sure the user has a content admin role over the required schema (synonyms/CDS objects if using 2.0).

    Step 2:  As mentioned in MYSQL blog post create similar tables in HANA. You can create a columnar or a row table in HANA according to your needs. Both will work for this solution.

    Note :For autoincrement in HANA for any column you would need to define the column as primary key and make it as IDENTITY 

     

    Step 3: Download and Install required Drivers

    • The code used the 32 bit HDB HANA driver. Execute c:\Windows\SysWOW64\odbcad32.exe in run
    • Download the HDB 32 bit HANA driver from SAP market place(SAP made it far more easier now to download the drivers)
    •  install the drivers 

     

    Step 4: Follow the same instructions from Timo blog post over copying all the required files of the extensions.

    Before testing the HANA insert records PHP file, make sure to modify the ini file under location xampp\php in my case it is under npm. Modifaction requires you to just uncomment below two dll libraries which are already in the INI file.

    extension=php_pdo_odbc.dll
    extension=php_odbc.dll

     

    Step 5: Inserting records into HANA PHP file

    Below is the code : You can run this PHP from your browser to test if statements are working. Easiest way is use Select ‘A’ from dummy staement or even simple INSERT statment with dummy values into the table you created.

    <?php
    $customerName = $_POST['name'];
    $clusterName = $_POST['cluster'];
    $checkBox = $_POST['checkbox'];
    $userInput = $_POST['userinput'];
    $selectedMeasure = $_POST['measure'];
    
    if (! extension_loaded('odbc'))
    {
    die('ODBC extension not enabled / loaded');
    }
    
    
    $driver = 'HDBODBC32';
    
    $host = "HANA:30015";
    
    // Default name of your hana instance
    $db_name = "HDB";
    
    // Username
    $username = 'makkena';
    
    // Password
    $password = "HANA";
    
    // Try to connect
    $conn = odbc_connect("Driver=$driver;ServerNode=$host;Database=$db_name;", $username, $password, SQL_CUR_USE_ODBC);
    
    if (!$conn)
    {
    // Try to get a meaningful error if the connection fails
    echo "Connection failed.\n";
    echo "ODBC error code: " . odbc_error() . ". Message: " . odbc_errormsg();
    }
    else
    {
    // Do a basic select from DUMMY with is basically a synonym for SYS.DUMMY if you need to test in HANA
    $sql = "INSERT INTO CPG.getdataandwriteback (ClusterName,CustomerName,CheckBox,UserInput,SelectedMeasure) VALUES ('".$clusterName."','".$customerName."','".$checkBox."','".$userInput."','".$selectedMeasure."')";
    $result = odbc_exec($conn, $sql);
    if (!$result)
    {
    echo "Error while sending SQL statement to the database server.\n";
    echo "ODBC error code: " . odbc_error() . ". Message: " . odbc_errormsg();
    }
    else
    {
    while ($row = odbc_fetch_object($result))
    {
    var_dump($row);
    }
    }
    odbc_close($conn);
    }

     

     

    Step 6: Update your MarkSelection JS file to refer to this PHP file created above.

    • Assume you are using Timo JS code, just rename the reference of  Timo’s INSERT PHP file to HANA one that you created in Step 5.
    • Also since Timo’s dashboard is using the data source name as MYSQL you might have to change that in case you decide to change the data source name in your dashboard. For example, if I created the Data Source named HANA on these Tables create in the above steps I will have to change the JS script code referencing the data source name.

     

    Step 7: Follow the same steps from Timo’s original blog to test the insert records update from Tableau Dashboard and your done! 😉

  • Tableau + SAP BW

    Tableau + SAP BW

    Do you want to combine different SAP BW Queries on a single Tableau Dashboard? Well, having multiple next to each other on a dashboard is not a problem at all, but how can you make them interact with each other? This is exactly what this blog post is going to demonstrate:

    • If you’re working on a single SAP BW Query and you want to filter from one sheet to another you can do this in the the exact same way you’re used to use relational data sources (Use Sheet as Filter)
    • If you’re using 2 different SAP BW Queries, filtering from one to another get’s a little bit more “tricky”
    • The following video shows you how to interact with multiple SAP BW Queries on a Single Tableau Dashboard.

     

    1. Option: Normal Action Filter
    This works if both Queries are using the same unique remote name (Tableau terminology; Right click on a dimension within the Data Pane in Tableau Desktop -> Describe Field)
    e.g: [0D_NW_CNTRY].[0D_NW_CNTRY].[LEVEL01]

    2. Option: URL Action
    The problem here is that this will open up a new tab if you don’t follow a “workaround” like:  Opening dashboard links in same browser window

    3. Option: URL Action + Web Page Object
    This is my preferred solution so feel free to directly jump to min 3:35 of the tutorial video above

     

    Download the workbook here:
    Tableau + SAP BW (Filter options on 2 seperated Queries)
    (The ZIP file does just contain the *.twb file. I was trying to use SAP BW sample queries only. I’m interested to hear if they work for everyone once you’ve changed

    • TABLEAUSERVER to your <YOUR TABLEAU SERVER URL> and
    • the SAP BW connection to your testing environment

     

    Cheers,
    TT