Quantcast
Channel: SAP HANA Central
Viewing all 711 articles
Browse latest View live

Configuring DP Agent and Remote Source in HANA to read Flat Files Part-1

$
0
0

Setting up DP Agent and Remote Source in HANA


1. Download DPAGENT from SAP Service Marketplace as a SAR file

Extract the SAR file using the following command

SAPCAR -xvf  IMDB_DPAGENT200_03P_20-70002517.SAR

Note: DP Agent version has to match the Hana version. Which version to use is best found out by looking at the PAM for Hana SDI

2. Install DPAgent

Installation Path -> C:\usr\sap\dataprovagent

3. For on-premise assign the following privileges to the user

Assign following privilege

◈ System privilege: AGENT ADMIN
◈ System privilege: ADAPTER ADMIN

For Cloud assign following privileges for the user

Application privilege:

sap.hana.im.dp.admin::Administrator

○ System privilege:

AGENT ADMIN , ADAPTER ADMIN  ,USER ADMIN

○ Object privilege:

EXECUTE on GRANT_APPLICATION_PRIVILEGE

HANA on Cloud

○ Application privilege: sap.hana.im.dp.proxy::AgentMessaging

4. DP Service should be up and running in HANA system. Please confirm this before proceeding to next step

5. Launch DP Agent on your client

Click on Register Agent and given Agent Name.

Click on Connect to HANA  -> Provide your HANA System Details

SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Study Materials

6. Register FileAdapter with HANA

Select FileAdapter and click on Register Adapter

SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Study Materials

SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Study Materials

SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Study Materials

Once you register File Adapter in DP Agent , you can check in HANA under SYS->VIEWS->ADAPTER whether an entry is created

SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Study Materials

7. Tell the DP Agent the location of the folder in which the files to be accessed via Remote Source are saved. For that do the following in preferences of DP Agent.

Go to DPAgent -> Configure menu ->Preferences -> Adapters-> FileAdapter

SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Study Materials

Create a Access Token password . (Need to give this while creating Remote source in HANA)

8. Build the configuration file for the source file. We have to build a configuration file of the text file which we want to access

via Remote Data Source. Use inbuilt agentutils application

C:\usr\sap\dataprovagent\agentutils

SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Study Materials

9. Find the SID – owner of the machine where the file is stored (need to provide this while creating Remote source in HANA)

SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Study Materials

10. Come back to HANA and Create a Remote Source

Provisioning -> Remote Sources -> Create New Remote Source.  (the user must have the privileges mentioned initially)

SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Study Materials

Enter the Access TokenEntry what you created earlier in preferences of DP Agent

11. We can verify the connection is established successfully by going to

Provisioning -> FlatFile . We can see the file that we want to replicate along with other metadata files.

SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Study Materials

So ,now we are able to configure DP Agent and enable a connection to Flat File Remote Source.

SAP S4HANA 1809 Installation complete steps with snaps

$
0
0
Installation of SAP “S4HANA 1809” initial stack on SUSE 12 SP03 with DB SAP HANA Platform Edition 2.0 SPS03 rev33 S4HANA 1809 is the latest release of SAP on-premise edition. The current initial stack is released.

Installation of 1809 is similar to old installation just a few things are changed.
  1. “SWPM 2.0 SP01″ or higher required for 1809 installation.
  2. There is no need to extract 1809 Exports. SWPM will take *.zip file and extract it later.
  3. There are 20 Exports files in 1809.
  4. Import ABAP phase is removed from the installation task list.
  5. SWPM is using backup restore method to install 1809
  6. HANA Platform Edition 2.0 SPS03 rev32 or Higher is required to install 1809.
  7. SAPABAP1 Schema changes to SAPHANADB Schema.
  8. HANA DATABASE is only supported on Linux (SLES, RHEL etc.)
  9. SAP HANA CLIENT .SAR file required for installation.
  10. Supported OS for 1809 as per SAP PAM.
    1. AIX
      1. AIX 7.2
    2. LINUX ON POWER LITTLE ENDIAN
      1. SUSE SLES12/PPC64LE 64BI
      2. REDHAT EL7/PPC64LE 64BIT
    3. LINUX ON X86_64
      1. SUSE SLES12/X86_64 64BIT
      2. REDHAT EL7/X86_64 64BIT
    4. WINDOWS FOR X86_64
      1. WINDOWS SERVER 2016 LTSB 64BIT
  11. I am using the latest Kernel currently which is ” 7.73 Unicode”.
Step1: (Installation of SAP HANA Database using hdblcm)

open Terminal and change the current working directory to

“/media/DATA_UNITS/HDB_SERVER_LINUX_X86_64”

execute “./hdblcm”

provide the inputs to the terminal.

I am using CLI you can also use GUI for installation.


SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

DB installation will complete in 5-10 mins as per hardware performance.

Step2 : (1809 Installation using SWPM 2.0)

Once DB installed

Open Terminal and change the current working directory to

“/media/SWPM/”

execute “./sapinst”

Open Web Browser and paste Url, provide credentials and click ok button.

Select “SAP S\4HANA Server1809” > choose the option as per your requirement.

I had to choose

“SAP S\4HANA Server1809>SAP HANA DATABASE>installation>Application Server ABAP>Standard System”

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

choose typical or custom as per your need.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

enter SID and click next

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

enter FQDN and click next

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

enter DB host details and click on next

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

enter the password of “SYSTEM” user and click next.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

provide the path where kernel files are stored click next to validate the files.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

once files are available click on next

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

as this is poc I am selecting local.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

provide the path where HANA DB Client is stored

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

provide the path where 1809 export is stored

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

enter systemdb “system” users password and click next

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

click next if you want to use master password as schema password else change the password

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

SAPABAP1 is changed to SAPHANADB click next if want to set the master password as schema password

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

click next after required changes in configuration, I didn’t change anything as its poc.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

provide password HANA<dbsid>adm password and click next

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

enter instance no for PAS  and AAS.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

click next if the default setting is okay else change it as per your requirement.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

click next

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

if SLD is configured and you want to add this system select 1st option else select 2nd option

and click next

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

click next

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

for production choose option one.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

review the parameters and click the install button

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

the installation will take 50-90 Mins as per hardware performance.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

Finally installation is completed

Step 3: (login to System using SAP GUI)

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

Verify the installation product version.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Materials

SAP S4HANA 1809 installation is using backup restore method install SAP.

SWPM had extracted backup in

“/hana/share/<SID>/HDB<instance no.>/backup/data/DB_<SID>”

delete this backup and take one backup now.
  1. “SWPM 2.0 SP01″ or higher required for 1809 installation.
  2. There is no need to extract 1809 Exports. SWPM will take *.zip file and extract it later.
  3. Import ABAP phase is removed from the installation task list.
  4. SWPM is using backup restore method to install 1809, installation time is reduced.
  5. HANA Platform Edition 2.0 SPS03 rev32 or Higher is required to install 1809 as backup restore require same or higher DB version to restore the backup.
  6. SAPABAP1 Schema is changed to SAPHANADB Schema.
  7. HANA DATABASE is only supported on Linux (SLES, RHEL etc.)
  8. Supported OS for 1809 as per SAP PAM.
    1. AIX
      1. AIX 7.2
    2. LINUX ON POWER LITTLE ENDIAN
      1. SUSE SLES12/PPC64LE 64BI
      2. REDHAT EL7/PPC64LE 64BIT
    3. LINUX ON X86_64
      1. SUSE SLES12/X86_64 64BIT
      2. REDHAT EL7/X86_64 64BIT
    4. WINDOWS FOR X86_64
    5. WINDOWS SERVER 2016 LTSB 64BIT
  9. I am using the latest Kernel currently which is ” 7.73 Unicode”.
  10. You can also install SAP HANA Database using SWPM, as part of the installation procedure. Just download relevant media and provide the path in SWPM when prompted.

SAP S/4 HANA 1809 complete Installation on SUSE Linux with screenshot step by step

$
0
0
This blog will help to install S/4 HANA 1809 installation, installation of SAP 1809 initial pack on SUSE 12 SP03 with HANA Database 2.0 REV33 Platform Edition.

Minimum requirements:-

OPERATING SYSTEM:-


◈ LINUX ON X86_64

1. SUSE SLES12/X86_64 64BIT
2. REDHAT EL7/X86_64 64BIT

DATABSE:-


◈ HANA Platform Edition 2.0 SPS03 rev32 or Higher

SWPM:-

◈ “SWPM 2.0 SP01″ or higher required for 1809 installation

SOME IMPORTANT POINTS THAT YOU SHOULD KNOW:-


◈ Import ABAP phase is removed from the installation task list.
◈ To reduce installation time sap has removed import ABAP task from task list
◈ SAPABAP1 Schema is changed to SAPHANADB Schema
◈ There is no need to extract 1809 Exports. SWPM will take *.zip file and extract it later
◈ “SWPM 2.0 SP01″ or higher required for 1809 installation.
◈ I am using the latest Kernel currently which is ” 7.73 Unicode”.

FOLLOW BELOW STEPS:-


Installation of HANA Database

Open terminal go to HANA DB & execute ./HDBLCM

HANA DB INSTALLATION…

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

I AM PERFORMING INSTALLATION ON DEV SERVER HENCE CHOSEN 3, YOU CAN SELECT AS PER YOUR REQUIREMENT

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

HANA DB WILL TAKE 15 TO 20 MINUTES TO INSTALL

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

START  (SWPM 2.0)

SWPM>./sapinst

NOW OPEN URL IN WEB BROWSER , FOLLOWING WINDOW WILL APPEAR..

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

SELECT TYPICAL OR CUSTOM AS PER YOUR REQUIREMENT

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

ENTER SID

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

ENTER FQDN

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

ENTER MASTER PASSWORD

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

ITS TAKING MASTER PASSWORD DEFAULT , YOU CAN CHANGE IT , IT WILL BE A <SIDADM> PASSWORD

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

GIVE DB DB-HOST & INSTANCE NO OF DATABASE

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

ENTER PASSWORD FOR “SYSTEM” USER

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

PROVIDE THE PATH WHERE KERNEL FILES ARE LOCATED IN MEDIA

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

CHOOSE HANA DB CLIENT SOFTWARE PATH AS PER YOUR LANDSCAPE

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

ENTER SYSTEM DB “SYSTEM” USERS PASSWORD AND CLICK ON NEXT

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

YOU CAN CHANGE SCHEMA PASSWORD OR CLICK ON NEXT TO KEEP MASTER PASSWORD

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

SAPABAP1 IS CHANGED TO SAPHANADB

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

CHANGE ANYTHING IF REQUIRED

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

PROVIDE PASSWORD FOR <DBSID>

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

ENTER INSTANCE NO FOR AAS & PAS

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

CLICK NEXT IF DEFAULT OPTION IS OK

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

PASSWORD FOR <WEBADM>

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

SELECT SLD OPTION AS PER YOUR LANDSCAPE

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

CLICK NEXT

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

INSTALL DISPATCHER AS PER YOUR REQUIREMENT IN MY CASE I DON’T NEED

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

FOR PRODUCTION SELECT OPTION ONE

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

REVIEW PARAMETERS

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

INSTALLATION WILL TAKE 1 TO 2 HRS AS PER HARDWARE PERFORMANCE

INSTALLATION HAS BEEN COMPLETED 

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

YOU CAN VERIFY (LOGIN TO SAP GUI & IN SYSTEM STATUS YOU CAN SEE AS BELOW)

SAP HANA, SAP S/4HANA Cloud, 1809 installation, SAP HANA Study Materials, SAP HANA Guides

CONGRATULATIONS..!!! YOU HAVE SUCCESSFULLY COMPLETED S/4 HANA 1809 INSTALLATION.

Creating Virtual Table in WEB IDE for Flat file present in Remote Source Part 2

$
0
0
In Previous Part– we have understood how to configure DP Agent and enable a connection from HANA to Flat File Reomote source.

Let’s create a virtual table for the object “FILECONTENTTEXT” present in the Remote Source ,FlatFile.

Create following roles

SAP HANA Tutorial and Material, SAP HANA Guides, SAP HANA Learning, SAP HANA Certifications

2. Create a User Self Service through which the above roles will be assigned to the Container Object owner and Application User

Login to XS Command Line Interface and execute following command to create User Self Service

SAP HANA Tutorial and Material, SAP HANA Guides, SAP HANA Learning, SAP HANA Certifications

3. Update the mta.yaml file.

SAP HANA Tutorial and Material, SAP HANA Guides, SAP HANA Learning, SAP HANA Certifications

4. Select the src folder and build it.

5. Create a hdbgrants file

SAP HANA Tutorial and Material, SAP HANA Guides, SAP HANA Learning, SAP HANA Certifications

6. Select the src folder and build it.

7. Create a Virtual Table named as vtable

Right click on src-> New -> virtual table

SAP HANA Tutorial and Material, SAP HANA Guides, SAP HANA Learning, SAP HANA Certifications

8. Create a Virtualtable config file

Right click on src-> New -> File

Give name as vtable.hdbvirtualtableconfig

SAP HANA Tutorial and Material, SAP HANA Guides, SAP HANA Learning, SAP HANA Certifications

9. Select the src folder and build it.

So , now we have built the virtual table.

HANA Scale-Up HA with System Replication & Automated Failover using SUSE HAE on SLES 12 SP 3 – Part 1

$
0
0
This blog, will give you insight on System Replication and SuSE High Availability Extension overview. It will also provide you details on the various method, services and agents involved to setup automatic failover of HANA.

Scope


Below are the system version on which this document has been prepared. For more updated information, always use the latest SAP Notes and Guide to best implement High Availability for HANA.

HANA Version – HDB 2.0.030.00 (Scale-Up)

SuSE Version – SLES 12 SP 03

SuSE High Availability Extension Version – SLES HAE 12 SP 03

Scenario Implemented – Performance Optimized Scenario


HANA High Availability Overview


SAP HANA database runs mission critical applications and it is important that these systems remain available to users always. This requires that these systems can make faster recovery after system component failure (High Availability) or after a disaster (Disaster Recovery). This should happen without any data loss (zero RPO) and in very short recovery time (low RTO).

To provide fault recovery SAP HANA software includes a watchdog function, that automatically restarts configured services (index server, name server, and so on) in case of their failure. In addition to these features, SAP and its partners offer the following high availability mechanism for SAP HANA. These solutions are based on completely redundant servers and/or storage.

◈ Host Auto-Failover: One (or more) standby nodes are added to a SAP HANA system and configured to work in standby mode. In case of failure, data and log volumes of a failed worker node is taken over by a standby node. The standby node becomes a worker node and takes over user load. This solution does not need additional storage, only servers.

◈ SAP HANA System Replication: SAP HANA replicates all data to a secondary SAP HANA system constantly. Data can be constantly pre-loaded in the memory of the secondary system to minimize the recovery time objective (RTO). This solution needs additional servers and storage. The focus of this reference architecture guide is SAP HANA System Replication.

◈ Storage Replication: Data replication is achieved by means of storage mirroring independent from the database software. Disks are mirrored without a control process from the SAP HANA system. SAP HANA hardware partners offer this solution. This solution needs additional servers and storage.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Material

SAP HANA System Replication


SAP HANA System Replication is implemented between two different SAP HANA systems with same number of active nodes. After system replication is setup between the two SAP HANA systems, it replicates all the data from the primary HANA system to the secondary HANA system (initial copy). After this, any logged changes in the primary system are also sent to the secondary system. The following replication modes are available for this procedure:

◈ Synchronous on disk (mode=sync): Transaction is committed after log entries are written on primary and secondary systems.

◈ Synchronous in memory (mode=syncmem): Transaction is committed after the secondary system receives the logs, but before they are written to disks.

◈ Asynchronous (mode=async): Transaction is committed after log entries are sent without any response from the secondary system.

◈ Full Sync: Full synchronization is supported by SAP but cannot be configured with SUSE HAE. Full Sync mode stops the surviving node if either node is down, so failover with SUSE HAE is not possible.

If the primary SAP HANA system fails, the system administrator must perform a manual takeover. Takeover can be performed using SAP HANA Studio or the command line. Manual failover requires continuous monitoring and could lead to higher recovery times. To automate the failover process, SUSE Linux Enterprise High Availability Extension (SUSE HAE) can be used or you can any third party vendor. The use of SUSE HAE for the takeover process helps customers achieve service level agreements for SAP HANA downtime by enabling faster recovery without any manual intervention.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Material

SUSE High Availability Extension (HAE) Resource Agents (RA)


