How to get two same entities in ABAP OData according to the id?

349 Views Asked by At

I am developing a fullstack ABAP OData and SAPUI5 application. I have some issues with connect two entities in the request. I have a table called "Flight" and a table called "Airport". In the "Flight" table I have a primary key and two foreign keys. The foreign keys are the "DepartureAirportId" and the "ArrivalAirportId".

I created an oData-Service using the transaction SEGW. I have already created an association in ABAP, with the principal entity of Flight and the child entity for Airport.

When I called this association I've got back all of the airports which are stored in the database, but I've just wanted two of them, the departure and the arrival airports.

How can I recreate my association to get only those two airports which are given by the id?

2

There are 2 best solutions below

0
Piyush aggarwal On

In your Get Entity Set for Airports read key from IT_KEY_TAB. Here you will primary key of flight. Through which you fetch foregn keys fro arrival and departure airports and select airports details using hte airport id's and return them in et_entityset.

0
Mustafa Can DARCAN On

You can create two entity named DepartureAirport and ArrivalAirport, and create an association with the Flight entity. This way, you can obtain a deep structure in the rows containing flight information, with separate information about two different airports.I'm sure there are better ideas, but you can achieve it with this method.