<?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>Question Re: Posting using Odata in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaa-p/736180#M206723</link>
    <description>&lt;P&gt;Hi Siddharth,&lt;/P&gt;&lt;P&gt;You should always use the ui5 odata  to perform the crud operations. check the reference api below:&lt;/P&gt;&lt;P&gt;&lt;A href="https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel" target="test_blank"&gt;https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also, do not instantiate the odata service in your code manually. you can use the manifest.json which will automatically instantiate your service.&lt;/P&gt;&lt;P&gt;Ideally in manifest.json, you will make your odata model as nameless model.&lt;/P&gt;&lt;P&gt;In you app, get the model and call the create&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;this.getView().getModel().create("/EntitysetName",{properties:properties}, {
success: function(mData){

}.bind(this),

error: function(mData){

}.bind(this)
});&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A href="https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/create" target="test_blank"&gt;https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/create&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I also suggest you to use the webide to generate the initial template(worklist) this will auto generate the basic code for you, later you can delete the files that you dont want and build on top of it, it also has the automatic instantiation of the odata model inside the manifest. &lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;</description>
    <pubDate>Mon, 24 Dec 2018 15:31:25 GMT</pubDate>
    <dc:creator>maheshpalavalli</dc:creator>
    <dc:date>2018-12-24T15:31:25Z</dc:date>
    <item>
      <title>Posting using Odata</title>
      <link>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaq-p/736179</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;
  &lt;P&gt;I am trying to create internal order using OData in Fiori.&lt;/P&gt;
  &lt;P&gt;I have currently used this code which is giving me errors saying&lt;STRONG&gt; Identifier Expected.&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;I'm using this blog as a reference : &lt;/P&gt;
  &lt;P&gt;&lt;A href="https://blogs.sap.com/2015/02/05/simple-exercise-on-odata-and-sap-ui5-application-for-the-basic-crud-operation/" target="test_blank"&gt;https://blogs.sap.com/2015/02/05/simple-exercise-on-odata-and-sap-ui5-application-for-the-basic-crud-operation/&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;XML&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt; &amp;lt;Panel headerText="Internal Order Details" width="100%" height="auto" expanded="true" backgroundDesign="Solid"&amp;gt;
    &amp;lt;RadioButtonGroup id="group0" columns="2"&amp;gt;
     &amp;lt;buttons &amp;gt;
      &amp;lt;RadioButton id="rbtnEUIB" text="IO Asset CAP Unbudgeted (EUIB)"/&amp;gt;
      &amp;lt;RadioButton id="rbtnEIDB" text="IO Asset Budgeted Capex (EIBD)"/&amp;gt;
     &amp;lt;/buttons&amp;gt;
    &amp;lt;/RadioButtonGroup&amp;gt;
    &amp;lt;HBox id="hbox1" width="100%" justifyContent="SpaceAround" wrap="Wrap" backgroundDesign="Solid"&amp;gt;
     &amp;lt;items&amp;gt;
      &amp;lt;Input id="txtIONo" placeholder="Internal Order No"/&amp;gt;
      &amp;lt;Input id="txtDesc" placeholder="Description"/&amp;gt;
     &amp;lt;/items&amp;gt;
    &amp;lt;/HBox&amp;gt;
   &amp;lt;/Panel&amp;gt;
   &amp;lt;IconTabBar id="bar0" selectedKey="__xmlview0--attachment"&amp;gt;
    &amp;lt;items&amp;gt;
     &amp;lt;IconTabFilter id="Info" text="Info" icon="sap-icon://hint" iconColor="Positive"&amp;gt;
      &amp;lt;content&amp;gt;
       &amp;lt;sap.ui.layout.form:Form xmlns:sap.ui.layout.form="sap.ui.layout.form" id="form0" editable="true"&amp;gt;
        &amp;lt;sap.ui.layout.form:formContainers&amp;gt;
         &amp;lt;sap.ui.layout.form:FormContainer id="container1"&amp;gt;
          &amp;lt;sap.ui.layout.form:formElements&amp;gt;
           &amp;lt;sap.ui.layout.form:FormElement id="element1" label="Controlling Area"&amp;gt;
            &amp;lt;sap.ui.layout.form:fields&amp;gt;
             &amp;lt;Input id="txtContolArea" value="4000" width="20%"/&amp;gt;
            &amp;lt;/sap.ui.layout.form:fields&amp;gt;
           &amp;lt;/sap.ui.layout.form:FormElement&amp;gt;
           &amp;lt;sap.ui.layout.form:FormElement id="element2" label="Company Code"&amp;gt;
            &amp;lt;sap.ui.layout.form:fields&amp;gt;
             &amp;lt;Input id="txtCompanyCode" value="362" width="20%"/&amp;gt;
            &amp;lt;/sap.ui.layout.form:fields&amp;gt;
           &amp;lt;/sap.ui.layout.form:FormElement&amp;gt;
           &amp;lt;sap.ui.layout.form:FormElement id="element3" label="Plant"&amp;gt;
            &amp;lt;sap.ui.layout.form:fields&amp;gt;
             &amp;lt;Input id="txtPlant" width="20%"/&amp;gt;
            &amp;lt;/sap.ui.layout.form:fields&amp;gt;
           &amp;lt;/sap.ui.layout.form:FormElement&amp;gt;
           &amp;lt;sap.ui.layout.form:FormElement id="element4" label="Object Class"&amp;gt;
            &amp;lt;sap.ui.layout.form:fields&amp;gt;
             &amp;lt;ComboBox id="cboxObjCls" width="20%"&amp;gt;
              &amp;lt;items&amp;gt;
               &amp;lt;core:Item xmlns:core="sap.ui.core" id="item2" text="Investment" key="IV"/&amp;gt;
               &amp;lt;core:Item xmlns:core="sap.ui.core" id="item3" text="Overhead" key="OC"/&amp;gt;
               &amp;lt;core:Item xmlns:core="sap.ui.core" id="item4" text="Earnings, Sales" key="PA"/&amp;gt;
               &amp;lt;core:Item xmlns:core="sap.ui.core" id="item5" text="Production" key="PR"/&amp;gt;
              &amp;lt;/items&amp;gt;
             &amp;lt;/ComboBox&amp;gt;
            &amp;lt;/sap.ui.layout.form:fields&amp;gt;
           &amp;lt;/sap.ui.layout.form:FormElement&amp;gt;
           &amp;lt;sap.ui.layout.form:FormElement id="element6" label="Profit Center"&amp;gt;
            &amp;lt;sap.ui.layout.form:fields&amp;gt;
             &amp;lt;Input id="input6" width="40%"/&amp;gt;
            &amp;lt;/sap.ui.layout.form:fields&amp;gt;
           &amp;lt;/sap.ui.layout.form:FormElement&amp;gt;
           &amp;lt;sap.ui.layout.form:FormElement id="element7" label="Responsible CCtr"&amp;gt;
            &amp;lt;sap.ui.layout.form:fields&amp;gt;
             &amp;lt;Input id="input7" width="40%"/&amp;gt;
            &amp;lt;/sap.ui.layout.form:fields&amp;gt;
           &amp;lt;/sap.ui.layout.form:FormElement&amp;gt;
           &amp;lt;sap.ui.layout.form:FormElement id="element8" label="User Responsible"&amp;gt;
            &amp;lt;sap.ui.layout.form:fields&amp;gt;&amp;lt;Input id="input8" width="40%"/&amp;gt;
            &amp;lt;/sap.ui.layout.form:fields&amp;gt;
           &amp;lt;/sap.ui.layout.form:FormElement&amp;gt;
           &amp;lt;sap.ui.layout.form:FormElement id="element8_copy2" label="Request CCtr"&amp;gt;
            &amp;lt;sap.ui.layout.form:fields&amp;gt;
             &amp;lt;Input id="input8_copy2" width="40%"/&amp;gt;
            &amp;lt;/sap.ui.layout.form:fields&amp;gt;
           &amp;lt;/sap.ui.layout.form:FormElement&amp;gt;
           &amp;lt;sap.ui.layout.form:FormElement id="element8_copy4" label="WPS"&amp;gt;
            &amp;lt;sap.ui.layout.form:fields&amp;gt;
             &amp;lt;Input id="input8_copy4" width="40%"/&amp;gt;
            &amp;lt;/sap.ui.layout.form:fields&amp;gt;
           &amp;lt;/sap.ui.layout.form:FormElement&amp;gt;
           &amp;lt;sap.ui.layout.form:FormElement id="element0"&amp;gt;
            &amp;lt;sap.ui.layout.form:fields &amp;gt;
             &amp;lt;Button xmlns="sap.m" id="btnCreate" type="Accept" press="onCreate" text="Create"/&amp;gt;
             &amp;lt;Button xmlns="sap.m" id="btnCancel" type="Reject" text="Cancel"/&amp;gt;
            &amp;lt;/sap.ui.layout.form:fields&amp;gt;
           &amp;lt;/sap.ui.layout.form:FormElement&amp;gt;
          &amp;lt;/sap.ui.layout.form:formElements&amp;gt;
         &amp;lt;/sap.ui.layout.form:FormContainer&amp;gt;
        &amp;lt;/sap.ui.layout.form:formContainers&amp;gt;
        &amp;lt;sap.ui.layout.form:layout&amp;gt;
         &amp;lt;sap.ui.layout.form:ResponsiveGridLayout id="layout0"/&amp;gt;
        &amp;lt;/sap.ui.layout.form:layout&amp;gt;
       &amp;lt;/sap.ui.layout.form:Form&amp;gt;
      &amp;lt;/content&amp;gt;
     &amp;lt;/IconTabFilter&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;JS&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;  var that = this;
  var ioType = "";
  var oEIDB = that.getView().byId("rbtnEIDB");
  var oEUIB = that.getView().byId("rbtnEUIB");
  if (oEIDB.getSelected()) {
   ioType = "EUIB";
  } else if (oEUIB.getSelected()) {
   ioType = "EIBD";
  }
  var oIOdata = {};
  oIOdata.Compcode = that.getView().byId("txtCompanyCode").getValue();
  oIOdata.ControllingArea = that.getView().byId("txtContolArea").getValue();
  oIOdata.Plant = that.getView().byId("txtPlant").getValue();
  oIOdata.ObjectClass = that.getView().byId("cboxObjCls").getSelectedKey();
  oIOdata.OrderName = that.getView().byId("txtDesc").getValue();
  oIOdata.UserRespons = that.getView().byId("txtUserResp").getValue();
  oIOdata.ProfitCenter = that.getView().byId("txtProfitCenter").getValue();
  oIOdata.RespCostCenter = that.getView().byId("txtRespCCtr").getValue();
  oIOdata.ReqCostCenter = that.getView().byId("txtReqCCtr").getValue();
  oIOdata.OrderNumber = that.getView().byId("txtIONo").getValue();
  oIOdata.OrderType = ioType;
  OData.request({
    requestUri: "/sap/opu/odata/AAG362/FI_INTERNAL_ORDER_SRV/InternalOrderSet",
    method: "GET",
    headers: {
     "X-Requested-With": "XMLHttpRequest",
     "Content-Type": "application/atom+xml",
     "DataServiceVersion": "2.0",
     "X-CSRF-Token": "Fetch"
    }
   },
   function (data, response) {
    header_xcsrf_token = response.headers['x-csrf-token'];
    var oHeaders = {
     "x-csrf-token": header_xcsrf_token,
     'Accept': 'application/json',
    };
    OData.request({
      requestUri: "/sap/opu/odata/AAG362/FI_INTERNAL_ORDER_SRV/InternalOrderSet",
      method: "POST",
      headers: oHeaders,
      data: oIOdata
     },
     function (data, request) {
      alert("Internal Order Created");
      location.reload(true);
     },
     function (err) {
      alert("Creation failed");
     });
   },
   function (err) {
    var request = err.request;
    var response = err.response;
    alert("Error in GET -- Request " + request + " Response " + response);
   });
 
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;OData&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;entry&amp;gt;&amp;lt;id&amp;gt;http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/FI_INTERNAL_ORDER_SRV/InternalOrderSet('')&amp;lt;/id&amp;gt;&amp;lt;a xmlns="http://www.w3.org/1999/xhtml" style="color: blue; margin-left: -2em;"&amp;gt;&amp;lt;&amp;lt;span style="color: rgb(153, 0, 0);"&amp;gt;title&amp;lt;/span&amp;gt; &amp;lt;span style="color: rgb(153, 0, 0);"&amp;gt;type&amp;lt;/span&amp;gt;="&amp;lt;span style="color: black; font-weight: bold;"&amp;gt;text&amp;lt;/span&amp;gt;"&amp;gt;&amp;lt;/a&amp;gt;InternalOrderSet('')&amp;lt;span xmlns="http://www.w3.org/1999/xhtml" style="color: blue;"&amp;gt;&amp;lt;/&amp;lt;span style="color: rgb(153, 0, 0);"&amp;gt;title&amp;lt;/span&amp;gt;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;updated&amp;gt;2018-12-24T12:48:14Z&amp;lt;/updated&amp;gt;&amp;lt;category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="AAG362.FI_INTERNAL_ORDER_SRV.InternalOrder"/&amp;gt;&amp;lt;link title="InternalOrder" rel="self" href="InternalOrderSet('')"/&amp;gt;&amp;lt;content type="application/xml"&amp;gt;&amp;lt;m:properties xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"&amp;gt;&amp;lt;d:Compcode/&amp;gt;&amp;lt;d:ControllingArea/&amp;gt;&amp;lt;d:Plant/&amp;gt;&amp;lt;d:ObjectClass/&amp;gt;&amp;lt;d:OrderName/&amp;gt;&amp;lt;d:UserRespons/&amp;gt;&amp;lt;d:ProfitCenter/&amp;gt;&amp;lt;d:RespCostCenter/&amp;gt;&amp;lt;d:ReqCostCenter/&amp;gt;&amp;lt;d:OrderNumber/&amp;gt;&amp;lt;d:WBS/&amp;gt;&amp;lt;d:OrderType/&amp;gt;&amp;lt;/m:properties&amp;gt;&amp;lt;/content&amp;gt;&amp;lt;/entry&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;How do I resolve this error???&lt;/P&gt;
  &lt;P&gt;I also read about using ODataModel.create()... would that be better...&lt;/P&gt;
  &lt;P&gt;please help and advice&lt;/P&gt;
  &lt;P&gt;Thanking You&lt;/P&gt;
  &lt;P&gt;Siddharth&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Dec 2018 12:52:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaq-p/736179</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-12-24T12:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Posting using Odata</title>
      <link>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaa-p/736180#M206723</link>
      <description>&lt;P&gt;Hi Siddharth,&lt;/P&gt;&lt;P&gt;You should always use the ui5 odata  to perform the crud operations. check the reference api below:&lt;/P&gt;&lt;P&gt;&lt;A href="https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel" target="test_blank"&gt;https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also, do not instantiate the odata service in your code manually. you can use the manifest.json which will automatically instantiate your service.&lt;/P&gt;&lt;P&gt;Ideally in manifest.json, you will make your odata model as nameless model.&lt;/P&gt;&lt;P&gt;In you app, get the model and call the create&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;this.getView().getModel().create("/EntitysetName",{properties:properties}, {
success: function(mData){

}.bind(this),

error: function(mData){

}.bind(this)
});&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A href="https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/create" target="test_blank"&gt;https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/create&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I also suggest you to use the webide to generate the initial template(worklist) this will auto generate the basic code for you, later you can delete the files that you dont want and build on top of it, it also has the automatic instantiation of the odata model inside the manifest. &lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;</description>
      <pubDate>Mon, 24 Dec 2018 15:31:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaa-p/736180#M206723</guid>
      <dc:creator>maheshpalavalli</dc:creator>
      <dc:date>2018-12-24T15:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Posting using Odata</title>
      <link>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaa-p/736181#M206724</link>
      <description>&lt;P&gt;hii Mahesh,&lt;/P&gt;&lt;P&gt;I tried the code above:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; oModel.create("/InternalOrderSet", oIOdata, {
    success: function (oData, response) {
     console.log(response);
     MessageBox.show(oData.OrderNumber + " has been Created");
    }.bind(this),
    error: function (oError) {
     MessageBox.show(oError + ": Error has occurred");
    }.bind(this)
   });&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;it worked, I get a 201 status but the IO does not get created at the backend. I ran the service in Frontend server there it worked. am I missing something here??&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Siddharth&lt;/P&gt;</description>
      <pubDate>Thu, 27 Dec 2018 06:28:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaa-p/736181#M206724</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-12-27T06:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Posting using Odata</title>
      <link>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaa-p/736182#M206725</link>
      <description>&lt;P&gt;Hi Siddharth,&lt;/P&gt;&lt;P&gt;1. "I ran the service in Frontend server there it worked." ? I didnt understand this part, ran in front end server means, you tried in gw_client tcode?&lt;/P&gt;&lt;P&gt;2. If the status is 201 means, it is success, now you need to put an external breakpoint in that redefined create method and check if the code is working or not.&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;</description>
      <pubDate>Thu, 27 Dec 2018 07:59:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaa-p/736182#M206725</guid>
      <dc:creator>maheshpalavalli</dc:creator>
      <dc:date>2018-12-27T07:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Posting using Odata</title>
      <link>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaa-p/736183#M206726</link>
      <description>&lt;P&gt;so I changed the model definition from this.getView().getModel() to a sap.ui.model.odata.ODataModel(oServiceURL, true); and it worked&lt;/P&gt;&lt;P&gt;Siddharth &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Dec 2018 11:15:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaa-p/736183#M206726</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-12-28T11:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: Posting using Odata</title>
      <link>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaa-p/736184#M206727</link>
      <description>&lt;P&gt;Hi Sid,&lt;/P&gt;&lt;P&gt;Super, but any reason why u are instantiating it using sap.ui.model.odata.OdataModel ?&lt;/P&gt;&lt;P&gt;It's better to instantiate the service using manifest.json instead of manually.&lt;/P&gt;&lt;P&gt;BR, Mahesh&lt;/P&gt;</description>
      <pubDate>Fri, 28 Dec 2018 11:48:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/posting-using-odata/qaa-p/736184#M206727</guid>
      <dc:creator>maheshpalavalli</dc:creator>
      <dc:date>2018-12-28T11:48:33Z</dc:date>
    </item>
  </channel>
</rss>