SUSE has implemented the scale-up scenario with the SAPHana resource agent (RA), which performs the actual check of the SAP HANA database instances. This RA is configured as a master/slave resource. In the scale-up scenario, the master assumes responsibility for the SAP HANA databases running in primary mode, and the slave is responsible for instances that are operated in synchronous (secondary) status.

To make configuring the cluster as simple as possible, SUSE also developed it’s SAPHanaTopology resource agent. This runs on all nodes of an SLE 12 HAE cluster and gathers information about the statuses and configurations of SAP HANA system replications. It is designed as a normal (stateless) clone.

SAP HANA System replication for Scale-Up is supported in the following scenarios or use cases:

◈ Performance Optimized
◈ Cost Optimized
◈ Multi-tier
◈ Multi-tenancy or MDC

Concept of the Performance Optimized Scenario

In case of failure of the primary SAP HANA on node 1 (node or database instance) the cluster first tries to start the takeover process. This allows to use the already loaded data at the secondary site. Typically, the takeover is much faster than the local restart. To achieve an automation of this resource handling process, we can utilize the SAP HANA resource agents included in SAPHanaSR. System replication of the productive database is automized with SAPHana and SAPHanaTopology and the details of this agent and its usage is explained below.

You can setup the level of automation by setting the parameter AUTOMATED_REGISTER. If automated registration is activated the cluster will also automatically register a former failed primary to get the new secondary.

To get more insight on Scenarios, you can refer to the link provided in Reference Section.

SAPHana Agent


The SAPHanaSR resource agent manages two SAP HANA database systems which are configured in system replication. SAPHana supports Scale-Up scenarios. Managing the two SAP HANA database systems means that the resource agent controls the start/stop of the instances. In addition the resource agent is able to monitor the SAP HANA databases to check their availability on landscape host configuration level. For this monitoring the resource agent relies on interfaces provided by SAP. A third task of the resource agent is to also check the synchronization status of the two SAP HANA databases. If the synchronization is not “SOK”, then the cluster avoids to failover to the secondary side, if the primary fails. This is to improve the data consistency.

The resource agent uses the following four interfaces provided by SAP:

◈ sapcontrol/sapstartsrv: The interface sapcontrol/sapstartsrv is used to start/stop a HANA database instance/system

◈ landscapeHostConfiguration: The interface is used to monitor a HANA system. The python script is named landscapeHostConfiguration.py. landscapeHostConfiguration.py has some detailed output about HANA system status and node roles. For our monitor the overall status is relevant. This overall status is reported by the returncode of the script: 0: Internal Fatal, 1: ERROR, 2: WARNING, 3: INFO, 4: OK The SAPHana resource agent will interpret returncodes 0 as FATAL, 1 as not-running or ERROR and and returncodes 2+3+4 as RUNNING.

◈ hdbnsutil: The interface hdbnsutil is used to check the “topology” of the system replication as well as the current configuration (primary/secondary) of a SAP HANA database instance. A second task of the interface is the possibility to run a system replication takeover (sr_takeover) or to register a former primary to a newer one (sr_register).

◈ hdbsql / systemReplicationStatus: Interface is SQL query into HANA (system replication table). The hdbsql query will be replaced by a python script “systemReplicationStatus.py” in SAP HANA SPS8 or 9. As long as we need to use hdbsql you need to setup secure store users for linux user root to be able to access the SAP HANA database. You need to configure a secure store user key “SAPHANASR” which can connect the SAP HANA database:

◈ saphostctrl: The interface saphostctrl uses the function ListInstances to figure out the virtual host name of the SAP HANA instance. This is the hostname used during the HANA installation.

SAPHanaTopology Agent


This Resource Agent (RA) analyzes the SAP HANA topology and “sends” all findings via the node status attributes to all nodes in the cluster. These attributes are taken by the SAPHana RA to control the SAP Hana Databases. In addition it starts and monitors the local saphostagent.

◈ Interface to monitor a HANA system (landscapeHostConfiguration.py): landscapeHostConfiguration.py has some detailed output about HANA system status and node roles. For our monitor the overall status is relevant. This overall status is reported by the returncode of the script: 0: Internal Fatal 1: ERROR 2: WARNING 3: INFO (maybe a switch of the resource running) 4: OK The SAPHanaTopology resource agent will interpret returncodes 1 as NOT-RUNNING (or 1 failure) and returncodes 2+3+4 as RUNNING. SAPHanaTopology scans the output table of landscapeHostConfiguration.py to identify the roles of the cluster node. Roles means configured and current role of the nameserver as well as the indexserver.

◈ Interface is hdbnsutil: The interface hdbnsutil is used to check the “topology” of the system replication as well as the current configuration (primary/secondary) of a SAP HANA database instance. A second task of the interface is the posibility to run a system replication takeover (sr_takeover) or to register a former primary to a newer one (sr_register).

◈ saphostctrl: The interface saphostctrl uses the function ListInstances to figure out the virtual host name of the SAP HANA instance. This is the hostname used during the HANA installation.

IP Agent


This Linux-specific resource manages IP alias IP addresses. On creating resource, virtual IP will be attached to primary site and this virtual IP will to move to secondary in case of failover.

SUSE HAE Supported Scenarios and Pre-requisites


With the SAPHanaSR resource agent software package, suse limit the support to Scale-Up (single-box to single-box) system replication with the following configurations and parameters:

◈ Two-node clusters.

◈ The cluster must include a valid STONITH method.

– Any STONITH mechanism supported by SLE 12 HAE (like SDB, IPMI) is supported with SAPHanaSR.
– This guide is focusing on the sbd fencing method as this is hardware independent.
– If you use sbd as the fencing mechanism, you need one or more shared drives. For productive environments, we recommend more than one sbd device.

◈ Both nodes are in the same network segment (layer 2).

◈ Technical users and groups, such as adm are defined locally in the Linux system.

◈ Name resolution of the cluster nodes and the virtual IP address must be done locally on all cluster nodes.

◈ Time synchronization between the cluster nodes using NTP.

◈ Both SAP HANA instances have the same SAP Identifier (SID) and instance number.

◈ If the cluster nodes are installed in different data centers or data center areas, the environment must match the requirements of the SLE HAE cluster product. Of concern are the network latencies and recommended maximum distance between the nodes. Please review our product documentation for SLE HAE about those recommendations.

◈ Automated registration of a failed primary after takeover.

– As a good starting configuration for projects, we recommend switching off the automated registration of a failed primary. The setup AUTOMATED_REGISTER=”false” is the default. In this case, you need to register a failed primary after a takeover manually. Use SAP tools like hana studio or hdbnsutil.
– For optimal automation, we recommend AUTOMATED_REGISTER=”true”.

◈ Automated start of SAP HANA instances during system boot must be switched off.

Important: Valid STONITH Method – Without a valid STONITH method, the complete cluster is unsupported and will not work properly.

Solution Overview


This blog provides an example configuration of SAP HANA High Availability using SAP HANA System Replication and automated takeover using SUSE HAE and SAPHanaSR resource agents. SAP HANA Scale-up systems are based on IBM Servers which uses POWER architecture. Each HANA server is running on separate Physical box of IBM compute where servers are created using LPAR technology. The two SAP HANA scale-up systems are installed in separate LPAR of two different physical boxes.

We have installed HANA as Multi-Tenant Database Container (MDC) where we can create multiple tenant in single database running on single SAP HANA server.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Study Material

ParameterValue Role 
Cluster Node 1XXXXXXXXX4021Cluster Node Name
Cluster Node 2 YYYYYYYYY4022 Cluster Node Name 
SID SLH (SYSTEMDB)
SL1 (TenantDB)
SAP Identifier (SID) 
Instance Number 00 Number of the SAP HANA database. For system replication also, Instance Number+1 is blocked. 
Network Address 10.XX.YYY.0/24 
Network Mask 10.XX.YYY.255
Virtual IP Address 10.XX.YYY.219 
Storage Storage for HDB data and log files is connected “locally” (per node; not shared)
SBD/dev/disk/by-id/scsi-360000970000197700209533031354139 STONITH Device 
Hawk Port7630
NTP Server Address or name of your time server. 

Solving the Knight’s Tour Problem with HANA Graph

$
0
0
The problem is best summarised as the following: “find a succession of moves of a knight piece on a chess board such that the knight visits each square exactly once”.
SAP HANA Tutorial and Materials, SAP HANA Certification, SAP HANA Guides, SAP HANA Learning

Graph Theory



We can model the chess board like a graph with the squares as the vertices and all the possible moves as the edges.

By using this abstraction, the problem actually boils down to a special case of the more general Hamiltonian Path problem, which is basically the search of a path traversing all vertices of a graph exactly once.


SAP HANA Tutorial and Materials, SAP HANA Certification, SAP HANA Guides, SAP HANA Learning

Graph Engine



HANA has built-in support for processing graphs. As of now, it has the following main features:

◈ Storing and representing graphs (basically you need a vertex and an edge table and then you can create a so-called “workspace” out of them).
◈ Running some simple algorithms on graphs (neighbourhood, shortest path, connected components, etc).
◈ Performing queries based on the openCypher query language.
◈ Writing stored procedures using a dedicated GraphScript language.

To solve this problem, I used the stored procedures together with the graph representation.

Chess Board


The first step would be to generate the chess board as a graph. We will label the rows from 1 to 8 and the columns from A to H:


SAP HANA Tutorial and Materials, SAP HANA Certification, SAP HANA Guides, SAP HANA Learning

To store the graph, I defined the data model as follows:


CREATE TABLE nodes (
label VARCHAR(2),
row_number INT NOT NULL,
col_number INT NOT NULL,
PRIMARY KEY (label)
);

CREATE TABLE edges(
label VARCHAR(5) NOT NULL,
from_node VARCHAR(2) NOT NULL,
to_node VARCHAR(2) NOT NULL,
PRIMARY KEY (label)
);

CREATE GRAPH WORKSPACE board
  EDGE TABLE edges SOURCE COLUMN from_node 
    TARGET COLUMN to_node KEY COLUMN label
  VERTEX TABLE nodes KEY COLUMN label;

I did not want to manually define the board, so I wrote a procedure for generating it for me based on an input size:

CREATE OR REPLACE PROCEDURE generate_board_for_knights(
    IN size INT, 
    OUT nodes TABLE(
        label VARCHAR(2),
        row_number INT,
        col_number INT
    ),
    OUT edges TABLE(
        label VARCHAR(5),
        from_node VARCHAR(2),
        to_node VARCHAR(2)
    )
) LANGUAGE SQLSCRIPT READS SQL DATA AS BEGIN
    nodes = SELECT col_label || row_label AS label, 
                row_number, col_number
        FROM (
           -- generate row numbers from 1 to 8
           SELECT GENERATED_PERIOD_START AS row_number, 
              TO_VARCHAR(GENERATED_PERIOD_START) AS row_label 
              FROM SERIES_GENERATE_INTEGER(1, 1, 9)
        ) AS row_table
        CROSS JOIN (
           -- generate column numbers from 1 to 8
           -- and column labels from A to H
           SELECT GENERATED_PERIOD_START AS col_number, 
              NCHAR(ASCII('A') + GENERATED_PERIOD_START - 1) AS col_label 
              FROM SERIES_GENERATE_INTEGER(1, 1, 9)
        ) AS col_table; 
           -- the edge label is simply the node labels
           -- joined by a hyphen (e.g. A1-C2)
    edges = SELECT A.label || '-' || B.label AS label, 
              A.label AS from_node, B.label AS to_node 
              FROM :nodes AS A CROSS JOIN :nodes AS B
            WHERE  (ABS(A.row_number - B.row_number) = 2 
              AND ABS(A.col_number - B.col_number) = 1)
              OR (ABS(A.row_number - B.row_number) = 1 
              AND ABS(A.col_number - B.col_number) = 2);
END;

After creating the procedure, I was able to simply call it to fill my tables:

CALL "GENERATE_BOARD_FOR_KNIGHTS"(8, nodes, edges) WITH OVERVIEW;

WebIDE has a built-in graph viewer which provides a pretty nice visualisation of the chess board:


SAP HANA Tutorial and Materials, SAP HANA Certification, SAP HANA Guides, SAP HANA Learning

Lastly, I defined a table type for representing paths:


CREATE TYPE tt_path AS TABLE(label VARCHAR(2));

Naive Approach


The first idea that came to my mind was to try to solve it via backtracking. I decided to not do it, because of the fact that it would be simply too slow.

Vanilla backtracking has an exponential asymptotic time complexity. In our graph each node has potentially 8 neighbours and we have to find a 64-node long path, so it would need to do (slightly less than) 8 ^ 64 steps to finish the whole algorithm.

Of course, if we would stop when we find the first solution it will be faster, but I still decided that there must be a better solution.

Greedy Algorithm


After thinking on it a while, I decided that it should be possible to find a solution using a greedy algorithm with an appropriate selection heuristic.

The first heuristic that I tried was to always try to go towards the bottom of the board and slowly fill in from there. After fighting a little with the GraphScript language, I wrote the following procedure:

CREATE OR REPLACE PROCEDURE "FIND_HAMILTONIAN_PATH" (
  IN iv_origin VARCHAR(2),
  OUT ot_path tt_path
) LANGUAGE GRAPH READS SQL DATA AS
BEGIN
  Graph lo_graph = Graph("BOARD");
  BigInt lv_size = Count(Vertices(:lo_graph));

  -- retrieve the start point from the graph based on the origin label
  Vertex lo_current = Vertex(:lo_graph, :iv_origin);
  Sequence<Vertex> lt_nodes = [:lo_current];
  ALTER lo_graph ADD TEMPORARY VERTEX ATTRIBUTE(Boolean visited = false);
  
  WHILE (COUNT(:lt_nodes) <= :lv_size) {
    lo_current."VISITED" = true;
    Boolean lf_found = false;
    Int lv_row = -1;
    Int lv_col = -1;
    
    FOREACH lo_neighbor IN NEIGHBORS(:lo_graph, { :lo_current }, 1, 1) {
      -- first try to go on lower rows
      -- if the row is the same, go towards the left corner
      IF (NOT :lo_neighbor."VISITED" 
          AND (:lv_row < :lo_neighbor."ROW_NUMBER" 
          OR (:lv_row == :lo_neighbor."ROW_NUMBER" 
          AND :lv_col < :lo_neighbor."COL_NUMBER"))) {
        lv_row = :lo_neighbor."ROW_NUMBER";
        lv_col = :lo_neighbor."COL_NUMBER";
        lf_found = true;
        lo_current = :lo_neighbor;
      }
    }
    
    -- stop the loop if we did not find a next node 
    -- this avoids infinite loops which do not do anything
    IF (NOT :lf_found) {
      BREAK;
    }
    
    -- append the next node to the path
    lt_nodes = :lt_nodes || [:lo_current];
  }
  
  ot_path = SELECT :lo_node.label FOREACH lo_node IN :lt_nodes;
END;

Unfortunately, this approach failed miserably, yielding mediocre results:


SAP HANA Tutorial and Materials, SAP HANA Certification, SAP HANA Guides, SAP HANA Learning

The problem looked to me like once the bottom half of the board was almost full, the knight got into a dead end. To prevent this, I tried applying a different heuristic: to always go as close as possible to the center of the board.


CREATE OR REPLACE PROCEDURE "FIND_HAMILTONIAN_PATH" (
  IN iv_origin VARCHAR(2), 
  OUT ot_path tt_path
) LANGUAGE GRAPH READS SQL DATA AS 
BEGIN
  Graph lo_graph = Graph("BOARD");

  -- get the size of the graph and use it throughout the algorithm
  BigInt lv_size = Count(Vertices(:lo_graph));

  -- retrieve the start point from the graph based on the origin label
  Vertex lo_current = Vertex(:lo_graph, :iv_origin);
  Sequence<Vertex> lt_nodes = [:lo_current];
  ALTER lo_graph ADD TEMPORARY VERTEX ATTRIBUTE(Boolean visited = false);
  
  WHILE (COUNT(:lt_nodes) <= :lv_size) {
    lo_current."VISITED" = true;
    Boolean lf_found = false;
    BigInt lv_score = 4L * :lv_size;
    
    FOREACH lo_neighbor IN NEIGHBORS(:lo_graph, { :lo_current }, 1, 1) {
      IF (NOT :lo_neighbor."VISITED") {
        -- compute the delta (4.5 would be the middle of the board, but we
        -- multiply everything by 2 to be able to use integers)
        BigInt lv_row_delta = 2L * BIGINT(:lo_neighbor."ROW_NUMBER") - 9L;

        -- do an ABS, because GraphScript does not support math functions
        IF (:lv_row_delta < 0L) {
          lv_row_delta = :lv_row_delta * -1L;
        }

        BigInt lv_col_delta = 2L * BIGINT(:lo_neighbor."COL_NUMBER") - 9L;
        IF (:lv_col_delta < 0L) {
          lv_col_delta = :lv_col_delta * -1L;
        }

        IF (:lv_score > :lv_col_delta + :lv_row_delta) {
          lv_score = :lv_col_delta + :lv_row_delta;
          lo_current = :lo_neighbor;
          lf_found = true;
        }
      }
    }
    
    IF (NOT :lf_found) {
      BREAK;
    }
    
    -- append the next node to the path
    lt_nodes = :lt_nodes || [:lo_current];
  }
  
  ot_path = SELECT :lo_node.label FOREACH lo_node IN :lt_nodes;
