Hi All,
I have developed odata service to perform insert operation, when I tested in gateway client its inserting the record in the back-end properly.
I have developed a ui5 application(code is in below) for inserting the record by consuming odata service which I discussed above. But when I am inserting the record from front end its not inserting in back end .can anybody please help me regarding this issue
html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<script src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m,sap.ui.commons,sap.ui.layout"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-resourceroots='{"view": "./"}'
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->
<script>
sap.ui.localResources("view");
var app = new sap.m.App({initialPage:"idView1"});
var view = sap.ui.view({id:"idView1", viewName:"view.View1", type:sap.ui.core.mvc.ViewType.JS});
view.placeAt("content");
var oSimpleForm = new sap.ui.layout.form.SimpleForm("sf1",{
maxContainerCols : 2,
editable : true,
content:[ new sap.ui.commons.Label({text:"Empno"}),
new sap.ui.commons.TextField({value:" ",width : '15em'}),
new sap.ui.commons.Label({text:"Machineid"}),
new sap.ui.commons.TextField({value:" ",width : '15em'}),
new sap.ui.commons.Label({text:"Reamrks"}),
new sap.ui.commons.TextField({value:" ",width : '15em'}),
new sap.ui.commons.Label({text:"Updationmode"}),
new sap.ui.commons.TextField({value:" ",width : '15em'}),
]
});
var opanel = new sap.ui.commons.Panel({text: "Time Punch Data"});
opanel.addContent(oSimpleForm);
opanel.placeAt("content");
var button = new sap.ui.commons.Button({text : "INSERT" } );
press : insertData
button.placeAt("content");
function insertData()
{
var content = oSimpleForm.getContent();
var oEntry = {};
oEntry.Empno = content[1].getValue();
oEntry.Machineid = content[3].getValue();
oEntry.Reamrks = content[5].getValue();
oEntry.Updationmode = content[7].getValue();
//NOTE 1 : proxy/sap/opu/odata/sap/ZTIME_PUNCH_DATA2_SRV
var oModel = new sap.ui.model.odata.ODataModel(
"http:xxxxxxxxxxx/sap/opu/odata/sap/ZTIME_PUNCH_DATA2_SRV",false,
"xxxx","xxx12");
//NOTE 2 : I also refered service using note 1 which is defined above
sap.ui.getCore().setModel(oModel);
sap.ui.getCore().getModel().create('/PunchSet', oEntry, null,
function(oResponse)
{
sap.ui.commons.MessageBox.alert("Create sucessfully");
},
function()
{
sap.ui.commons.MessageBox.alert("Create Failed");
});
}
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
Thanks,
Nagesh