on 05-17-2018 7:44 PM
Hello community,
Right now i'm triying to create an entry, well i'm jus testing that my odata is receiving the info, so i create an odata with my entity CrearSet and activate the check of creatable, put some break-points to debugg when my app sapui5 send the info but is not receiving nothing
now, this is my controller/function that fire my event/odata i'm using odata v2
// "sap/ui/model/odata/v2/ODataModel",
...
function(Jquery, Controller, MessageToast, JSONModel, ODataModel, ManagedObject, validRut, ODataModeII) {
...
onCrear : function() {
var mensajeOkCreado = this.byId("mensajeOkCreado");
var mensajeNotCreado = this.byId("mensajeOkCreado");
var sURI = "/sap/opu/odata/sap/ZCRM_UX_PROSPECTO_SRV";
var oModel = new ODataModeII(sURI, true);
var oDatosRespuesta = new JSONModel();
var oInfo = {};
oInfo.rut = this.byId("crearRut").getValue();
oInfo.nombres = this.byId("crearNombres").getValue();
oInfo.apellidos = this.byId("crearApellidos").getValue();
oInfo.calle = this.byId("crearDir1").getValue();
oInfo.numero = this.byId("crearDir2").getValue();
oInfo.depto = this.byId("crearDir3").getValue();
oInfo.comuna = this.byId("crearDir4").getValue();
oInfo.fijo = this.byId("crearTlf1").getValue();
oInfo.movil = this.byId("crearTlf2").getValue();
oInfo.email = this.byId("crearMail").getValue();
oModel.create("/CrearSet", oInfo, {
method: "POST",
success: function(data) {
mensajeOkCreado.setVisible(true);
},
error: function(oError) {
mensajeNotCreado.setVisible(true);
}
});
}
So i got this error:
The following problem occurred:
HTTP request failed400,Bad Request,
{"error":
{"code":"/IWCOR/CX_DS_EP_PROPERTY_ERROR/00505692409C1ED6B8FE112855048EDA",
"message":{"lang":"es","value":"Property 'rut' is invalid"},
"innererror":{
"application":{"component_id":"","service_namespace":"/SAP/","service_id":"ZCRM_UX_PROSPECTO_SRV","service_version":"0001"},
"transactionid":"8242004F04A044C1BE83804994D9432D","timestamp":"20180517183905.6633110",
"Error_Resolution":{"SAP_Transaction":"For backend administrators: run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details","SAP_Note":"See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"},"errordetails":[]}}} -
this is how i configured my odata:
i follow this tutorial : http://www.techippo.com/2016/05/create-data-in-sap-backend-using-odata.html
http://www.techippo.com/2016/09/odata-create-operation-from-sapui5-application.html
Error message says property 'rut' is is invalid
check if property with name 'rut' exists in metadata also check the length/data type of the property.
If data type is Edm.String and length = 4, and you are passing value of length '5' then create operation will result in error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks !! ! Srikanth KV i'll take a look , ok but this is my first time creating an entity so i din't know if i had some mistakes
no need to create oDataModel(below lines) if the model is declared in manifest.json
var sURI = "/sap/opu/odata/sap/ZCRM_UX_PROSPECTO_SRV";
var oModel = new ODataModeII(sURI, true);
lets say, if the model is declared with name 'myModel' in manifest.json then the same can be accessed by
var oModel = this.getOwnerComponent().getModel("myModel");
oModel.create("/CrearSet", oInfo, {
success: function(){},
error: function(){}
});
how can i recreate a uri to test from my getaway the post request ? i tried /sap/opu/odata/sap/ZCRM_UX_PROSPECTO_SRV/CrearSet('CL') and/sap/opu/odata/sap/ZCRM_UX_PROSPECTO_SRV/CrearSet(Rut='CL') but i got error 404
<code>005056A509B11ED199D8826D151FC0FE</code>
<message xml:lang="es">The specified HTTP method is not allowed for the resource identified by the Data Service Request URI</message>
<br>
<br>
i put some breaks on my method CREARSET_CREATE_ENTITY just to see if it stops there be cause i don't have any logic yet ,just some variables and a if sy-subrc eq 0 where the break it's
use the transaction code /IWFND/GW_CLIENT in gateway system to test the create operation.
Once everything is fine then try the create operation from UI5 code.
Some useful links:
http://www.sapyard.com/odata-and-sap-netweaver-gateway-part-v-crud-operations-in-odata-services/
https://blogs.sap.com/2014/03/06/let-s-code-crudq-and-function-import-operations-in-odata-service/
I implemented my method crear_get_entity to test from my GW_CLIENT and afthe that use it as request so when i exceute the post with /sap/opu/odata/sap/ZCRM_UX_PROSPECTO_SRV/CrearSet i get status code 201 "Ok" and follow Jesus Javier Contreras Colmenares i checked my properties and correct them the firt letter upper case and i got this error:
jquery.sap.global-dbg.js:1035 2018-05-18 09:48:41.943399 The following problem occurred: HTTP request failed400,Bad Request,{"error":{"code":"CX_SXML_PARSE_ERROR/001560AA0E081DEB8CA398CC1690D406","message":{"lang":"es","value":"Failed to read property 'Telefono' at offset '154'"},"innererror":{"application":{"component_id":"","service_namespace":"/SAP/","service_id":"ZCRM_UX_PROSPECTO_SRV","service_version":"0001"},"transactionid":"80AFC585C7D4400796E069814C2E0AE9","timestamp":"20180518134841.5342260","Error_Resolution":{"SAP_Transaction":"For backend administrators: run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details","SAP_Note":"See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"},"errordetails":[]}}} -
could be the order of my oInfo (my data) ??
this is my info that i'm pretending to send
and this is my request that i send trought GW_CLIENT where i receive Ok
Hi Naoto Amari,
Pass your objects to backend Case sensitive as it is showing in your metadata.
Sent your objects following format. then i ll will work.
You have to follow entityset Property Name Tab.
oInfo.Rut = this.byId("crearRut").getValue();
oInfo.Nombres = this.byId("crearNombres").getValue();
oInfo.Apellidos = this.byId("crearApellidos").getValue();
oInfo.Calle = this.byId("crearDir1").getValue();
oInfo.Numero = this.byId("crearDir2").getValue();
oInfo.Depto = this.byId("crearDir3").getValue();
oInfo.Comuna = this.byId("crearDir4").getValue();
oInfo.Fijo = this.byId("crearTlf1").getValue();
oInfo.Movil = this.byId("crearTlf2").getValue();
oInfo.Email = this.byId("crearMail").getValue();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try change oInfo.rut TO oInfo.Rut
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.