END;

I envisioned that the knight will spin around the center of the board. What I did not realise is that this approach would basically cut off the corners of the board leading the knight to be stuck in one of the corners:


SAP HANA Tutorial and Materials, SAP HANA Certification, SAP HANA Guides, SAP HANA Learning

Seeing that my heuristics are not working, I decided to read a little literature on the topic.


Warnsdorff Rule



After reading some papers, I found out that I was very close to a correct solution. The heuristic that I was searching for was to always select the next node to be the one with the smallest degree. That is, we select the node which has the smallest amount of not-yet-visited neighbours.

CREATE OR REPLACE PROCEDURE "FIND_HAMILTONIAN_PATH_VIA_WARNSDORFF" (
  IN iv_origin VARCHAR(2), 
  OUT ot_path tt_path
) LANGUAGE GRAPH READS SQL DATA AS 
BEGIN
  Graph lo_graph = Graph("BOARD");

  -- get the size of the graph and use it throughout the algorithm
  BigInt lv_size = Count(Vertices(:lo_graph));

  -- retrieve the start point from the graph based on the origin label
  Vertex lo_current = Vertex(:lo_graph, :iv_origin);

  Sequence<Vertex> lt_nodes = [:lo_current];
  ALTER lo_graph ADD TEMPORARY VERTEX ATTRIBUTE(Boolean visited = false);
  
  WHILE (COUNT(:lt_nodes) <= :lv_size) {
    lo_current.visited = true;
    Boolean lf_found = false;
    BigInt lv_min = :lv_size;
    
    FOREACH lo_first IN NEIGHBORS(:lo_graph, { :lo_current }, 1, 1) {
      IF (NOT :lo_first.visited) {
        BigInt lv_first_count = 0L;

        -- compute the degree of each neighbour
        FOREACH lo_second IN NEIGHBORS(:lo_graph, { :lo_first }, 1, 1) {
          IF (NOT :lo_second.visited AND :lo_second != :lo_current) {
            lv_first_count = :lv_first_count + 1L;
          }
        }
        
        -- go for the minimal degree
        IF (:lv_first_count < :lv_min) {
          lo_current = :lo_first;
          lv_min = :lv_first_count;
          lf_found = true;
        }
      }
    }
    
    IF (NOT :lf_found) {
      BREAK;
    }
    
    -- append the next node to the path
    lt_nodes = :lt_nodes || [:lo_current];
  }
  
  ot_path = SELECT :lo_node.label FOREACH lo_node IN :lt_nodes;
END;

Basically, this would yield the exact opposite result as the image above: first visit the margins of the board, then the center:


SAP HANA Tutorial and Materials, SAP HANA Certification, SAP HANA Guides, SAP HANA Learning

I finally got a solution! But what I don’t like at this heuristic is that the, when we have to decide on the next node and there are two nodes with the exact same score, we always take the first one. In the literature, they usually take one at random. Sometimes this heuristic may not be able to yield a result (although I never encountered this situation), so I wanted to improve it further.


Pohl’s Tie Breaking



One possible way of breaking ties would be to repeatedly apply the selection mechanism on the candidate nodes. Because I cannot really write a recursive call using GraphScript, I decided to go for a single level:

◈ First find all candidate nodes based on the Warnsdorff rule.
◈ If there is only one candidate, select that one.
◈ Otherwise, compute the minimal neighbour degree for each candidate and select the one with the smallest value. At this point, we could again reach a tie, so we just select the first one (this would be solved via recursion – except for the perfectly symmetrical arrangements).

CREATE OR REPLACE PROCEDURE "FIND_HAMILTONIAN_PATH_VIA_WARNSDORFF_AND_POHL" (
  IN iv_origin VARCHAR(2), 
  OUT ot_path tt_path
) LANGUAGE GRAPH READS SQL DATA AS 
BEGIN
  Graph lo_graph = Graph("BOARD");

  -- get the size of the graph and use it throughout the algorithm
  BigInt lv_size = Count(Vertices(:lo_graph));

  -- retrieve the start point from the graph based on the origin label
  Vertex lo_current = Vertex(:lo_graph, :iv_origin);

  Sequence<Vertex> lt_nodes = [:lo_current];
  ALTER lo_graph ADD TEMPORARY VERTEX ATTRIBUTE(Boolean visited = false);
  
  WHILE (COUNT(:lt_nodes) <= :lv_size) {
    lo_current.visited = true;
    BigInt lv_min = :lv_size;
    
    -- we will use this sequence to store candidate nodes
    Sequence<Vertex> lt_candidates = Sequence<Vertex>(:lo_graph);
    
    FOREACH lo_first IN NEIGHBORS(:lo_graph, { :lo_current }, 1, 1) {
      IF (NOT :lo_first.visited) {
        BigInt lv_first_count = 0L;

        -- compute the degree of each candidate
        FOREACH lo_second IN NEIGHBORS(:lo_graph, { :lo_first }, 1, 1) {
          IF (NOT :lo_second.visited) {
            lv_first_count = :lv_first_count + 1L;
          }
        }

        -- add the candidate to the list if needed
        IF (:lv_first_count < :lv_min) {
          lv_min = :lv_first_count;
          lt_candidates = [ :lo_first ];
        } ELSE {
          IF (:lv_first_count == :lv_min) {
            lt_candidates = :lt_candidates || [ :lo_first ];
          }
        }
      }
    }
    
    -- terminate the algorithm if no candidates were found
    IF (COUNT(:lt_candidates) == 0L) {
      BREAK;
    } ELSE {

      -- select the single candidate if only one was found
      IF (COUNT(:lt_candidates) == 1L) {
        lo_current = :lt_candidates[1L];

      -- otherwise, apply the tie-breaking heuristic
      } ELSE {
        lv_min = :lv_size;
        FOREACH lo_candidate IN :lt_candidates {
          BigInt lv_candidate_min = :lv_size;
          
          -- find the minimum neighbour degree for each candidate
          FOREACH lo_first IN NEIGHBORS(:lo_graph, {:lo_candidate}, 1, 1) {
            BigInt lv_first_count = 0L;
            IF (NOT :lo_first.visited) {
              FOREACH lo_second IN NEIGHBORS(:lo_graph, {:lo_first}, 1, 1) {
                IF (NOT :lo_second.visited AND :lo_second != :lo_candidate) {
                  lv_first_count = :lv_first_count + 1L;
                }
              }
            }
            IF (:lv_first_count < :lv_candidate_min) {
              lv_candidate_min = :lv_first_count;
            }
          }

          -- select the candidate with the smallest minimum neighbour degree
          IF (:lv_candidate_min <= :lv_min) {
            lo_current = :lo_candidate;
            lv_min = :lv_candidate_min;
          }
        }
      }
    }
    
    -- add the next node to the path
    lt_nodes = :lt_nodes || [:lo_current];
  }
  
  ot_path = SELECT :lo_node.label FOREACH lo_node IN :lt_nodes;
END;

Running it seems to generate the expected result:


SAP HANA Tutorial and Materials, SAP HANA Certification, SAP HANA Guides, SAP HANA Learning

I still don’t like this solution, because even for asymmetrical arrangements, because of the lack of recursion, we still have to take a random choice.


Roth’s Tie Breaking



Another idea for the tie breaking is to select from the candidate nodes based on the distance from the center of the board (take the node with the maximal distance to the center of the board):

CREATE OR REPLACE PROCEDURE "FIND_HAMILTONIAN_PATH_VIA_WARNSDORFF_AND_ROTH" (
  IN iv_origin VARCHAR(2), 
  OUT ot_path tt_path
) LANGUAGE GRAPH READS SQL DATA AS 
BEGIN
  Graph lo_graph = Graph("BOARD");

  -- get the size of the graph and use it throughout the algorithm
  BigInt lv_size = Count(Vertices(:lo_graph));

  -- retrieve the start point from the graph based on the origin label
  Vertex lo_current = Vertex(:lo_graph, :iv_origin);

  Sequence<Vertex> lt_nodes = [:lo_current];
  ALTER lo_graph ADD TEMPORARY VERTEX ATTRIBUTE(Boolean visited = false);
  
  WHILE (COUNT(:lt_nodes) <= :lv_size) {
    lo_current.visited = true;
    BigInt lv_min = :lv_size;

    -- we will use this sequence to store candidate nodes
    Sequence<Vertex> lt_candidates = Sequence<Vertex>(:lo_graph);
    
    FOREACH lo_first IN NEIGHBORS(:lo_graph, { :lo_current }, 1, 1) {
      IF (NOT :lo_first.visited) {
        BigInt lv_first_count = 0L;

        -- compute the degree of each candidate
        FOREACH lo_second IN NEIGHBORS(:lo_graph, { :lo_first }, 1, 1) {
          IF (NOT :lo_second.visited) {
            lv_first_count = :lv_first_count + 1L;
          }
        }

        -- add the candidate to the list if needed
        IF (:lv_first_count < :lv_min) {
          lv_min = :lv_first_count;
          lt_candidates = [ :lo_first ];
        } ELSE {
          IF (:lv_first_count == :lv_min) {
            lt_candidates = :lt_candidates || [ :lo_first ];
          }
        }
      }
    }
    
    -- terminate the algorithm if no candidates were found
    IF (COUNT(:lt_candidates) == 0L) {
      BREAK;
    } ELSE {

      -- select the single candidate if only one was found
      IF (COUNT(:lt_candidates) == 1L) {
        lo_current = :lt_candidates[1L];

      -- otherwise, apply the tie-breaking heuristic
      } ELSE {
        Double lv_max_distance = -1.0;
        FOREACH lo_candidate IN :lt_candidates {
          -- compute the distance between the vertex and the board center
          Double lv_distance = (DOUBLE(:lo_candidate."ROW_NUMBER") - 4.5) 
             * (DOUBLE(:lo_candidate."ROW_NUMBER") - 4.5) 
             + (DOUBLE(:lo_candidate."COL_NUMBER") - 4.5) 
             * (DOUBLE(:lo_candidate."COL_NUMBER") - 4.5);
          -- select the candidate with maximal distance
          IF (:lv_distance > :lv_max_distance ) {
            lo_current = :lo_candidate;
            lv_max_distance = :lv_distance;
          }
        }
      }
    }
    
    -- add the next node to the path
    lt_nodes = :lt_nodes || [:lo_current];
  }
  
  ot_path = SELECT :lo_node.label FOREACH lo_node IN :lt_nodes;
END;

Surprisingly, running this for the same starting point generated the same result most of the time as Pohl’s tie-breaking.

Bloopers


I don’t want to give a false impression and make people think that everything went smoothly. I actually encountered a few bugs and limitations which made me waste a few hours of my time:

◈ HANA Express is too large for my computer. I had to clean up 40GB of my laptop to be able to run it. I wanted to use HXE to have access to the latest service pack, but I really started thinking to use an older HANA to which I have access…

◈ I am not very happy with the fact that GraphScript is a completely different language than SQLScript, especially because of the fact that most functions available in SQLScript are not available in GraphScript. For example, there is no ABS in GraphScript.

◈ I did not find a way to pass a Graph object through the procedure interface (e.g. to create a recursive procedure).

◈ The WebIDE is always showing a ton of errors as if all the code is completely broken. To be honest, I would prefer to not have any kind of syntax check and just have syntax highlighting.

◈ Once I introduced the first IF clause, the WebIDE “Run” button would not anymore execute my “CREATE OR REPLACE PROCEDURE” statement. I had to resort to manually sending the code via an jQuery.ajax call from the development console.

jQuery.ajax({
   method: "POST", 
   url: "/sap/hana/cst/api/v2/sessions(...)/connections(...)/sqlExecute()", 
   headers: {"X-CSRF-Token": "..."}, 
   contentType: "application/json", 
   data: JSON.stringify({
      "statements": [{"statement": code, "type": "UPDATE"}],
      "maxResultSize": 1000, 
      "limitLOBColumnSize": 1024, 
      "includePosColumn": true,
      "bExeWithoutPrepare": false,
      "bStopOnError": true,
      "bRunAsBackgroundActivity": false
   })
});

HANA Housekeeping using HANACleaner

$
0
0

Purpose


The blog provide guidelines on the necessary steps that needs to be followed to automate housekeeping task using SAP HANACleaner script.

Background


It’s really a good practice to set up housekeeping task from the early stage of your project as there are some task which you know in advance whereas some housekeeping task comes after your production system go-live like Table Growth.

This blog demonstrate the steps involved to perform housekeeping for cleanup of backup catalog entries. The idea behind performing this activity is that, with time entries in backup catalog table grows which result in higher data footprint at persistent level results in more memory utilization. So, this is one of many tables on which we can perform housekeeping task and keep it under threshold.

Overview


This section will provide an overview on what is HANA Catalog and where it used and how to check its size etc. and all the relevant information with respect to backup.


SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

1. Backup Files – Delete according to backup retention times
2. Backup Catalog – Delete old entries according to backup retention times
3. Trace files backup.log and backint.log – Delete old entries according to backup retention times

For database operation, backup catalog is loaded into main memory so the size of backup catalog matters.

In persistent storage, your actual data/log, parameter and trace files are stored, and the backup of data and log volume are placed in data and log backup. The backup catalog for file-based backups is written as a separate backup to the location where the log backups are stored.

NOTE: Cleanup of backup catalog entries is also necessary if you have third party backup solution.

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Here /backup is backup storage where all data and log backup files are places. The backup of “backup catalog” (log_backup_0_0_0_0.1539032862322) is placed in log backup directory along with log backup.

Manual Housekeeping


Backup files and catalog can manually be deleted using HANA Studio. The method to do so is as below –

In HANA Studio. Login to your SYSTEMDB and open “Backup”

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Select the database for which you want to delete backup files and catalog. This option is only visible if you are in SYSTEMDB database. If you have logged in tenant database and navigated to backup folder, the option for database selection will not be available.

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Right click on the data backup from which you want to delete older backups.

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Here you can just delete the catalog or you can delete the catalog and backup files from the file system location.

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

It will provide you the list of backup files that will be deleted on choosing “Finish”. It will delete all complete, delta and log backups older than the backup you have selected.

IMPORTANT NOTE

In HANA, it is not possible to delete just the log or incremental backup from backup catalog. The reason is obvious as deletion of any random log and incremental backup will make data backup useless for point in time recovery.

Even if you try to delete an entry of log backup from backup catalog, it will result you with error

BACKUP CATALOG DELETE ALL BEFORE BACKUP_ID <backup_id>

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

SAP DBTech JDBC: [452]: invalid backup id: Invalid backup id '<backup_id>'

Automatic Housekeeping – Using HANACleaner Script


Now to get rid of this manual task of deleting catalog, you can schedule a job to delete this catalog on regular basis. You have to perform one-time activity of scheduling a job for the same. The process of doing that is explained below.

Certain SAP HANA cleanup tasks like purging the backup catalog or deleting old trace files (SAP Note 2119087) need to be implemented individually. SAP HANACleaner is now available to perform this task automatically.

The SAP HANA cleaner is a house keeping script for SAP HANA. It can be used to clean the backup catalog, diagnostic files, alerts, to compress the backup logs, and much more. It should be executed by adm or, in case you use a CRON job, with the same environment as the adm. This script is expert tool designed by SAP support. You can use it, but SAP doesn’t take over any responsibility for problems originating from the use of this tool.

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Always refer the latest version of SAP Note to get most updated HANACleaner script.

SAP HANACleaner can be used for the following cleanup tasks:

