cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 -> Gateway Service Function Import

Former Member

Hi, I'm trying to learn how to interact with the Function Imports of a gateway service. I can't find any documentation about it. Does anyone have an example I can look at?

I've been playing around with CheckFlightAvailability on RMTSAMPLEFLIGHT.

If you have code on how to trigger it and retrieve the data, that would be great!

Accepted Solutions (1)

Accepted Solutions (1)

former_member293602
Active Participant
0 Kudos

Hi Ryan,

here a simple example to trigger the action "GetAvailableFlights". In my example, this action has the HttpMethod GET attached. Therefore you have the possibility to test this simply in your browser by appending the following string to the service URL:

GetAvailableFlights?fromdate=datetime'2012-03-01T00:00'&todate=datetime'2012-04-01T00:00'&cityfrom='NEW%20YORK'&cityto='SAN%20FRANCISCO'

Alternatively you can use the read method of the model like this:

searchFlights: function(oEvent){

sap.ui.getCore().getModel().read(

   "GetAvailableFlights",

   null,

   [

    "fromdate=datetime'"+oAvailableFlightsController.formatDateUrl(sap.ui.getCore().byId("inpFromDate").getYyyymmdd())+"T00:00'",

    "todate=datetime'"+oAvailableFlightsController.formatDateUrl(sap.ui.getCore().byId("inpToDate").getYyyymmdd())+"T00:00'",

    "cityfrom='"+sap.ui.getCore().byId("inpCityFrom").getValue()+"'",

    "cityto='"+sap.ui.getCore().byId("inpCityTo").getValue()+"'"

    ],

   true,

   function(oData, oResponse){

    console.log("Success!");

    console.log(oResponse);

    console.log(oData);

   },

   function(oError){

    console.log("Error!");

    console.log(oError);

   }

);

},

And for the CheckFlightAvailability, the URL could look like:

CheckFlightAvailability?airlineid='AA'&connectionid='0017'&flightdate=datetime'2012-02-22T00:00'

Regards, Frank

sathish_kumar82
Explorer
0 Kudos

Can I return a deep entity using Function Import?

Answers (1)

Answers (1)

0 Kudos

Hello.

You can use jQuery.ajax to perform a HTTP GET or POST.

The only problem is that to call a Function Import in this way you must set a XCSFR token inside the HTTP header.

Regards.