on 03-12-2018 8:26 PM
Hi i don't know where can i start i have adialog that opens at the beginning to introduce an user and made a query (the odata works propertly i already tested it in sap getaway with something like this /sap/opu/odata/sap/ZERP_ACTIVIDADES_SRV/ReservaSet?$filter=Asesor eq '10000324') that odata was made in the back end and in the front i add that service with the tx /n/IWFND/MAINT_SERVICE.
In my code of my controller (the app is very simple but...):
onInit: function(){
this.oDialog();
},
oDialog : function () {
var oView = this.getView();
var oDialog = oView.byId("userDialog");
// create dialog lazily
if (!oDialog) {
// create dialog via fragment factory
oDialog = sap.ui.xmlfragment(oView.getId(), "Calendario.app.view.Popup_usuario", this);
oView.addDependent(oDialog);
}
oDialog.open(); // Abrimos el dialogo
},
getText: function(){
//Obtenemos el texto
var asesor = this.getView().byId("usuario").getValue();
//Hacemos la peticion al odata
this.makeRequest(asesor).then(function(oData){
var someModel = new sap.ui.model.json.JSONModel();
someModel.setData(oData);
this.getView().setModel(someModel, "");
});
//Close
this.getView().byId('userDialog').close();
},
closeDialog: function(){
this.getView().byId('userDialog').close();
},
makeRequest: function(sAsesor){
return new Promise(function(resolve, reject) {
var oModel = new sap.ui.model.odata.ODataModel({
serviceUrl: "https://client.com:port/sap/opu/odata/sap/ZERP_ACTIVIDADES_SRV",
json: true
});
var sPath = "/ENDPOINT?filter=search eq " + sAsesor;
oModel.read(sPath, null, null, true,
function(oData) {
resolve(oData);
},
function(oError) {
reject(oError);
});
});
}
my view
<Panel id="panel-id">
<FlexBox alignItems="Start"
justifyContent="Center">
<items>
<Table id="tabla"
items="{ path : '/ReservaSet' }"
fixedLayout="true"
popinLayout="Block">
<columns>
<Column width="12em">
<Text text="Sucursal" />
</Column>
<Column width="12em">
<Text text="Nombre de Cliente" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier
text="{Sucursal}"/>
<Text text="{CliNombre}" />
</cells>
</ColumnListItem>
</items>
</Table>
</items>
</FlexBox>
</Panel>
and i'm getting so many erros, im using a chrome extension called CORS to allow control origin
i can see my odata in the browser but i don't know what do i need to check
Thanks to jun.wu5 , deploy the aplication to avoid those errors and i change the request a little:
this is the event that it is open when press ok on the dialog:
getText: function(){
//Obtenemos el texto
var asesor = this.getView().byId("usuario").getValue();
var oTable = this.getView().byId("tabla");
var sURI = "/sap/opu/odata/SAP/ZERP_ACTIVIDADES_SRV";
var oDataModel = new ODataModel(sURI, true);
var oModel = new sap.ui.model.json.JSONModel();
var oFilter = new Filter("Asesor", "EQ", asesor);
oDataModel.read("/ReservaSet", {
filters: [oFilter],
success: function(oData, response) {
var oResults = oData.results;
oModel.setData(oData.results);
oTable.setModel(oModel);
}
});
//Close
this.getView().byId('userDialog').close();
MessageToast.show(asesor);
},
<br>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
var sPath = "/ENDPOINT?filter=search eq " + sAsesor;
why you put ENDPOINT here?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i saw something like that in a code, but i made the request a little diferent and it's working but the time and date i have to reformat in the app
this is the event that it is open when press ok on the dialog:
getText: function(){
//Obtenemos el texto
var asesor = this.getView().byId("usuario").getValue();
var oTable = this.getView().byId("tabla");
var sURI = "/sap/opu/odata/SAP/ZERP_ACTIVIDADES_SRV";
var oDataModel = new ODataModel(sURI, true);
var oModel = new sap.ui.model.json.JSONModel();
var oFilter = new Filter("Asesor", "EQ", asesor);
oDataModel.read("/ReservaSet", {
filters: [oFilter],
success: function(oData, response) {
var oResults = oData.results;
oModel.setData(oData.results);
oTable.setModel(oModel);
}
});
//Close
this.getView().byId('userDialog').close();
MessageToast.show(asesor);
},
<br>
so with this is working but thanks to you i deploy the aplication instead of brake my head looking for the errors 😄
deploy to abap server to run your app
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello, thanks for you reply . i did the deploy and when i send the user get this error:
jquery.sap.global-dbg.js:1035 2018-03-13 09:05:48.937699 The following problem occurred: HTTP request failed404,Not Found,{"error":{"code":"005056A509B11EE1B9A8FEC11C21D78E","message":{"lang":"es","value":"Resource not found for the segment 'ENDPOINT'."},"innererror":{"transactionid":"2B097E0A03924EAAB80D2A1B9EC7A672","timestamp":"20180313120550.0044190","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)"}}}} -
i run the /IWFND/ERROR_LOG so i see this:
The url of the request or metadata definition are incorrect.
maybe is the url that i pass to the odata?
makeRequest: function(sAsesor){
return new Promise(function(resolve, reject) {
var oModel = new sap.ui.model.odata.ODataModel({
serviceUrl: "/sap/opu/odata/sap/ZERP_ACTIVIDADES_SRV",
json: true
});
var sPath = "/ENDPOINT?filter=search eq " + sAsesor;
oModel.read(sPath, null, null, true,
function(oData) {
resolve(oData);
},
function(oError) {
reject(oError);
});
});
}
i want to build something like this /sap/opu/odata/sap/ZERP_ACTIVIDADES_SRV/ReservaSet?$filter=Asesor eq 'user pass in the app example: 10000324' i tried like this to test my odata and it works so i don't know if i made a mistake passing the url
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.