◈ Cleanup of backup catalog entries
◈ Cleanup of backups
◈ Cleanup of trace files
◈ Cleanup of backup.log and backint.log
◈ Cleanup of audit logs
◈ Cleanup of SAP HANA alerts
◈ Cleanup of free log segments
◈ Cleanup of internal events
◈ Cleanup of multiple row store containers
◈ Cleanup of data file fragmentation
◈ Cleanup of SAP HANACleaner logs
◈ Cleanup of arbitrary directories (e.g. SAP HANASitter logs)
◈ Creation of optimizer statistics for SDA tables
◈ Optimize compression of tables not compressed
◈ Optimize compression of tables with columns not compressed
◈ Optimize compression of tables with large UDIV overhead
◈ Cleanup of object lock history for ‘(unknown)’ objects

This document talks about cleanup of backup catalog entries. Similarly, cleanup for rest of the task can be schedule as per your business need.

Install Phython Script


You can install SAP HANACleaner in the following way:

Download the script mentioned in SAP Note 2399996 or you can use direct link -> https://github.com/chriselswede/hanacleaner.git

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Copy it to a directory on your SAP HANA database server

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Once it is copied, you can explore various options available to execute script. The following command provides you with an overview of the way how SAP HANACleaner works and the available configuration options:

sidadm> python hanacleaner.py --help

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

IMPORTANT NOTE

1. It is intended to be executed as <sid>adm on your HANA server (as environment variable for your python script is already set with <sid>adm on your HANA server).
2. It connects via host, port and DB user provided in hdbuserstore.
3. The DB user needs proper privileges.

Create Users


Create user in all HANA databases (System DB + Tenant DBs)

NOTE: Depending on what housekeeping tasks, the specific hanacleaner user will need specific sets of privileges. As I just want to delete backup catalog entries, I have used below set of roles.

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Disable the expiry of user by executing SQL command –

ALTER USER HKPSCH DISABLE PASSWORD LIFETIME;

Create similar users in all Tenant Databases (I have 3 tenants, so have created users in all 3 tenants) and disable the expiry of users

Configure hdbuserstore


As mentioned earlier, python script connects via host, port and DB user provided in hdbuserstore

Configure “hdbuserstore” for all Databases

hdbuserstore set <KEY> <hostname>:<sql port> <username> <password>
---SYSTEMDB 
hdbuserstore set CLNRSCH <hostname>:30013 HKPSCH ***********
---Tenant 1
hdbuserstore set CLNRXXX <hostname>:30041 HKPXXX ***********
---Tenant 2
hdbuserstore set CLNRYYY <hostname>:30044 HKPYYY ***********
---Tenant 3
hdbuserstore set CLNRZZZ <hostname>:30047 HKPZZZ ***********

Here XXX, YYY, ZZZ are SID of tenant databases.

Once hdbuserstore is configured, you can cross check with below command

# hdbuserstore list

Execute Script


Before executing script, kindly perform checks to validate your backup catalog. Below example, I’m showing you everything on SystemDB but same needs to be followed for all tenant databases as well.

To check oldest backup entries in catalog and the size of catalog, execute below query in System DB and all tenant Database.

---Oldest Backup and Size of Backup Catalog

SELECT TO_CHAR(CURRENT_TIMESTAMP, 'YYYY/MM/DD HH24:MI:SS') EVALUATION_TIME,   
        LPAD(TO_DECIMAL(C.CATALOG_SIZE_MB, 10, 2), 15) CATALOG_SIZE_MB,   
        TO_CHAR(B.OLDEST_BACKUP_DATE, 'YYYY/MM/DD HH24:MI:SS') OLDEST_BACKUP_DATE,   
        LPAD(B.OLDEST_BACKUP_DAYS, 18) OLDEST_BACKUP_DAYS 
FROM ( SELECT TOP 1  BF.BACKUP_SIZE / 1024 / 1024 CATALOG_SIZE_MB   
        FROM  M_BACKUP_CATALOG B,
              M_BACKUP_CATALOG_FILES BF
        WHERE B.BACKUP_ID = BF.BACKUP_ID 
        AND BF.SOURCE_TYPE_NAME = 'catalog' AND B.STATE_NAME = 'successful'   
        ORDER BY B.SYS_START_TIME DESC ) C, 
      ( SELECT  MIN(SYS_START_TIME) OLDEST_BACKUP_DATE, 
                DAYS_BETWEEN(MIN(SYS_START_TIME), CURRENT_TIMESTAMP) OLDEST_BACKUP_DAYS   
        FROM  M_BACKUP_CATALOG 
      ) B

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

SELECT COUNT(*) FROM M_BACKUP_CATALOG;

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Run HANA Mini Check from SAP Note 1969700.

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Based on the age of HANA database, the size of backup catalog will increase. Above mini check shows you the size of backup catalog of SystemDB on which I have ran mini check. I have 3 tenant and the value of backup catalog on each comes are to be similar i.e 20 MB. So 80 MB has been utilized in total at persistent level. So housekeeping this table will help us to keep data footprint low which eventually utilize less memory.

Execute below command with <sid>adm

# python hanacleaner.py -bd 90 -br true -k CLNRSCH

Here it will delete entries in backup catalog older than 90 days. If you set -bb true, then along with the backup catalog entries corresponding backup files also gets deleted. But it is of no use, if you are using third party backup tool.

But if you use both -be and -bd, the most conservative, i.e. the flag that removes the least number entries, decides

For cleaning up the backup catalog (and possibly also backups) hanacleaner has the following input flags –

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Now check the oldest backup days and size of catalog and you will see that entries are been deleted and catalog size has been reduced.

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

So for all tenant databases same python script needs to be executed along with its user key CLNR<SID>

# python hanacleaner.py -bd 90 -br true -k CLNRXXX

# python hanacleaner.py -bd 90 -br true -k CLNRYYY

# python hanacleaner.py -bd 90 -br true -k CLNRZZZ

Configure Cron Job


We will be using cron job to run this script weekly. Some customer don’t allow to use cron job, so schedule this script using third party tool.

Note: hanacleaner expects the environment of <sid>adm –> if we use CRON the same environment as <sid>adm has to be provided.

Check with shell <sid>adm uses

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

This shell script, hanacleaner.sh, provides the <sid>adm environment, with source $HOME/.bashrc and then executes the hanacleaner command:

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

Then a new crontab can be created, calling this shell script, e.g. every Saturday at 6 o’clock  in morning. You can use https://crontab.guru to get time for cron job

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

If you want to log the output to std_out set up the crontab like this:

SAP HANA Certification, SAP HANA Guides, SAP HANA Learning, SAP HANA Tutorial and Material, SAP HANA Study Materials

NOTE: You can also insert email syntax in cron job, so on the completion the task it triggers an email along with output.

Implementing HANA Information view to calculate distance between Cities Using Geo-Spatial Functions

$
0
0
This blog is intended to share my experiences on Geo-Spatial Functions implementation in SAP HANA. One of the implementation is implementing Information view to calculate distance between Cities Using Geo-Spatial Functions which I am sharing today.

Background: Geo- Spatial function used geospatial data which stored in a geographic information system (GIS). The geospatial data needs to be combined with data from the internet and sensor data, data from business partner to implement point to point implementation, to manage coordinates of different stores, warehouse, utilities of an organization, business for real-time analysis, reporting, forecasting, threat detection.

In the below scenario we will show how to Implementing Information view to calculate distance between Cities Using Geo-Spatial Functions

Let us create a table Cities, where we store the city name and its Coordinates.
Go to catalog -> right click on schema  -> open SQL console

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

Create a table CITY, where we store the city name and its Coordinates.
Write the code as shown in below screenshot –

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

Giving you the code for your reference:

CREATE COLUMN TABLE CITY (
Id BIGINT not null primary key generated by default as IDENTITY, /* To automatically fill the Id column */
City NVARCHAR (40) NULL,
LongLat ST_GEOMETRY (4326)) /* Using ST_GOEMETRY shape which is a super set to load points information */
Click on execute

Here it is successfully executed.

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

Here you can see table under BEST schema

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

Some observations while creating the table:
1) ID Column:
Identity column to generate the numbers for the ID column
2) Longitude & Latitude points:
For different areas we have different latitude and longitude point.
Here I have taken latitude and longitude points of Hyderabad and Vishakhapatnam
3) ST_GEOMETRY:
We are using this data type ST_GEOMETRY to load our coordinates for the city.
SRID Value 4326:
Spatial reference identifier (SRID) and that the 4326 refers to the WGS84 standard which is commonly used.
To insert the data into that table
Write the below code as shown in below screenshot

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

Code for your reference:
Insert into CITY (City, LongLat) values (‘Hyderabad’, new ST_POINT (‘POINT (78.4744400 17.3752800)’));
Insert into CITY (City, LongLat) values (‘Vishakapatnam’, new ST_POINT (‘POINT (83.3000000 17.7000000)’));

Click on execute and it will successfully executed.

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

Write the select statement as shown below
Code for your reference:
SELECT LongLat.ST_AsEWKT () FROM CITY;

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

and execute it.

Result:

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

Now we have data so now let us create stored procedure to calculate the distance between the 2 cities Hyderabad and Visakhapatnam. And also convert the distance into KM’s or Meters as required.
To create procedures write the code as shown in below screenshot-

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

Code for your reference:

CREATE PROCEDURE SP_CALC_DISTANCE2
(In Latitude DECIMAL (18, 10), In Longitude DECIMAL (18, 10), In Conversion NVARCHAR(10))
LANGUAGE SQLSCRIPT AS
BEGIN
DECLARE STRING_STR varchar (200);
/* Converting the Meters to KM */
IF: Conversion = ‘KM’
THEN
EXECUTE IMMEDIATE (‘select A. City AS “Origin City”, B.City AS “Destination City”
, A.LongLat.st_distance (B.LongLat)/1000 AS “Distance (KM)”
from CITY A,CITY B where A.id = 1 and B.id = 2’);
ELSE
EXECUTE IMMEDIATE (‘select A.City AS “Origin City”,B.City AS “Destination City”,
A.LongLat.st_distance(B.LongLat) AS “Distance(meters)”
from CITY A,CITY B
where A.id = 1 and B.id = 2’);
END IF; /* Calculating the distance from the location points given in the input against the table */
STRING_STR:= ‘SELECT NEW ST_Point(”POINT
(‘ || :Latitude ||’ ‘ || :Longitude || ‘)”,4326).ST_Distance(LongLat)/1000 AS “Distance(KM)” FROM CITY
WHERE id = 2’;
EXECUTE IMMEDIATE ( :STRING_STR);
END;
Click on execute and it will successfully executed.

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

Here we can see the procedure under BEST schema

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

CALL statement to get output in KM
Code for your reference:
CALL SP_CALC_DISTANCE2 (78.4744400, 17.3752800,’KM’)

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

Click on execute and Output in KM:

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

CALL statement to get output in meters
Code for your reference:

CALL SP_CALC_DISTANCE2 (78.4744400, 17.3752800,’METERS’)

Output in Meters:

SAP HANA Geo-Spatial Content, SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Study Materials

Setting up a HANA Express Python Machine Learning API Demo VM

$
0
0
This is a step-by-step guide to setting up a HANA Express(HXE) VM for demonstrating the Python Machine Learning API with functioning demo application.

The goal is to eventually provide an automated script to perform all the required actions. Currently some steps require user authentication and can’t be performed automatically.

As of the date of this post, these instructions are specific to HXE version 2.00.033.00.20180925.2 as reported by the HXE Download Manager for platform = Linux / x86-64, image = Virtual Machine, Package = Server + applications. The host VM was a Macbook Pro with 16GB of RAM running VMWare Fusion 8.5.10 (7527438). Other vm hypervisors and host platforms may work but your mileage may vary. Please adjust the following as needed for your situation.

This post does not describe a similar process for installing HXE from the binary installer or the dockerized version. However, you may find much of the following useful if you choose those methods.


SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Pick the downloader for your platform. Apple isn’t supported directly so we’ll use the Platform-independent DM.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

This will download the file HXEDownloadManager.jar. In order to run the downloader you must have java installed on your local machine.

Open a terminal window and change to your Downloads directory.

cd ~/Downloads

java -jar HXEDownloadManager.jar

This will run the HXE Download Manager.

Double check that the Version is 2.00.033.00.20180925.2 and that you’ve selected the Server + apps and Clients for Linux options.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

This can take some time depending on your internet connection speed.

Once the download is completed, you’ll have a file called hxexsa.ova and one called clients_linux_x86_64.tgz in your Downloads.

Run VMWare Fusion or your preferred hypervisor app and import the ova file.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

On my machine this took about 20 minutes. Don’t be tempted to give your vm less than 12GB.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

When the vm starts up, Confirm the keyboard configuration and change the time zone if desired.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Consult the Getting_Started_HANAexpress_VM.pdf file that was downloaded for details of setting up your machine’s hosts file to override the name resolution for the hostname hxehost.

WAIT! .. resist attempting to login right away. Give the system about 15 minutes to settle before continuing. Set a timer for 15 minutes and go get a cup of coffee.

…you waited, right? OK, let’s continue.

Login using the hxeadm user entering password HXEHana1(the default). You will be prompted to enter the (current) HXEHana1 password again and then your new password twice.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Do not forget this password! It will become the password for the os hxeadm user, the XSA_ADMIN, XSA_DEV users.  See the Getting_Started_HANAexpress_VM.pdf file for details.

You will then be prompted for the password of the db SYSTEM user in both the SYSTEMDB and the tenant HXE db.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

If your system needs a proxy setting to reach the internet, configure it now.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

The system will now do a bunch of installation/configuration/adjustment/tuning. This can take at least ??? minutes and you should wait for this to complete before continuing.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Last chance before continuing.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

zypper ar…

From this point we’ll ssh into our server with the built-in mac ssh client. In windows you’ll want to use Putty and Putty-gen to get things set up. I’m also setting up for passwordless ssh’ing into the server. There are several ways to do this so I won’t go into detail. For a quick setup, use ssh-keygen and ssh-copy-id.

ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub hxeadm@hxehost

Open a terminal or ssh client window and ssh to the server.

Check that the xs api endpoint is set.

If it isn’t, use the following.

xs api https://hxehost:39030/ --cacert=/hana/shared/HXE/xs/controller_data/controller/ssl-pub/router/default.root.crt.pem

If the XSA_ADMIN user isn’t logged it, Use this to login and the password set above.

xs login -u XSA_ADMIN

By default the XS Advanced application runtime has a LOT of things running. Since we’re very tight on memory we can turn nearly everything off but just the critical apps. Run these commands.

xs target -o HANAExpress -s SAP ; xs a | grep STARTED | grep -v hrtt-service | grep -v di-runner | grep -v di-core | grep -v deploy-service | cut -d '' -f 1 | while read -r line ; do echo "Stopping $line"; xs stop $line ; done

Note that once the above commands have finished, you won’t be able to access the xsa-cockpit, hana-cockpit, or webide or any other xsa utility.

Run the following to see what’s still started.

xs a | grep STARTED

You should only see 4 apps.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

The hxeadm user is by default set up to be able to sudo into the root user.

Become the root user by starting a new /bin/bash shell.

sudo /bin/bash

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

HANA Express doesn’t come with any repositories configured by default. We will need to add compilation tools and other programs to accomplish our tasks so we need to be able to install software. Configure the repos with the following commands as the root user.

zypper ar http://download.opensuse.org/distribution/leap/42.2/repo/oss/ oss
zypper ar http://download.opensuse.org/distribution/leap/42.2/repo/non-oss/ non-oss
zypper ar http://download.opensuse.org/update/leap/42.2/oss/ update-oss
zypper ar http://download.opensuse.org/update/leap/42.2/non-oss/ update-non-oss

Refresh the repo catalogs with this command as root.

zypper -n --gpg-auto-import-keys refresh

We will need to build the version of python we will use from source code so we need the standard linux build tools. Get them with the following.

zypper -n --gpg-auto-import-keys install --no-recommends --auto-agree-with-licenses --force-resolution --type pattern devel_basis

We also need a bunch of other tools, libraries and programs. Install them with the following.

zypper -n --gpg-auto-import-keys install --no-recommends --auto-agree-with-licenses --force-resolution tk-devel tcl-devel libffi-devel openssl-devel readline-devel sqlite3-devel ncurses-devel xz-devel zlib-devel wget git-core nodejs npm lynx jq libzip2 libzip inotify-tools

That’s all we need to do as root for now. Drop back to the hxeadm user with exit.

exit

