<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic OData Create method with auto incremental ID in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-create-method-with-auto-incremental-id/m-p/447959#M13495</link>
    <description>&lt;P&gt;I'm trying to perform the OData.create method on my SAPUI5 application.  However, when calling the create method from the controller.js I get this error: &lt;/P&gt;&lt;P&gt;The serialized resource has an missing value for member 'ID'&lt;/P&gt;&lt;P&gt;This is the structure of the ID column in the SAP HANA database: &lt;/P&gt;&lt;P&gt;"ID" INTEGER CS_INT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY&lt;/P&gt;&lt;P&gt;When trying to insert through a SQL command in SAP HANA it inserts just fine without specifying the ID.&lt;/P&gt;&lt;P&gt;However, through the application it is not working.&lt;/P&gt;&lt;P&gt;var newGMID = { &lt;/P&gt;&lt;P&gt;        GMID: 7653, &lt;/P&gt;&lt;P&gt;        COUNTRY_CODE_ID: 34, &lt;/P&gt;&lt;P&gt;        CURRENCY_CODE_ID: 344, &lt;/P&gt;&lt;P&gt;        IBP_RELEVANCY_CODE_ID: 370, &lt;/P&gt;&lt;P&gt;        NETTING_DEFAULT_CODE_ID: 374, &lt;/P&gt;&lt;P&gt;        QUADRANT_CODE_ID: 378, &lt;/P&gt;&lt;P&gt;        CHANNEL_CODE_ID: 383, &lt;/P&gt;&lt;P&gt;        MARKET_DEFAULT_CODE_ID: 386, &lt;/P&gt;&lt;P&gt;        TYPE: "SEEDS", &lt;/P&gt;&lt;P&gt;        GMID_COUNTRY_STATUS_CODE_ID: 389
        }; &lt;/P&gt;&lt;P&gt;        var oDataModel = this.getView().getModel();
        oDataModel.create("/GMID_SHIP_TO_COUNTRY", newGMID, &lt;/P&gt;&lt;P&gt;        { &lt;/P&gt;&lt;P&gt;        success: function(oData, oResponse)&lt;/P&gt;&lt;P&gt;{
    MessageToast.show("GMID successfully inserted into DB");
    },&lt;/P&gt;&lt;P&gt;
    error: function(oData, oResponse)&lt;/P&gt;&lt;P&gt;{
    MessageToast.show("Error. GMID not inserted.");
}&lt;/P&gt;&lt;P&gt;
        });&lt;/P&gt;&lt;P&gt;I have an Odata Service set up (version 2) and have no custom code for my .xsodata file.  &lt;/P&gt;&lt;P&gt;"BAMDEV"."GMID_SHIP_TO_COUNTRY" as "GMID_SHIP_TO_COUNTRY";&lt;/P&gt;&lt;P&gt;I have tried including the ID in my newGMID object as null, 0, "" but with no luck.  It gives me a duplicate key error when trying to insert twice with the same ID.  It is therefore not auto-incrementing.  &lt;/P&gt;&lt;P&gt;If I specify the ID to a random number and it is not yet in the database, it inserts just fine.  &lt;/P&gt;&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;</description>
    <pubDate>Sat, 20 May 2017 22:07:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2017-05-20T22:07:06Z</dc:date>
    <item>
      <title>OData Create method with auto incremental ID</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-create-method-with-auto-incremental-id/m-p/447959#M13495</link>
      <description>&lt;P&gt;I'm trying to perform the OData.create method on my SAPUI5 application.  However, when calling the create method from the controller.js I get this error: &lt;/P&gt;&lt;P&gt;The serialized resource has an missing value for member 'ID'&lt;/P&gt;&lt;P&gt;This is the structure of the ID column in the SAP HANA database: &lt;/P&gt;&lt;P&gt;"ID" INTEGER CS_INT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY&lt;/P&gt;&lt;P&gt;When trying to insert through a SQL command in SAP HANA it inserts just fine without specifying the ID.&lt;/P&gt;&lt;P&gt;However, through the application it is not working.&lt;/P&gt;&lt;P&gt;var newGMID = { &lt;/P&gt;&lt;P&gt;        GMID: 7653, &lt;/P&gt;&lt;P&gt;        COUNTRY_CODE_ID: 34, &lt;/P&gt;&lt;P&gt;        CURRENCY_CODE_ID: 344, &lt;/P&gt;&lt;P&gt;        IBP_RELEVANCY_CODE_ID: 370, &lt;/P&gt;&lt;P&gt;        NETTING_DEFAULT_CODE_ID: 374, &lt;/P&gt;&lt;P&gt;        QUADRANT_CODE_ID: 378, &lt;/P&gt;&lt;P&gt;        CHANNEL_CODE_ID: 383, &lt;/P&gt;&lt;P&gt;        MARKET_DEFAULT_CODE_ID: 386, &lt;/P&gt;&lt;P&gt;        TYPE: "SEEDS", &lt;/P&gt;&lt;P&gt;        GMID_COUNTRY_STATUS_CODE_ID: 389
        }; &lt;/P&gt;&lt;P&gt;        var oDataModel = this.getView().getModel();
        oDataModel.create("/GMID_SHIP_TO_COUNTRY", newGMID, &lt;/P&gt;&lt;P&gt;        { &lt;/P&gt;&lt;P&gt;        success: function(oData, oResponse)&lt;/P&gt;&lt;P&gt;{
    MessageToast.show("GMID successfully inserted into DB");
    },&lt;/P&gt;&lt;P&gt;
    error: function(oData, oResponse)&lt;/P&gt;&lt;P&gt;{
    MessageToast.show("Error. GMID not inserted.");
}&lt;/P&gt;&lt;P&gt;
        });&lt;/P&gt;&lt;P&gt;I have an Odata Service set up (version 2) and have no custom code for my .xsodata file.  &lt;/P&gt;&lt;P&gt;"BAMDEV"."GMID_SHIP_TO_COUNTRY" as "GMID_SHIP_TO_COUNTRY";&lt;/P&gt;&lt;P&gt;I have tried including the ID in my newGMID object as null, 0, "" but with no luck.  It gives me a duplicate key error when trying to insert twice with the same ID.  It is therefore not auto-incrementing.  &lt;/P&gt;&lt;P&gt;If I specify the ID to a random number and it is not yet in the database, it inserts just fine.  &lt;/P&gt;&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 20 May 2017 22:07:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-create-method-with-auto-incremental-id/m-p/447959#M13495</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-05-20T22:07:06Z</dc:date>
    </item>
  </channel>
</rss>

