1
votes

I'm using SAP RMTSAMPLEFLIGHT. It has function imports which require DateTime as input parameter

<FunctionImport Name="CheckFlightAvailability" ReturnType="RMTSAMPLEFLIGHT.FlightAvailability" m:HttpMethod="GET" sap:label="Check availability of flight" sap:action-for="RMTSAMPLEFLIGHT.Flight">
<Parameter Name="airlineid" Type="Edm.String" Mode="In" MaxLength="3"/>
<Parameter Name="connectionid" Type="Edm.String" Mode="In" MaxLength="4"/>
<Parameter Name="flightdate" Type="Edm.DateTime" Mode="In" Precision="0"/>
</FunctionImport>

When I try to call this function using the following URL it doesn't return any results. In Postman, I get BadRequest 400 code.

http://sapes4.sapdevcenter.com/sap/opu/odata/iwfnd/RMTSAMPLEFLIGHT/CheckFlightAvailability?airlineid='AA'&connectionid='0017'&flightdate=datetime'2016-11-23T00:00:00'

This is happening only for FunctionImports with DateTime input. Please suggest what is the right way to pass the datetime input.

1

1 Answers

1
votes

Although the HTTP status is 400, the URL gives back valid response (logged into the demo system with EN language). The returned XML contains more information about the error:

<code>BC_IBF/055</code>
<message xml:lang="en">Flight AA 0017 20161123 does not exist</message>

The error means you have to pass a suitable date. If you run the BAPI BAPI_FLIGHT_CHECKAVAILIBILITY with the same parameters, the same error comes back. This BAPI selects from the SFLIGHTS2 view. Did a where-use for this view and found SAPBC405_ARCS_3 report on demo system, you can list available flights. This was the first row for 'UA' carrid (modified your URL):

http://sapes4.sapdevcenter.com/sap/opu/odata/iwfnd/RMTSAMPLEFLIGHT/CheckFlightAvailability?airlineid='UA'&connectionid='0941'&flightdate=datetime'2016-09-29T00:00:00'

The response is:

<d:CheckFlightAvailability xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:type="RMTSAMPLEFLIGHT.FlightAvailability">
    <d:ECONOMAX>220</d:ECONOMAX>
    <d:ECONOFREE>8</d:ECONOFREE>
    <d:BUSINMAX>22</d:BUSINMAX>
    <d:BUSINFREE>2</d:BUSINFREE>
    <d:FIRSTMAX>10</d:FIRSTMAX>
    <d:FIRSTFREE>0</d:FIRSTFREE>
</d:CheckFlightAvailability>