As mentioned at the top of this (now growing long) blog post, I’ve intend to make all of this into an installation script, but it’s also good to get an explanation of the individual step in case you run into issues. The script and accompanying readme is in the following github repo. We will clone it here as some of the following scripts rely on it. If you want to look at my work in progress. Edit the hxe_python_ml.sh file.

git clone https://github.com/alundesap/hxe_python_ml.git

Now change into the new git repo folder hxe_python_ml.

cd hxe_python_ml

The demo application itself is a different github repo. We’ll clone it here.

git clone https://github.com/alundesap/mta_python_ml.git

We will be getting version 3.6.5 of the python source from python.org.

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

We need the Python Machine Learning API libraries from the client libraries that you downloaded with the HXE Download Manager. Return to your system and expand the clients_linux_x86_64.tgz file into it’s component files. On my mac I use the tar command. On a windows machine you’ll have ot untar and unzip it.

tar xzvf clients_linux_x86_64.tgz

Transfer the hana_ml-1.0.3.tar.gz file to your vm. On my mac I use scp, but on windows you may have to use WinSCP or similar.

scp hana_ml-1.0.3.tar.gz hxehost:/usr/sap/HXE/HDB90/hxe_python_ml/

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Download the XS_PYTHON00_1-70003433.ZIP file and then copy it into your vm as before.

scp XS_PYTHON00_1-70003433.ZIP hxehost:/usr/sap/HXE/HDB90/hxe_python_ml/

Return to the terminal or putty session where you are logged in as the hxeadm user.

Make sure you are in the hxe_python_ml folder.

Your folder should now have these files in it.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Next we will expand the python source, configure, build and install it into a local folder called python_3_6_5.

tar xzvf Python-3.6.5.tgz
md python_3_6_5
cd Python-3.6.5
./configure --prefix=/usr/sap/HXE/HDB90/hxe_python_ml/python_3_6_5/ --exec-prefix=/usr/sap/HXE/HDB90/hxe_python_ml/python_3_6_5/ ; make -j4 ; make altinstall

This will take some time to build. Plan on about 3-4 minutes.

You should end up with pip-9.0.3 and setuptools-39.0.1.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Move up one directory and into the bin folder of the python we just built.

cd ../python_3_6_5/bin

Since we just built a fully functional version of python, it would be nice to use it for localized testing of our project code. A nice way to do that is to create some symbolic links and set up our environment to use it. Change into the target python directory we installed our custom version of python into and create some links.

ln -s easy_install-3.6 easy_install
ln -s pip3.6 pip
ln -s pydoc3.6 pydoc
ln -s python3.6 python
ln -s pyvenv-3.6 pyvenv

Now we can install the python runtime into xs.

xs create-runtime -p /usr/sap/HXE/HDB90/hxe_python_ml/python_3_6_5/

Check that installed properly.

xs runtimes | grep python

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Let’s go up two levels.

cd ../..

When we cloned the hxe_python_ml repo, we got another handy file for setting up the environment for us to test python locally. Run the set_python_env.sh script like this.

Note. There is a space ” ” between the dot and set_python_env.sh. This ensures that the changes affect the current shell.

. set_python_env.sh

A side-effect of this script is that is places you in the mta_python_ml/python folder.

Test that python and pip are the versions we expect.

python --version

Should return Python 3.6.5

pip --version

Should return..

pip 9.0.3 from /usr/sap/HXE/HDB90/hxe_python_ml/python_3_6_5/lib/python3.6/site-packages (python 3.6)

We now have a functioning python that is the version that we built. It’s often that there are other versions of python available on a given system and it’s easy to get them mixed up, so beware.

Let’s install the libraries that we copied in earlier. Go up two folders.

cd ../..

Uncompress the SAP Python libraries.

unzip XS_PYTHON00_1-70003433.ZIP -d sap_dependencies

We use the sap_dependencies folder name so that it matches the SAP documentation.

Go back into the mta_python_ml/python folder.

cd mta_python_ml/python

In order to facilitate local testing of our demo app, let’s install the python libraries locally.

pip install -r requirements.txt --find-links ../../sap_dependencies --find-links ../../hana_ml-1.0.3.tar.gz

When we go to deploy our python demo application we’ll need the python dependencies in a special folder called vendor that the buildpack will detect and utilize.

mkdir -p vendor
pip download -d vendor -r requirements.txt --find-links ../../sap_dependencies --find-links ../../hana_ml-1.0.3.tar.gz hana_ml

Since the HANA WebIDE doesn’t support python as a development language yet and we’ve also turned it off, it would be nice to have a way to play with the python machine learning api. There is a python project called jupyter that provides this functionality.

pip install jupyter

Here are a few other python ml packages that you might like to explore(optionally).

pip install sklearn
pip install mxnet
pip install tensorflow
pip install python-mnist

Create a default jupyter configuration with this command.

jupyter notebook --generate-config
cp ~/../HDB90/hxe_python_ml/jupyter_config/jupyter_notebook_config.py ~/.jupyter/jupyter_notebook_config.py
cp ~/../HDB90/hxe_python_ml/jupyter_config/jupyter_notebook_config.json ~/.jupyter/jupyter_notebook_config.json

Run the jupyter notebook server.

jupyter notebook

Now you can browse to the Jupyter nodebook at http://hxehost:8080/ password is Plak8484

Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

There is a README.md file that contains the steps for building and deploying the demo application.

Currently this is a work-in-progress and may change somewhat so I’ll put the important steps here.

Move up one folder level to the top of the demo project.

cd ..

The python machine learning library is a facade for the Predictive Analytics Library(PAL) and the PAL library requires a DB tenant with the scriptserver daemon running. The default development space in HXE is mapped to the SYSTEMDB which doesn’t allow the scriptserver daemon to run in it. The HXE tenant will allow the scriptserver to run in it if so we’ll enable it.

Note, you’ll need to replace Plak8484 with the password you specified above.

hdbsql -i 90 -n localhost:39013 -u SYSTEM -p Plak8484 -d SYSTEMDB "ALTER DATABASE HXE ADD 'scriptserver'"

SELECT * FROM SYS_DATABASES.M_SERVICES

hdbsql -i 90 -n localhost:39015 -u SYSTEM -p Plak8484 -d HXE

We need a space that we can map to the HXE tenant DB so that deploys into that space will be mapped to that tenant. Create the ml space and add users to it.

xs create-space ml -o HANAExpress
xs set-space-role XSA_ADMIN HANAExpress ml SpaceManager
xs set-space-role XSA_ADMIN HANAExpress ml SpaceDeveloper
xs set-space-role XSA_DEV HANAExpress ml SpaceManager
xs set-space-role XSA_DEV HANAExpress ml SpaceDeveloper

Now we need to restart the xsa-cockpit app and enable XSA in the HXE DB tenant.

xs t -s SAP
xs start xsa-cockpit

Once it is running find it’s url.

xs app xsa-cockpit --urls

Browse to it at https://hxehost:51039 (yours my be different) and login with XSA_ADMIN and the password you specified above.

Click Tenant Databases and the little wand icon to the right of the HXE db line.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Set the SYSTEM user password to the same as the password you used above.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Wait for the status to become Enabled for the HXE db, then Click on the little map icon.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Select HANAExpress as the Organization and ml as the Space. Click Save.

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

Now when we push or deploy something into the ml space, it will get created in the HXE database tenant (which has the scriptserver running in it).

We won’t need the xsa-cockpit anymore so we can stop it.

xs stop xsa-cockpit

Let’s go now to our newly minted ml space and build our demo app.

xs t -s ml

Make sure we’re in the project folder.

cd /usr/sap/HXE/HDB90/hxe_python_ml/mta_python_ml

First we create a service instance to our HANA DB (in the ml space).

xs create-service hana hdi-shared python-ml-hdi

And one for the UAA.

xs create-service xsuaa default python-ml-uaa

Now we build our HDI container manually.

xs push python-ml.db -k 1024M -m 256M -p db --no-start --no-route
xs bind-service python-ml.db python-ml-hdi
xs restart python-ml.db --wait-indefinitely ; sleep 15 ; xs stop python-ml.db

Then the python module. Make a note of the port that the python module was assigned.

xs push python-ml.python -k 1024M -m 256M -n python -p python --no-start
xs bind-service python-ml.python python-ml-hdi
xs bind-service python-ml.python python-ml-uaa
xs start python-ml.python
xs app python-ml.python --urls

And finally the web module. Note: Adjust the port of the destination to match that of the python module above.

xs push python-ml.web -k 1024M -m 256M -n web -p web --no-start
xs bind-service python-ml.web python-ml-uaa
xs set-env python-ml.web destinations '[{"forwardAuthToken":true, "name":"python_be", "url":"https://hxehost:51029"}]'
xs start python-ml.web
xs app python-ml.web --urls

One manual steps we have to do is to grant our HDI container user the global role grant AFL__SYS_AFL_AFLPAL_EXECUTE so that they can execute PAL functions. At some point I will figure out a way to grant this in the application but for now we have to do it manually.

Here’s a dirty way to get at the user name. Don’t use the hdi_user.

xs env python-ml.python | grep user

“user” : “391FCB5A79B343949DECFD0F9014B082_F4UOB7FMN51QC8ELIJ95YXJAZ_RT”

Modify the following to fit your environment user name + SYSTEM password.

hdbsql -i 90 -n localhost:39015 -u SYSTEM -p Plak8484 -d HXE "grant AFL__SYS_AFL_AFLPAL_EXECUTE to 391FCB5A79B343949DECFD0F9014B082_F4UOB7FMN51QC8ELIJ95YXJAZ_RT"

Normally we’d bundle our project up into an mtar file and deploy it, but these steps accomplish the same thing for this example.

Now after all of that, we have an xs advanced app that utilized the python machine learning API.

Browse to the url of the web module. https://hxehost:51030 (Note yours will likely be different.)

SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Study Materials

This example uses the Support Vector Machine, Support Vector Classifier to try and train against and predict hand written digits. Start by drawing a “1” in the box at the left and then clicking the “1” button. Do this about 10 times and the prediction function will start. You’ve just taught it to recognize a “1”. Continue adding other digits and see when it starts correctly predicting them.

Each digit is represented by 784 integers, one for each pixel. So it’s easy to create quite a bit of data pretty fast. In theory each pixel could be a different feature for analysis.

Well this has been a long journey and we didn’t even look at the code itself! I’ve found that all the elements to pull this together were scattered in various places so hopefully this helps someone get a functional system working so that they can get to the good machine learning stuff.

Connecting Servlets to HANA as a Service on Cloud Foundry

$
0
0

Introduction


This tutorial will help you creating in a servlet and deploy it to SAP Cloud Platform with a Cloud Foundry instance using Eclipse.  The Eclipse landscape has been updated since the aforementioned blog was written and some of the prerequisites have changed for Eclipse. Additionally, this tutorial will connect the sample application to a HANA database schema on SAP Cloud Platform.  The tutorial uses JNDI and traditional SQL which is a common means to access the database.

Prerequisites:


◈ SAP Cloud Platform account with HANA as a Service entitlements (Note: the trial is soon expected to have HANA as a Service)
◈ Eclipse 2018-09 IDE for Java EE Developers


SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

Step 1: Verify Eclipse Cloud Foundry Support.


1. Verify that your Eclipse installation has the necessary Cloud Foundry support by selecting “Help->Eclipse Marketplace”.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

Search for Cloud Foundry in the Eclipse Marketplace.  If it is not already installed, install it now.  You should see Eclipse Tools for Cloud Foundry 1.2.0.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

2. After installing the tools, allow Eclipse to restart. If you are not already in the Java development perspective, click on the “Workbench” button on the top right.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

Step 2: Create a New Maven Project with a Servlet


1. Create a new Maven project by selecting “File->New->Maven Project” as shown below.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

2. Press the Next button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

3. Select the maven archetype “webapp” as shown below.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

4. Specify “com.sap.cloud.sample” for Group Id and “hello-world” for Artifact Id. Press Finish.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

5. Lets create a servlet within the project. Ensure the previously created Maven project is selected, select “File->New->Servlet”

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

6. Specify “com.sap.cloud.sample” for the Java package and “HelloWorldServlet” for the Class name and press the Finish button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

7. For some reason the project does not currently follow the conventional Maven file structure for Java, so create a new folder call “java” under the main folder under source. Right click on the main folder and select “New->Folder”.  Specify the name “java” for the new folder.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

8. Move the “com” folder and sub-folders created when you created the servlet to the new “java” folder as shown below by dragging the “com” folder and dropping on top of the “java” folder. This is the file structure that Maven is expecting.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

9. The new servlet will have a Maven dependency on “javax.servlet-api”. Right click on your project select “Maven->Add Dependency”.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

10. Enter the “javax.servlet” for the Group Id, “javax.servlet-api” for the Artifact Id and “3.1.0” for the version. (Note: your version may vary on your Maven repository).

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

11. Press the OK button.

Optional.  You could try at this point to package the application into war by right clicking on the project and select “Run As->Run Configurations”.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

Enter “package” as the “Goals” and verify you see a “Build Success” message in the console.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

Step 3: Setup your SAP Cloud Platform Cloud Foundry Database


1. Assuming the packaging process worked you can move on to setup the database services on SAP Cloud Platform for the application. Open your browser and log into SAP Cloud Platform to a subaccount that has Cloud Foundry entitlements assigned for HANA and a simple Java application.  If you have not already created a space, create one now for the subaccount.  Below you will see that there is a space called “dev”.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

2. Navigate to your space and select “Service Marketplace”. Select “SAP HANA Service”. This will be your main database and later you will create a schema on top of it.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

3. Select Instances on the left

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

4. Click on the “New Instance” button

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

5. Select the “standard” plan as you will not need enterprise features for this tutorial.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

6. Provide a password for your SYSTEM user.  Press the Next button as we will not need any additional features for the database.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

7. Click on the Next button as you will be binding the application using Eclipse later on in the tutorial.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

8. Provide a name of the instance and press the Finish button. Below “hana-std32″ was used as a instance name.  Good Work!  You have create your first HANA as a Service instance!

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

If you wanted to accomplish the same thing via the Cloud Foundry command line, the command to do this would be as shown below:

