Skip to Content
Apr 17, 2018 at 03:06 PM

How to handle an autoincremented ID in HANA from a SAPUI5-application?

609 Views Last edit Apr 17, 2018 at 03:14 PM 3 rev


in my SAPUI5-Application I got the following function that takes the data and creates an entry in my HANA DB:

 onCreateNewCustomer: function(){
	    	var oEntry = {};
	    	oEntry.NAME = this.byId("name").getValue();
	    	oEntry.CITY = this.byId("city").getValue();
	    	oEntry.PHONE = this.byId("phone").getValue();                               oEntry.ID = this.byId("id").getValue();
	    	// Post data to the server
	    	this.getOwnerComponent().getModel("CustomerModel").create("/                Customer", oEntry, null);

The creating process works and my entries get saved. In the next step I wanted to implement my table in HANA in that way, that the ID of the entries will be autoincremented so the user does not have to enter it. I used the following command to create my table:

create column table TABLE
         (ID bigint not null primary key generated by default as IDENTITY,
          FIRSTNAME nvarchar(30))

That worked, table is created. The problem now is, if I use the code above without providing the ID, the following error is logged by the console:

The following problem occurred: HTTP request failed400,Bad Request,<?xml version="1.0" encoding="utf-8" standalone="yes"?><error xmlns=""><code/><message xml:lang="en-US">The serialized resource has an missing value for member 'ID'.</message></error>

The entry does not get saved in my DB. If I execute the following SQL-Statements in my HANA Workbench without providing the ID, it works:

insert into TABLE (FIRSTNAME) values (‘David’);
insert into TABLE (FIRSTNAME) values (‘Mike’);      
insert into TABLE (FIRSTNAME) values (‘Bobby’);   

So I did some searching on google but did not find a proper solution on how to do this. My goal is that the entry gets saved and the ID is provided by my HANA DB without providing it from my SAPUI5 Application.

Im thankful for any help how this can be done!