Skip to Content
author's profile photo Former Member
Former Member

OData Create operation in JavaScript


does anyone have a working example or a simple explanation of a create operation for OData services in HTML / JavaScript / AngularJS?

I want to create new entities on my existing database. Is this also doable via URL (I dont think so)?

Thanks in advance,

yours truly,


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 10, 2016 at 11:46 AM


    you asked for a basic example, I hope this will help.

    (It's very basic, just to give you an idea.)

    //first, we create a button to press and call the update

    var myButtonInsert = new sap.ui.commons.Button("btninsert");

    myButtonInsert.setText("Insert Comment");

    myButtonInsert.attachPress(function() {



    // define the Table columns

    var oControl1 = new sap.ui.commons.TextView({text:"{COMMENT_ID}"}); // short binding notation

    oTable.addColumn(new sap.ui.table.Column({

    label: new sap.ui.commons.Label({text: "Comment ID"}),

    template: oControl1,

    sortProperty: "commentID",

    filterProperty: "commentID",

    width: "100px"}));

    .... More columns ....

    var oEntry = {};

    function onInsert() {

    var aUrl = '';

    oEntry.COMMENT_ID = commentID.getValue();

    oEntry.DATE = date.getValue();

    oEntry.USER_ID = userID.getValue();

    oEntry.COMMENT_TEXT = commentText.getValue();

    oEntry.POST_ID = postID.getValue();



    headers: {

    'Accept': 'application/json',

    'Content-Type': 'application/json'


    url: aUrl,

    type: 'POST',

    dataType: 'json',

    data: JSON.stringify(oEntry),

    success: function() {

    alert("Record Inserted");



    error: function() {

    alert("Insert Failed");




    The result is a form that will add a record to a HANA database, so perform a POST operation.


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 08, 2016 at 11:48 AM

    Have a look at SHINE (SAP HANA Interactive Education). There are examples there. The only difference is they use SAPUI5 and not Angular JS on the client side.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.