cf create-service hana-db standard hana-std32 -c “{\"SystemPassword\":\"<password>\",\"memory\":\"2\"}”​

9. Click on your space name again and select “Service Marketplace” again. Select “SAP HANA Schemas & HDI Containers”.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

You have several different options for HANA as a Service.  If you were doing development using SAP’s Core Data Services (CDS) and Multi-Target Applications (MTA), you likely would select the HDI Shared option, there is a great blog on doing this in the useful resource section.  If you are doing more traditional SQL style development, you likely would be using the “schema” option.  Each of options will be tied to the previous database service that you just created.  This tutorial will use a “schema”.

10. Select Instances on the left.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

11. Click on the New Instance button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

12. Select “schema” plan and press the Next button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

13. You can give your schema name using the JSON in the image below.  By doing this, your application could reference table as MYSCHEMA.tablename.  Otherwise you will get a system generate schema name.  Press the Next button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

14. We could bind the application if we had it ready at this point.  As mentioned earlier, you will bind the application with the database using Eclipse later on in the tutorial.  Press the Next button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

15. Enter the instance name for the schema as shown below and press the Finish button.  When setting up JNDI configuration (later on in this document) the definitions reference the name “myHANAdb”. If you use a different name, you will need to change the context.xml to reflect the name you used here.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

The schema gets assigned to the database service you created in step 8 earlier.  Each database has a GUID which you can get from the Cloud Foundry CLI.  If you wanted to get the GUID for the database you created you would use the following Cloud Foundry command.

cf service hana-std32 –guid​

Using the command below you can create the HANA schema and associated with the hana-std32 database through the GUID.

cf create-service hana schema myHANAdb -c "{ \"database_id\":\"putyourGUIDfromabovehere\", \"schema\":\"myHANAdb\" }"​

Step 4: Add Database code to the Servlet


1. Let’s add the code necessary for the database access to your application. Switch back to the Eclipse environment.  Open the web.xml file located under src -> main-> webapp.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

In the location where you see <insert code here> above, paste the following XML snippet to web.xml.  Note that you wont have <insert code here> tags in your web.xml.  This definition establishes the name “jdbc/DefaultDB” as a JNDI JDBC resource for the application.

<resource-ref>
  <description>DB Connection</description>
  <res-ref-name>jdbc/DefaultDB</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>

Save and close the web.xml file.

2. Create the file context.xml in META-INF folder. Right click on the webapp folder and select “New->Folder”. Name the folder “META-INF”.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

Right click on the new folder “META-INF”, select “New->File”.  Name this file context.xml (use this exact case for the name).

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

3. Paste following XML into the context.xml file. This definition establishes that “jdbc/DefaultDB” will connect to a service named myHANAdb (which you just created).  Save and close the context.xml file.  Again if you used a different instance name above in step 15, you will need this file to reference the name used in step 15.  The factory object referenced in the XML below will be provided by the sap_java_buildpack when you deploy the application to Cloud Foundry.

<?xml version="1.0" encoding="UTF-8"?>
<Context>  <Resource name="jdbc/DefaultDB"
    auth="Container"
    type="javax.sql.DataSource"
    factory="com.sap.xs.jdbc.datasource.tomcat.TomcatDataSourceFactory"
    service="myHANAdb"/>
</Context>

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

4. If the HelloWorldServlet.java file is not already opened, open it and position the cursor under the first import statement. Paste the following code to include key libraries for JDNI and JDBC.

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import java.sql.*;​

Expanded the import section should appears as shown below.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

5. Scroll down to the “doGet” method. Comment out the line after “// TODO Auto-generated method stub”, Paste the following code into the editor after your new comment.

             Context ctx = null;
             Connection con = null;
             Statement stmt = null;
             ResultSet rs = null;
             try {
               ctx = new InitialContext();
               DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/DefaultDB");
               con = ds.getConnection();
               stmt = con.createStatement();
               rs = stmt.executeQuery("select current_user as myuser from dummy");
               rs.next();
               response.getWriter().append("Served at:").append(rs.getString(1)).append(request.getContextPath());
             }catch(NamingException e){
                    e.printStackTrace();
             } catch (SQLException e) {
                    e.printStackTrace();
             }​

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

Step 5: Add the Cloud Foundry Server and Run the Application


1. Let’s add the Cloud Foundry Server. Under the Servers window, click on “Click on this link to create a new server”.  If you already had a server in the window, right click on the “Servers” window and select “New->Server”.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

2. Select Cloud Foundry and provide a name. Below the name “Cloud Foundry” is used. Press the Next button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

3. Enter your SAP Cloud Platform user and password. Click on the “Manage Cloud…” button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

4. Click the Add button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

5. You will need to get the Cloud Foundry API Endpoint URL for your cloud instance.  Switch back to your browser and navigate to the overview section of your subaccount.  The URL will be on the right with a heading of API Endpoint.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

6. Copy the URL.  Switch back to Eclipse and paste the URL into the URL field.  Provide a name for the Cloud URL.  Press the Finish button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

7. Press the OK button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

8. Press the Next button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

9. Select the space under which you had setup the database services.  Press the Next button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

10. Select your “hello-world” application and press the Add button.  Press the Finish button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

In the “Servers” window, you will see that your application is assigned to the new server but not deployed.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

11. Lets clean the project to ensure we are getting the latest code.  Right click on the project and select “Run As->Maven clean”.  Ensure your directory structure has the java folder under the main and not resource folder under “src”.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

12. Right click on the project and select “Run As->Run on Server”.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

13. Select the Cloud Foundry server that you created earlier and click on the Next button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

14. Click on the Finish button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

15. You will be prompted for Application details, enter the “sap_java_buildpack” for the Buildpack URL and check the box to update the manifest file. Press the Next button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

There several buildpacks on SAP Cloud Platform.  The following Cloud Foundry command will provide a list of buildpacks avalable:

cf buildpacks

16. Change the memory limit to 1024. Press the Next button.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

17. Bind to the schema instance name “myHANAdb” that you created earlier by clicking the check box for “myHANAdb”.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

18. Press the Finish button

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

In the console you will see the following output:

Checking application - hello-world
Generating application archive - hello-world
Pushing application - hello-world
Creating application - hello-world
Application successfully pushed
Starting application - hello-world
[Application Running Check] - Checking if application is running - hello-world. Please wait...
[Application Running Check] - Application appears to be running - hello-world.​

Eclipse may not use https in the attempt to run the application and may fail.  If it uses http, change the URL from “http” to “https” when launching the browser.Also, the process of verifying the application may not appear to be complete within Eclipse very quickly but if you switch to your browser and navigate to the space and you will see your application listed under application as hello-world, you will find an URL under Application Routes for the Application route.  Click on this link for the application route and you will see Hello World! In the browser.  Before you click on the URL, ensure you see the green “Started” message as shown below.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

19. Append the text “/HelloWorldServlet” to the URL above and you should see “Served at: MYSCHEMA” which is illustrates that you are connected to the database with a user name MYSCHEMA.

SAP HANA Study Materials, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning, SAP HANA Live

Table Functions in SAP HANA – step by step guide

$
0
0

SAP HANA Table Functions


Recently I spoke to multiple developers working on SAP HANA Native system for developing reports. What really surprised me was the fact, that most of them are still using calculation views of a SQL Script type instead of Table Functions. What is more, some of them were even not aware that these type of views are deprecated and replaced by Table Functions. I also haven’t found any step by step tutorial describing when to create Table Functions, how to do that, what are the benefits and how to consume them in calculation views.

This inspired me to write the article about Table Functions and share my experience on that topic.

What are Table Functions?

Since SP11 calculation views of SQL Script type are deprecated. As an alternative SAP introduced new development artifact called Table Function. HANA provides Migration tool, which enables automatic conversion script-based Calculation View into Table Function.

Table functions are used whenever the graphical views are not sufficient i.e. for loops, executing custom functions or complex queries.

What are the Pros and Cons of using Table Functions?


Pros:

◈ SQL Script gives much more functionality and flexibility (more functions available, complex logic can be implemented in easier way, SQL can be combined with Application Function Library – AFL giving even more functions for complex analysis)

Cons:

◈ Maintenance is much more difficult (preserving order and data types of output columns; data preview for part of code is not so straightforward comparing to previewing nodes in graphical views; when changing output – both Table Function and view on top of it needs to be adjusted; etc.)
◈ Multiple-value input parameters are not supported (there is no easy way of passing multiple values into single input parameter to Table Function, however there is workaround for that)
◈ By definition graphical views provide better performance thanks to HANA’s optimizer
◈ No GUI available – SQL Script knowledge is necessary

Generally Table Functions should are used in case if the logic cannot be covered by graphical view or the logic is too complex to model it graphically.

How to create Table Function?


Scenario: Business wants to display a report showing number of working days between “ORDERDATE” and “SHIPPEDDATE“. To calculate it we need to use WORKDAYS_BETWEEN SQL function, which is not available in graphical view. Additionally this function should display orders only for specific period of time which will be provided by the user.

1. To start developing database objects, go to Development Perspective:

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

2. Go to Repositories tab:

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

3. Right click on destination package and select New -> Other

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

4. In wizard type Table Function, select it and click Next

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

5. Provide Table Function name and click Finish</em>

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

6. Table function window will open.

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

7. Adjust the code to the requirements

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

I. [Optional] Provide input parameters including data types. This is needed when you want to parametrize Table Function.

II. [Mandatory] Set TABLE as the output type.

III. [Optional] Provide default schema for the query. This is needed when you transport the function between instances with different schemas i.e. in development system you are using “DEV” schema, but on production all tables are placed in “PROD” schema. If you provide the default schema in the definition of Table Function, then while transporting this schema will be automatically replaced with the schema of target system (based on schema mapping). When applying default value for schema mapping, in the query you should use table names without schemas i.e simply use “ORDERS” instead of “DEV“.”ORDERS“.

IV. [Mandatory] Add RETURN phrase before the final select statement.

V. [Mandatory] Add select statement.

VI. [Optional] Apply input parameters in the WHERE clause. Add leading colons (“:”) when calling each parameter.

VII. [Mandatory] Add semicolon (“;”) at the end of the statement.

VIII. [Mandatory] List all the output columns. Preserve the columns order, column names (case sensitive) and their data types consistent with the select statement

8. After writing Table Function definition activate it and make sure that there is no error after activation.

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

Be aware that any of Data Definition (CREATE, ALTER, etc.) or Data Manipulation (INSERT, UPDATE etc.) operators are not allowed in Table Functions.

How to query Table Functions?


Calling table Functions in SQL console is very easy. They are executed in the FROM clause. When executing the function, provide whole name of the function. In brackets provide values for input parameters. If there are no input parameters – leave the brackets empty ( they are always mandatory!!! ).

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

How to consume Table Function in Calculation View?


Using Table Function as a source in Calculation View is also very simple. Create a new calculation view, and when adding object for the projection, type name of the Table Function:

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

If Table Function is using input parameters you need to recreate them also in the view. Go to Parameters/Variables tab, click on Input Parameter Manage Mapping and select Data sources.

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

Click Auto Map By Name button to automatically copy input parameters from the Table Functions to the view.

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

Now when previewing data on the view, there will be pop up with input parameters. Once values are inputted they will be passed directly to the table function and results will be displayed.

SAP HANA Tutorial and Material, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Live

What are the limitations of Table Functions?


The main limitation of table function is that you can pass only single values for each input parameter, which can be very annoying, because in most cases user wants to have possibility to pass multiple values in selection criteria of his report.

Configuration and setup HANA XS Apps with HANA DB SSO (BASIS Activities)

$
0
0
This is a long time coming blog from me and below are some of the steps that I used to configure the SAP HANA XS apps (HANA live apps) such as KPI modeler, Analytics foundation apps and so on for which the content is in the HANA DB (In the form of the HANA delivery units we apply for those apps) but the apps are viewed in the FIORI URL. So to make this perfectly work we have below steps such as applying the delivery unit for the app, Web Dispatcher routing configuration, SSO between ECC ABAP and HANA DB and finally replication of ABAP users in HANA DB. Though these configurations are used less now a day, due to the introduction of S4 and its own FIORI apps but the different steps and configuration explained here can be used in different use cases.

Our Environment:

ECC EHP 8 with HANA DB.

Importing delivery units:
Make sure to check the FIORI apps library for the frontend and backend requirement (HANA DB in this case) for you app.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

There are several ways to deploy delivery units. Below are the popular methods,

1. Through the HANA studio. (which is shown)
2. Through command line in OS level.
3. Through HANA cockpit. (best way to do)

Take a Backup before start of this activity and try it in DEV or testing environment first.

Below procedures show how we can import delivery unit through HANA Studio.

Step 1: Click File – Import.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Step 2: Select the Delivery unit option from the SAP HANA Content drop down.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Step 3: Select the System (HANA SID) into which you want to import.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Step 4: Select the Appropriate TGZ file downloaded and extracted from SAP Market place

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Click Finish.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Similarly import all the delivery units required.

Web Dispatcher Configuration:

Please add the following Web dispatcher entry as below,

wdisp/system_(no.) = SID=EXT, EXTSRV=http://<hana host name>:80(nr), SRCURL=/sap/hba;/sap/hana/

hana host name= Host name or IP of server when HANA DB was installed.

Nr= Instance no of the HANA DB.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

According to above,

When /BOE service is called it goes to wdisp/system_0

When /sap is called it goes to either wdisp/system_1 or wdisp/system_2

In case of /sap it can redirect to either system 1 or system 2, so the web dispatcher checks the next service to /sap called- if /sap/hana or /sap/hba is called it goes to system 1 if other service is called (i.e) /sap/<any service other that hana or hba>/ it goes to system 2.

For the above condition to work – below parameter is maintained,

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Next: let us proceed configuration for SSO between FIORI Front end and HANA DB.

It has three steps.

Step 1:

Exporting ECC front end system (FIORI ABAP System) certificate:

T-Code STRUSTSSO2

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Click Export Own Certificate of FIORI Front end:

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Import that file in HANA DB:

To do that,

Launch HANA Cockpit: Right click – Configuration and monitoring – Open SAP HANA cockpit.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Open the App — Certificate store:

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Click import.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Now Select the certificate which you have exported from FIORI Front end System.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Then Open the App — Configure Certificate collections App:

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Now Create Certificate Collection by clicking the + button:

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Give it a name.

Click Edit and edit that certificate collection:

Edit the purpose.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Save it.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Then add the certificate which you previously imported by add certificate Button:

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Step 2:

My login ticket issuing URL for this SSO is my Fiori URL (which the end user is going to use): In my case the Web dispatcher URL through which FIORI is accessed.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Then Connect HANA DB in HANA Studio:

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Open Administration by double clicking the HANA DB SID in studio.

In the Configuration tab, expand the section xsengine.ini–>authentication. (add if the authentication option is missing)

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Set (or add) the parameter: logonticket_redirect_url.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Enter the URL that points to the system and service issuing SAP logon tickets, for example:

https://<web dispatcher hostname>:<portnumber>/<path/to/logon_ticket/service>

Type the parameter in key and

Paste the URL copied in notepad in the value box,

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Step 3: XS Engine Run-time configuration.

Maintain the run-time configuration for the application that you want to use SAP logon tickets for user authentication. In this case the HANA live apps and the configuration has to be maintained for those contents.

You can use the Web-based SAP HANA XS Administration Tool to complete this step. The tool is available on the SAP HANA XS Web server at the following URL:

http://<HANADB Host>:80<SAPHANAinstance>/sap/hana/xs/admin/

Choose XS Artifact Administration.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Steps:

◈ Locate the root package of the application whose run-time configuration you want to modify. In this case the HANA live apps and the configuration has to be maintained for those contents.

Use the Packages list in the Application Objects plane.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

◈ In the Security & Authentication tab, enable support for SAP Logon/Assertion Ticket.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Do the same for all Application root package.

◈ Save the changes you have made.

* Synchronizing ECC users and DB users: (To create users in Db directly from ABAP system):

First Connect to DB in T-Code DBCO:

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Add a new entry:

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Fill the details and connect to Db with Sufficient privilege (SCHEMA user is preferred):

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Then we have to maintain entry in table.

Entry to be maintained:

DBCO Connection name and Client from which you need to create DB user.

So Go to SM30 to maintain the table USR_DBMS_SYSTEM

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

New entry

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Maintain the entry

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

DBCO connection and source client for DB user creation.

Save it.

Kindly verify the same using SE11

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Then try to execute the program RSUSR_DBMS_USERS in SE38

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

It should execute without any error in the admin client (source client for DB user creation):

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

For other clients or if the above activity is not done it will display error as below;

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

To verify the above configuration is done correct- now go to SU01, enter a ABAP user id,

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Click EDIT.

Now a new tab DBMS will appear in the user edit menu,

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

From where you can create a DB user for the ABAP user you have edited and also administer them (like granting roles).

Eg: Refer below screenshot,

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

Now hand it over to FIORI consultants to activate the HANA DB dependent apps.

If the web dispatcher routing is missing, we will get the below error – cannot load tile.  Because the Tile is unable to access the content in HANA DB due to the missing route

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

If the Web dispatcher configuration is done correctly and SSO configuration is not done – it will ask for DB level credentials.

The same will happen if the user is not created in DB level or sufficient role is missing.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

All configuration (web dispatcher and SSO configuration is done), it will show the KPI apps after FIORI login.

SAP HANA Live, SAP HANA Tutorial and Material, SAP HANA Study Materials, SAP HANA Certifications

The above procedures for HANA live apps in ECC product but my guess is it is not required for S4 HANA product. Though this configuration is old, there are different configuration setup such as web dispatcher configuration, SSO and replicating users in ABAP to HANA DB which can be used in different cases.

HANA Fallback Snapshot – HANA 2.0 SP 03

$
0
0

Purpose


This blog provide you an information on fallback snapshot, a new feature that has been introduced in HANA from HDB 2.0 SP 03 version.

Overview


From HANA 2.0 SP 03, there is a new feature called “Fallback Snapshot” which allows you to quickly and easily return back to a previous database state. You can create a fallback snapshot for a tenant database. It allows you to revert to a particular database state. If you no longer need the fallback snapshot, you can delete it. It can be used in below scenarios –

1. Reset of Tenant Database used for Training
2. Reset system back to previous state after performing import of Transport Requests to understand the sequence or performing testing for new region roll out.
3. Reset system back to previous state if anything goes wrong while applying add-on/patch via SAINT
IMPORTANT NOTE: Below point needs to be kept in mind before using Fallback Snapshot:

◈ Fallback snapshots can only be created for tenant databases.
◈ Configuration changes are not included.
◈ You can only create one fallback snapshot per tenant database. If you need to create a new fallback snapshot, delete the existing one first.
◈ A service cannot be added or removed if a fallback snapshot already exists.
◈ A fallback snapshot cannot be created if the tenant database is the primary database in a system replication scenario.
◈ A fallback snapshot does not replace a database backup.
◈ A fallback snapshot is not included in a database backup.

Always try to follow latest update guide while performing fallback snapshot, chances are this blog might not be updated regularly with any additional functionality in latest HANA release.

Pre-requisite


The database user with which you connect to the SAP HANA database has the privilege DATABASE ADMIN.

Procedure


Open Manage Databases in the SAP HANA cockpit by drilling down from Overall Tenant Statuses in the system Overview for the system database.

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

As you can see, currently there are “No snapshot” for tenant database SL2. But before creating fallback snapshot, we will check the screen where we will be making changes after fallback snapshot.

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

In SAP Application (tcode – SU01), currently you can see that the last name is “Padia11”

Now we will be creating snapshot and make the changes in above screen.

Select the tenant for which you want to create snapshot, click on triple dot icon and select “Create Fallback Snapshot”

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

The moment you take fallback snapshot, it will perform a savepoint (16845) where your data will get persistent till the time when you took fallback snapshot

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

As you can see in Cockpit screen and indexserver log, we have the same time stamp for the fallback snapshot and savepoint.

IMPORTANT NOTE [OBSERVATION]:

After this all the changes that will be made in the system won’t get persistent in database. It will be part of redo log in the form of log segments and your /hana/log will continue to grow. So, you should make sure that you have sufficient free space in /hana/log to accommodate all changes after snapshot creation.

Fallback snapshot is not a replacement of backup, so you should make sure that you reset/delete fallback snapshot once you are done with your activity otherwise your /hana/log will keep on growing and your data won’t get persistent in /hana/data

As you might wonder that if my data does not get persistent after fallback snapshot what happen in case my system gets restarted?

Your system won’t be impacted as during start of system it will read the data till the last savepoint from /hana/data and after that all redo logs from /hana/log and bring up the system in up-to-date state.

Information of fallback snapshot can be found in M_SNAPSHOTS table.

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

After creating snapshot, we have changed the last name from “Padia11” to “Padia”

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

Now we will “Reset to Fallback Snapshot”

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

On resetting snapshot, your system get restarted (for obvious reason)

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

It will restart your system and perform recovery till last savepoint 16845. Once the recovery is done, it will perform another savepoint.

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

In SAP System, you will find that the last name has again changed back to “Padia11”

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

After resetting fallback snapshot, you have to delete it as it still remains even after resetting it.

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

Once you delete the snapshot, you have to reclaim log.

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

SAP HANA 2.0, SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials

As you are aware, from HANA 2.0 cockpit needs to be installed separately but in case if you don’t have cockpit installed you can use below SQL command and also it can used for automation.

-- create
ALTER DATABASE <database name> CREATE FALLBACK SNAPSHOT;
-- reset to snapshot
ALTER SYSTEM START DATABASE <database name> FROM FALLBACK SNAPSHOT;
-- delete
ALTER DATABASE <database name> DROP FALLBACK SNAPSHOT;

Building an App on SAP HANA Express – Part 1, Installing Linux

$
0
0
A while back, my friends at Intel were kind enough to give me a NUC. Thanks, Intel! Anyhow it was time to give it a whirl, so I got it out the cupboard and decided to put SAP HANA Express on it.

In this series of blogs, I’m going to take you through getting HANA Express running on a NUC and building an application based on a publicly available dataset. The same principals will work if you want to install HANA Express on any system.

Hardware


Before you get started with SAP HANA Express, you’re going to need something which it can run on. SAP HANA Express requires 16GB RAM and 2 cores, but recommends 32GB RAM and 4 cores.

My NUC is a NUC6i7KYK which is an Intel Core i7-6770HQ. It’s 4-core, 2.6GHz, with 32GB RAM and 1TB SSD, so we are good to go from a hardware perspective!

I know we are all moving to the cloud, but an Amazon EC2 system with 32GB RAM costs $0.50 an hour to run, over $4000 a year. Yikes. Of course, you’ll turn it off when you’re not using it.
Amusingly I don’t have a USB keyboard or a HDMI screen any more, so I hooked up an Apple Magic keyboard via USB à Lightning, and plugged it into a 55” 4k TV.

I also decided to hardwire the network for the NUC. It will sit in a cupboard once I have it up and running, and having a hardwired network means the SLES will update during the installation.

Operating System


The first thing we need is an OS which SAP HANA Express supports. That’s SLES 12, or RHEL 7. I’m sure my IBM friends will kick me for this, but I’m a SLES guy, ever since RH 4.8 wiped my system in 1997. Just kidding, they’re both great products.

It does surprise me that SAP only supports commercial Linux distributions for HANA Express. It would be cool if they supported at least one non-commercial distribution.

The good news is that SLES provide a 60-day trial of SLES 12 SP3 for SAP Applications. You will need of course to register. Your SLES system may continue to work after 60 days, though you won’t be eligible for updates.

Update BIOS


It’s always a good idea to update the BIOS before you get started, and Intel made this super easy. You just need to find the download page for your product, download the EFI update onto a USB drive, boot the NUC and hit F7 to load the file. I updated from revision 41 to 58 and it took about 5 minutes to complete.

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

Creating a bootable USB Drive


My NUC has the ability to boot from USB, so I don’t need to be trying to burn a DVD. Using PXE to network boot looks like too much hard work for a one-off activity, so I’m going to go with the USB option.

First up, make sure you format your USB stick to MBR and MS-DOS:

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

I’m going to use Etcher to burn my ISO to USB.

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

It took about a minute to flash the 3.8GB ISO onto the USB stick. Success!

Installing SLES 12 SP3


This isn’t complicated – insert the USB stick and then boot the NUC. My NUC has F10 reserved for selecting a boot device, so I hit F10 and select the SanDisk.

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

From there I decided to install SLES with all the default options. I’ll probably need to change some things later that could have been configured in the installer, but since I don’t know exactly what I want right now, there doesn’t seem to be any point in second guessing the installation settings.

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

It takes about 10 minutes to install the OS. It’s funny, I remember watching early versions of Linux install for hours. It’s great that it installs so fast, but some of the anticipation is lost.

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

Basic Security


Once you’ve setup the system, the next step is to configure a ssh server and configure ssh keys. For reasons unknown to me, SUSE don’t do this by default during installation.

Run yast, and go to Security and Users –> Firewall. Add Secure Shell Server to the Allowed Services.

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

First, add on the server the ability to authenticate via public key in /etc/ssh/sshd_config

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

Then restart sshd

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

Create a new user for login purposes:


SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

N.B. I did have some additional hardening here, but found that HXE would not install after this. So I’ll come back to additional Linux hardening after the HXE installation.

Now you need to go ahead and generate the ssh key on your Mac:

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

And then copy your ID to the server:

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

Now I can login without entering a password:

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

Go ahead and remove password authentication and root login from your system in /etc/ssh/sshd_config:

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

And restart sshd:

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

OK – now we have disabled username and password login, as well as root login via ssh, it’s only possible to login from my Mac, and only my user can su to root. This is simple security best practice/hardening.

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

I really wish that Linux providers would step up and provide basic hardening out the box.

Update SLES 12 SP3 to latest versions


This should have happened during the installation, which is really neat. Still, it’s worth checking that your system is completely up to date. This will avoid security or other issues down the line.

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

As a separate check, we can check that we are running a recent Linux kernel, so we know the updates are working.

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

As you can see, we are running on Linux 4.4.156, which is a recent release of the Linux 4.4 Stable branch. 4.4 is an older release of Linux, but SUSE stay within one Linux kernel release within a SP, and SLES 12 SP3 was released on Linux 4.4 in August 2017.

I also like to disable X Windows, because I will be using this as a headless system, so I prefer not to run X Windows on the NUC. Note that this does NOT prevent you from running a remote X Windows Server like XQuartz

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

Configuring Hosts File


This is just a local system, so I don’t have DNS setup. I therefore have to put a manual hosts file entry on my Mac:

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

N.B. I found that HXE requires a FQDN, i.e. hana.applebyj.com. It did not work with hana.local

Installing XQuartz for X Windows tunneling


I like to have a local XQuartz X Windows Server on my Mac, so I can do any GUI work needed on the Linux system.

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

Once you run XQuartz, it just hangs out in the background and appears to do nothing. X Servers are like that, don’t hold it against them. The only way you know it’s running is to check it’s in the task bar:

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

Now I can use ssh in -X mode (X Windows tunneling), and use the hostname hana. It checks to make sure, because I haven’t connected to this system before with this hostname.

Then I can test xclock, and launch it into the background. xclock successfully appears on my Mac. Yay!

SAP HANA, SAP HANA Express, SAP HANA Linux, SAP HANA Study Materials

Final Words


Installing SLES 12 SP3 for SAP Applications on a NUC is fairly painless if you know the steps to take. It took me some trial and error to find the right tools like Etcher, and knowing how to update the BIOS etc.

S4HANA Cloud Key User Extensiblity scenarios: Field Extensibility and Report Extensibility

$
0
0
Extensibility covers a broad spectrum of topics that allows customers and partners to adapt standard business software to their business needs. It ranges from business configuration; layout adaptation of user interface (UI), forms, and reports; custom fields and logic; integration; and custom terminology and translation to customer-specific applications. Extensibility in the SAP S/4HANA suite can be categorized into two main parts: side-by-side extensibility through SAP HANA Cloud Platform and in-app extensibility through built-in capabilities.

Business role:

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

This document will focus on demonstrating key user extensibility: how to consume the custom field in your custom CDS view and custom Analytical Queries.

In my demo to create custom fields, I am taking an example from “Customer Project” app. Using this app, I intend to bring a customer specific field that I could later consume it in my custom CDS view and can further be exposed as OData service or may be bring them into custom Analytical Query for further reporting capabilities.

Customer Project App without any custom Field

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

A simple way to identify if extension options are available for a particular app is the Fiori Apps Library

If the specific app indicates the extensibility of UI5 application in the front-end server, then the app is extensible.

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Custom Fields

As a first step towards the creation of custom field, Go to Custom Fields and Logic Appà Fill the mandatory fields. Make sure the business context is selcted as ‘Engagement project’ and the custom Field I would like to add is Technolgy

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Since I would like to have drop down option for the custom field- Technology I chose ‘Code List’ as Type under General Information and added values that include Artificial Intelligence, Big Data, Business Intelligence etc.

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Now, under the tab strip UI and Reports, I will enable the appropriate data sources that are required while creating the custom CDS views. In order to identify what specific pre-defined views are available,  one need to make sure the data sources are explicitly selected from the cog wheel as shown in the figure below.

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Now, I have published the custom field- Technology.

To bring this custom field- Technology into the specified app, Go to Create Customer project app and then follow the steps:

1. click the user profile and select Adapt UI
2. click UI Adaptation
3. Select the Group Icon
4. I renamed the group Icon to Custom Field my example as shown in the screenshot below.
5. Right click on ‘Custom Field’ and select add field from the available fields, select ‘Technology’ as this is the custom Field I wanted to bring into this app.

Save and Exit

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Customer Project App with custom Field

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Fill the mandatory fields in there along with the new custom field you have added to validate how data gets populated for the reporting purpose.

Custom CDS view

Now, I will create a custom CDS view using I_EngagementProject as this was one of the data source enabled during the creation of custom field.

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Custom CDS view name: YY1_Project_Sample and selected Analytical (described in the below section)as an option which could be later consumed in custom Analytical Query app.

Note: As of 1808 upgrade, we no longer will have the option to enable OData and Analytical(as a cube) at the same time while creating custom CDS view

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Custom field- Technology will be available as selection field for the creation of custom field

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

I have additional fields added to make the reporting looks more meaningful, which is available on the right section of the above image.

Save Draft and Publish!

When previewing the newly created custom CDS view- yy1_project_sample, I will see the new custom field as well getting populated.

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Custom Analytical Queries

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Name the Query: YY1_Project_sample1 and select the Data Source, in this case it will be the custom CDS view that I just created.

Select YY1_Project_sample from the Data source section.

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Note: While creating of custom CDS view, please make sure the analytical option is turned ON, otherwise, the same custom CDS view will not be available for creation of Custom Analytical Query.

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

You will notice all the fields that were part of selection in custom CDS view to reflect in the Custom Analytical Query as well. Here as well, you have the option to pick and choose the fields that are need for your reporting capabilities.

The selected fields will start reflecting in the right pane (just like custom CDS view)

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

In ‘Display’ option, there are several arithmetic operations that can be carried out as well.

Save the draft and Preview!

S4HANA Cloud, SAP HANA Certification, SAP HANA Tutorial and Material, SAP HANA Learning

Drag and drop the fields in the ‘ROWS’ tab to better analyze the data. And you could see the custom field- Technology as well getting populated with the data that was entered for demo purpose.

In my next blog, I will be focusing on Fiori Apps that are not extensible however, we still could create custom fields and expose them in custom CDS view and build Custom Analytical Queries and many more with new extensibility features.

Merge Multiple SCD Tables into A Single Dimension

$
0
0
Tracking historical changes within a dimension is a common task in data warehousing.  Achieving this in a HANA sidecar database (SCD) requires an explicit design focus.  In some cases, the data source system maintains dates and time stamps to denote a record or value’s creation, change, or validity threshold.  In SAP systems creation, change, or validity dates are often but not always maintained for a record, dimension, attribute, or value. One such example being SAP Human Capital Management (HCM) mini-master info-types, seen as below:

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

The above info-types are versioned using a Begin (BEGDA) Date and End (ENDDA) Date thereby creating a validity range.  In this post, I am demonstrating a simplified scenario using the following three tables, each with multiple valid from/to timestamps to show how to merge and aggregate the data into an ordered historical result using SAP HANA calculation views.

Execute the below SQL script then preview the resulting tables and data.

CREATE COLUMN TABLE "STAGING"."PA0000"
(
"PERNR" NVARCHAR(8),
"BEGDA" NVARCHAR(8),
"ENDDA" NVARCHAR(8),
"STAT" NVARCHAR(1)
);


CREATE COLUMN TABLE "STAGING"."PA0001"
(
"PERNR" NVARCHAR(8),
"BEGDA" NVARCHAR(8),
"ENDDA" NVARCHAR(8),
"STAT1" NVARCHAR(1)
);


CREATE COLUMN TABLE "STAGING"."PA0007"
(
"PERNR" NVARCHAR(8),
"BEGDA" NVARCHAR(8),
"ENDDA" NVARCHAR(8),
"STAT7" NVARCHAR(1)
);


INSERT INTO "STAGING"."PA0000" VALUES('03151228','20170801','20180116','A');
INSERT INTO "STAGING"."PA0000" VALUES('03151228','20180116','20180502','B');
INSERT INTO "STAGING"."PA0000" VALUES('03151228','20180502','99991231','C');

INSERT INTO "STAGING"."PA0001" VALUES('03151228','20180501','20180829','D');
INSERT INTO "STAGING"."PA0001" VALUES('03151228','20180829','99991231','E');

INSERT INTO "STAGING"."PA0007" VALUES('03151228','20180301','20180511','F');
INSERT INTO "STAGING"."PA0007" VALUES('03151228','20180511','20181016','G');
INSERT INTO "STAGING"."PA0007" VALUES('03151228','20181016','99991231','H');

Each table contains rows for one Personnel ID (PERNR) with changing attribute stat (STAT,STAT1,STAT7) values.  The changes are denoted by Valid-From (BEGDA) and Valid-To (ENDDA) date ranges.  In this example, we will apply an inclusion of BEGDA and exclusion of ENDA.  Each table combinations of PERNR, BEGDA, and ENDDA to create a unique set of keys for the row.

Table: PA0000

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

Table: PA0001

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

Table: PA0007

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

Here is the final result after merging three tables:

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

The information of the three tables is now merged into a single dimension view. Each row represents a version change of attributes with different BEG_DATE and END_DATE. As an example, the first change for employee 03151228 was starting date 20180116 with the STAT value changed from A to B.

So, how do we get there? There are two steps we define to accomplish this.

Task 1 – Collect all dates then build new valid from/to date ranges using the SAP HANA Rank Node.

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

1) Collect dates in three PA tables. The BEGDA and ENDDA columns are renamed to DATES

