on 11-02-2015 5:27 PM
Hi,
I need a little help for the gateway service in SAP and the oData binding in eclipse.
The request is as follows: Pass parameters on input to the RFC -> get the output table -> bind the data with the table in the view.
I only have 1 function module with 2 tables (in the FM). I use the first table for input and based on that data i make a select in a standard table and extract those records in the 2nd table which I use for output in the FM. I need to display that output table in the view.
I have created 2 entity sets: 1 for the input table and 1 for the output table. The mapping is done only on GetEntitySet for both sets(i don't think i need to map other service implementations, but please correct me if i'm wrong).
I call the service and I'm able to display records in the table if I play in debug in the FM:
This is my table in the view:
Now, I'm not sure how to make the connection with the gateway in order to pass a parameter->extract some records to the output table->get the output table from the FM->bind it with the table from the view.
I found this code here: and it's closest to my scenario.
var Input = {};
Input.Qmnum = sap.ui.getCore().byId("qmnumtxt").getValue();
OData.request({
requestUri: "proxy/http/<server>:<port>/sap/opu/odata/sap/ZCS_NT_LIST_SRV_TEST_SRV/TbInputSet",
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: "proxy/http/<server>:<port>/sap/opu/odata/sap/ZCS_NT_LIST_SRV_TEST_SRV/TbInputSet",
headers: oHeaders,
data:Input
},
function(data,request) {
location.reload(true);
}, function(err) {
alert("Error");
});
}, function(err) {
var request = err.request;
var response = err.response;
alert("Error in Get -- Request " + request + " Response " + response);
});
But there are 2 wrong points here:
1. It doesn't pass anything to the service(although the Input is valorized)
2.It makes a reload to the page and in my case it goes in the init method again and takes the empty output table from the service.
I'll really appreciate any help whatsoever!
Thanks
Hi
if you use get_entity - return structure(one line), then binding as:
oTable.bindItems("/",template)
in your case properly use get_entity_set, as you appear in the table a lot of records rather than one.
oTable.bindItems("/results",template)
Example requests
Get_Entity_Set - return many row
uUrl:port/sap/opu/odata/sap/U_SRV/NameEntitySet?$filter=Objid eq '123' and Otype eq 'E'
after parameter $filter you can see in abap IT_FILTER_TAB
Get_Entity - always return one row
uUrl:port/sap/opu/odata/sap/U_SRV/NameEntitySet(Objid='50000299',Otype='E')
Objid and Otype this fields at stricture in SEQW, this field must be KEY.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
var sPath_cust = "/Customer_DetailsSet(Kunnr='" + custID + "')";
this.oModel.read(sPath_cust,null, null, false, function(oData,
response) {
var jsonModel = new sap.ui.model.json.JSONModel(oData);
customerForm.setModel(jsonModel);
},
function(oError) {alert(oError); }
);
Nikhil j No
Try this
Kunnr - must be KEY in segw struc/
OR
var sPath_cust = "/Customer_DetailsSet$filter=Kunnr eq '" + custID + "';
Now it gives me 400 (Bad Request) .
Another thing I noticed If I pass it like this: "/oEntitySet?" then I can enter in debug in the FM and doesn't give an error (but like that I'm not sending any input to the server, I only get the output), but if i pass it as you suggest gives back the error and doesn't go in debug (also with the ? ).
please show full url request with filter params(at chrome console).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
2Hello Sashko,
As you said, there are two table parameter one for input and another for output. But in onInit method I am not able to find any input parameter for service call.
One more thing you can pass HandleError function in Odata.read method and alert response code.
Please find sample code.
var sPath_cust = "/Customer_DetailsSet(Kunnr='" + custID + "')";
this.oModel.read(sPath_cust,null, null, false, function(oData,
response) {
var jsonModel = new sap.ui.model.json.JSONModel(oData);
customerForm.setModel(jsonModel);
},
function(oError) {alert(oError); }
);
You can debug javascript code in chrome. refer below URL/
https://sapui5.hana.ondemand.com/sdk/#docs/guide/1e52fde5444649748809a78fd8a645da.html
Thanks,
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It says that the url doesn't exist only when i pass it like Nikhil suggested ("/Customer_DetailsSet(Kunnr='" + custID + "')";), if I pass it like i did, the url exists. Also i have created and activated a webservice for the gateway project:
if you read by key, then you must transfer all keys at structure entity at segw
("/Customer_DetailsSet(key1='" + custID + "')",key2='123')
if you read by filter params you must transfer an arbitrary number of parameters.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.