Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Gateway and oData POST and GET methods

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: Simple Exercise on OData and SAP UI5 Application for the basic CRUD Operation 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

Tags:
Former Member replied

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); }

);

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question