Projection Node: PR_PA0000_BEG

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

Projection Node: PR_PA0000_END

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

2) Union all dates using Union Node

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

The result after union (all) is as follows.  There are some duplicate dates such as 20180116, 99991231 etc.

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

3) Remove duplicate dates by applying an Aggregation Node. The dates will now be distinct.

4) To partition PERNR, using an ascending sort we generate a RANK ID for each time slice (assume each PERNR will have maximum 100,000 time slices)

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

Data preview for RANK_DATES

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

5) Derive a column LEAD_RANK_ID using below formula

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

Next we will split the result into two datasets.  The first contains PERNR, DATES, and LEAD_RANK_ID. The second contains PERNR, DATES, and RANK_ID

1ST dataset 

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

2nd dataset

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

6) Apply the following left outer join condition between the first and second dataset. From the 1st dataset, expose DATES and rename it as BEG_DATE. From the 2nd dataset, expose DATES and rename it as END_DATE.

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

Date preview on JN_BEG_END

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

7)  Add a filter removing the last line where END_DATE is null.

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

8) Final result for task 1

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

Task 2 – We now have eight rows (see above) with correct date ranges but without the original three table attributes. We can add the corresponding attributes by joining the initial three base tables with our new data ranges. An SAP HANA temporal join is not applicable here as we are working with a date range instead of temporal column such as a posting date.   Instead, we can write a SAP HANA SQL Script to apply a date range look up.

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

Here is a graphical modeling solution with the final calculation view as below

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

1) Select PA tables etc., PR_PA0000

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

2) Create a left outer join between the new date ranges and PA tables on PERNR only

Left outer join on PERNR

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

See the left outer join results below.  The first row is a valid record as BEG_DATE >= PA00_BEGDA and END_DA <= PA00_ENDDA selecting STAT value A as the correct version.  Note that some rows, such as fourth row, become invalid as BEG_DATE and END_DATE range moves out the row’s PA00_BEGDA and PA00_ENDDA date range.

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

3) Create a calculated attribute to flag invalid rows with a null value

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

Data preview with calculated attribute

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

4) Apply an aggregation node to compress result, eliminating invalid rows with null CC_STAT values.

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

4) Repeat the same steps for PA0001 and PA0007 tables.

SAP HANA Certification, SAP HANA Learning, SAP HANA Tutorial and Materials

Note: In the case where a dimension-based value requires historical perspective but carries no associated create, change or validity dates and/or time, there is the option of deriving the necessary dates during the data warehouse load processes.  Historical attribute views between fact and dimension tables are now possible using SQL or temporal joins.

XSA and SAP Web IDE For SAP HANA 2.0 SPS 03 Feature Revision 1: New Developer Features

$
0
0
Normally when we introduce new features for HANA, it is only done via a new release version (HANA 1.0 or 2.0) or an SPS – Support Package Stack (ex. HANA 2.0 SPS 0, SPS 01, SPS 02, SPS 03). However the XSA runtime and the SAP Web IDE for SAP HANA actually have a rather independent technical infrastructure from the HANA DB itself. Up to this point we’ve never used this feature to deliver new features separate from a HANA release or SPS. But it was always possible.

With HANA platform itself moving to just one SPS a year, we saw a need and an opportunity to update XSA and the SAP Web IDE for SAP HANA without having to wait until the next SPS of HANA itself. Therefore the HANA 2.0 SPS 03 Feature Revision 1 for XSA and the SAP Web IDE for SAP HANA was born. The latest patch level of XSA Runtime (1.0.97) and SAP Web IDE for SAP HANA (4.3.57) which were released this week contain far more than the regular revision patches. Normally a revision patch only contains bug, security, or performance fixes. However for XSA and the SAP Web IDE for SAP HANA, this patch contains major new features.

In order to access these new features you only need to update XSA and the SAP Web IDE for SAP HANA. It does not require a HANA Platform/database update. In fact because both XSA and the SAP Web IDE for SAP HANA are backwards compatible, these new features can be updated on any supported HANA release/SPS – even all the way back to HANA 1.0 SPS 12. We’ve heard from years from customers and partners that they want new technical features, particularly for developers and admins, but don’t want to disrupt the business by going through major HANA updates. This is exactly what we are able to deliver here.


XSA Runtime


The XSA Runtime has a variety of new features that impact the infrastructure, administration and development aspects of XSA applications. The release notes with a complete list are available here: https://launchpad.support.sap.com/#/notes/2691905

However I will go ahead and summarize some of best of these major new features with the focus on developers here:

◈ XSA Single Sign On https://help.sap.com/viewer/6b94445c94ae495c83a19646e7c3fd56/2.0.03/en-US/04ca8c59adaf43b78dfb24675cbb9dae.html
XSA now supports X.509 authentication as well as SPNEGO and Kerberos

◈ XSA can now be installed into a tenant instead of the SYSTEMDB. This feature is only available at installation time and does have a requirement upon the HANA DB backend (at least SAP HANA 2 SPS03 rev 34). We plan to expand this feature in the future to also allow separate XSA installations into multiple tenants and a migration tool to move XSA out of the SYSTEMDB. https://help.sap.com/viewer/2c1988d620e04368aa4103bf26f17727/2.0.03/en-US/9e27727aac8842ef9fb8431525e97a55.html

◈ Support symbolic links when uploading applications to the XS Controller – which can help to decrease the time for application deployment

◈ SAML IdP users can now get XS Controller roles (for example, developer) by assigning a role via the xs cli commands “xs set-org-role” and “xs set-space-role” and specifying the corresponding IdP with the option “–origin”

◈ Send applications logs to external syslog servers

◈ Support http application health checks


SAP Web IDE for SAP HANA



New Project Wizards

Two new project wizards

SAP HANA XSA, SAP HANA 2.0, SAP HANA 2.0 SPS, SAP HANA Study Materials, SAP HANA Guides

◈ SAP HANA Database Application (lightweight/simple project for DB-only development)
◈ SAP Cloud Platform Business Application (new programming model for SAP Cloud Platform and on-premise development – see Week 2 for more details)

SAP HANA Database Application Wizard

SAP HANA XSA, SAP HANA 2.0, SAP HANA 2.0 SPS, SAP HANA Study Materials, SAP HANA Guides

◈ Creates an MTA project, DB module, and HDB container resource from one wizard workflow
◈ Great for calculation view modelers and other low-code developers who just want to create DB artifacts and not have to learn much about mta.yaml and large project structures

Application Programming Model for SAP Cloud Platform

Don’t let the name fool you, the Application Programming Model for SAP Cloud Platform is now available for SAP HANA on premise via XSA and the SAP Web IDE for SAP HANA as well. 

SAP HANA XSA, SAP HANA 2.0, SAP HANA 2.0 SPS, SAP HANA Study Materials, SAP HANA Guides

◈ New application wizard that creates an MTA project but also initializes it for CDS/new application programming model development
◈ Supports both Node.js (Odata V4) and Java (OData V2) service module creation
◈ Creates the HANA DB module
◈ Creates the UAA configuration in the mta.yaml and wiring to generated modules

For much more on this new Application Programming Model and especially how it can be used in the HANA Native development scenario, be sure to check out the upcoming openSAP course.

New Database Artifact Dialog

SAP HANA XSA, SAP HANA 2.0, SAP HANA 2.0 SPS, SAP HANA Study Materials, SAP HANA Guides

◈ Today, you have to type in the file extension for most database artifacts
◈ Error-prone task, and a typo can lead to difficult error messages
◈ Difficult to know which extensions are supported
◈ This new dialog simplifies things by letting you choose the extension from a value list

We now have new database artifact dialog. Previously, there were only a few artifact types listed in the “New” menu option for database artifacts, like we had procedures and functions. But there were a lot of HDI based artfiacts that were missing and we always had to do a “New” -> “File” and give the name of the file and its associated file extension. This was very error prone when having to type out the file extensions, especially for very long ones like .hdbstructuredprivilege. Typos lead to ambiguous error messages and just waste a lot of time. This new dialog simplifies things by allowing you to choose your artifacts from a list, and all of the DB artifacts are now available.

Multiple Workspaces

SAP HANA XSA, SAP HANA 2.0, SAP HANA 2.0 SPS, SAP HANA Study Materials, SAP HANA Guides

◈ Developers can now create multiple workspaces with different configurations in each workspace
◈ You can also have different branches of the same project open for editing in each workspace

Developers can now create multiple workspaces with different configurations in each workspace. This is primarily useful when interacting with multiple git branches. Sometimes you need to make changes in two or more branches at the same time. For instance, when you need to make complex cherry picked fixes in multiple development or feature branches. Before we could only have a single git repository/branch open at one time. Now we can use separate workspace to work on different branches of the same project in parallel.

Resource Manager

SAP HANA XSA, SAP HANA 2.0, SAP HANA 2.0 SPS, SAP HANA Study Materials, SAP HANA Guides

◈ A new view in the bottom-right corner of SAP Web IDE for SAP HANA
◈ It displays all service resources defined in your project
◈ You can also see the service instance name (much like performing the xs services command)
◈ Most important, you can delete the service instance from here

The new resource manager is a new view in the bottom-right corner of the Web IDE which displays all of the service resources defined in our project. You can also see the service instances names and more importantly, you can delete the service instances from here as well. Many customers asked for this feature because they were concerned by how many old containers developers were creating and then abandoning. Admins could use the Cockpit or command line to clean up these container instances, but it is difficult for them to tell when developers are truly finished with them.

Now developers can directly see and take responsibility to clean up their service instance resources – especially before deleting a project or branch from the Web IDE. This feature also helps with troubleshooting errors during service provisioning or binding.

Inactive Indicator

SAP HANA XSA, SAP HANA 2.0, SAP HANA 2.0 SPS, SAP HANA Study Materials, SAP HANA Guides

◈ A new, special indicator for database artifacts
◈ This indicator is shown after you change an object and save it, but before you build the DB module
◈ This helps you identify if recent changes have already been sent to the runtime objects in the database container

SAP HANA System Copy- Homogeneous On Multi Tenant Database – Refresh using SWPM

$
0
0
As explained on my last blog SAP HANA System Copy- Homogeneous On Multi Tenant Database that we have 3 Ways to do System Copy and i explain 2 Ways 1 and 3 according to the note -1844468 – Homogeneous system copy on SAP HANA, and i promised to add 2nd way as well , So below is the 2nd way to do system copy, For Pre checks and preparation please read the 1st blog,

So Now run the SWPM on Your PAS.

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database
SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

Here Select the option Start Migration/Restore Manually.

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

I have done system copy on SCM/APO system so i have installed integrated Live Cache

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

Now We need to do Restore using HANA Stuido , Stop the tenant database if it is running and perform the restore 

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

I used without backup catalog , if you want to select backup from the catalog you can select that option,

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

Now My restore has completed,

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

Move the SWPM now to complete the refresh,

SAP HANA, SAP HANA Studio, SAP NetWeaver, SAP HANA Study Materials, SAP HANA Database

This Complete our System Copy on Tenant Database Using refresh,

Perform the post refresh steps as per the Note-1844468 – Homogeneous system copy on SAP HANA .

SAP S/4HANA: Key Adoption Scenarios to Consider Webcast Recap

$
0
0
SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

This was a SAP user group webinar from yesterday.

Interesting developments are planned next year for 1809 in terms of system conversion; read below.

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Legal disclaimer applies, subject to change

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning


SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Separate product line

S4 is “next generation” digital core

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Main release – one per year

5 years maintenance of release

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Release strategy

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Approaches

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

3 layers on the right for user interface, database

Implement business practice on new platform

Data load via integration cockpit

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Suite on HANA customers need to update database to SAP HANA 2 and then do system conversion

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Going from S4 to S4

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Read the SAP Notes listed

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

With HANA 2 need two step to get to S/4HANA

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning


SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

More on the landscape transformation

System Conversion


SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Left includes tools for the planning phase for S/4HANA

Readiness Check


SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Free for SAP Maintenance Agreement and need S-user

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

See SAP Note for readiness check

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

How the readiness check looks, how to review

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Plans for 2019

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Simplification Check

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Search for it

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Checks are done before conversion to bring system in a consistent state.

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Migration cockpit

Included in license for S/4HANA

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Able to add customer specific files

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Next year, plan to transfer directly from SAP Source system

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Preview of 1809 FPS01; transfer data directly from source system

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

All notes in one slide for SAP S/4HANA Migration Cockpit

SAP S/4HANA, SAP HANA Tutorial and Materials, SAP HANA Guides, SAP HANA Learning

Tool list by phase

The ability to transfer from source system (ECC) will be very interesting for next year; what do you think?

Create Time-Related Tables and Generate Time Data in SAP HANA XSA Platform

$
0
0

Introduction


Time data is necessary almost in any kind of data manipulation process, as well as adding time-dimension to the calculation views. So, ways to go for the time-dimension has changed a bit with the release of SAP HANA XSA Platform. In this blog post, you’ll see how to create time-related tables if required, and generate time data through the steps on SAP WEB IDE.

If you’d like to check how time data generation is handled in XS Classic, which is the previous version of XS Advanced, you can visit this nice blog on this link.

Context


You can create and fill time-related tables by using the standard tool SAP WEB IDE provides.

There are two options to generate time data in XSA Platform in terms of where database objects are stored. These objects can be stored in:
1. HDI Container’s Schema.
2. Classical _SYS_BI Schema

Let’s go through these in detail.

Option 1: In the HDI Container’s Schema


This is the brand new method came with XSA and lets you have HDI container specific time tables. In this case, there is a newly created SAP HANA Database Module which means time tables must be created at first and time data will be generated afterwards.

Procedure

In the image below, you see an already created MTA project called “HANA01” and a HANA Database Module with the name of “HANADB01”. I assume you’ve already created these. In the workspace view, we do right click on the HANADB01 folder which corresponds to SAP HANA Database Module, and choose Modeling Actions > Maintain Time Tables

SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials, SAP HANA Certification

The following preferences are presented as in the image below. If you only need time data with day granularity you can just select it as per your requirement and only tables related to the selected preferences will be created for the HDI container. For demonstration purposes, all the options are selected.

SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials, SAP HANA Certification

If you click “Generate Data After Creation” option, tables will be automatically created and data will be generated as soon as you click “Generate” button. In other words, it is an immediate trigger for the database module building process.

HANA CDS documents are created automatically under the automatically created “time_tables” folder. Each CDS document refers to the time table with the same name.

SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials, SAP HANA Certification

Now, switch to the Database Explorer view and verify the tables in the HDI container.

For the Gregorian calendar type, modeler has generated time dimension data into M_TIME_DIMENSION_YEAR, M_TIME_DIMENSION_MONTH, M_TIME_DIMENSION_WEEK, M_TIME_DIMENSION tables in the HDI container.

SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials, SAP HANA Certification

Data can be verified as follows.

SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials, SAP HANA Certification

Option 2: In the Classical _SYS_BI Schema


This option lets you have time data in the classical system default _SYS_BI Schema. This is also the option we only had in XS Classic. Before XSA, it was developed by using Hana Studio/Eclipse.

Tables are present as default within _SYS_BI Schema, so only time data has to be generated.

Prerequisite

For this option, you will need an HDI Container based on a user-defined service which has insert privileges to the _SYS_BI Schema. CROSS_SCHEMA_PRODUCTS HDI will be used for this purpose.

Procedure

Go to the Database Explorer view, expand the HDI container, right click on “Tables” and select “Generate Time Data”.

SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials, SAP HANA Certification

Following preferences are displayed. I choose “Day” as granularity and “Gregorian” as calendar type in this case.

SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials, SAP HANA Certification

Open an SQL Console and verify the data with the following SQL statement.

select * from "_SYS_BI"."M_TIME_DIMENSION";

--For other granularity levels
select * from "_SYS_BI"."M_TIME_DIMENSION_MONTH";
select * from "_SYS_BI"."M_TIME_DIMENSION_WEEK";
select * from "_SYS_BI"."M_TIME_DIMENSION_YEAR";

In the following image, data in the “_SYS_BI”.”M_TIME_DIMENSION” is previewed.

SAP HANA Study Materials, SAP HANA Guides, SAP HANA Tutorial and Materials, SAP HANA Certification

Conclusion


So far, we’ve covered details to create time-related tables and data in the SAP HANA XSA Platform. After having tables and data ready, you can now add time-related tables in calculation views as a data source or use them in any executable SQL statements. The same steps can also be used in SAP Cloud Platform Cloud Foundry.

Which option you’ll choose mostly depends on the requirement. However, the first option provides flexibility to have a separate configuration to generate time data for each SAP HANA Database Module. So, each HANA Database Module can have its own generated time data.
Viewing all 711 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>