Developing OData ABAP Service using BAPI with Mapping Technique :
================================================
=============
BAPI with Mapping Technique is used in OData Service, if BAPI already Contains
the Required Database Functionality
_________________________________________________________________________
Step By Step Procedure :
-------------------------------------------
step1 : in SE37 Tcode, we can Analyze BAPI ( for ex : BAPI_FLIGHT_GETLIST )
i,e
Recognize the Input Parameters of BAPI ( Airline / Airlineid )
Recognize the Output Parameters of BAPI ( Flight_List )
Note : Select Query is Already Implemented in
BAPI_FLIGHT_GETLIST
step2 : in SEGW Tcode, open OData Service Project =
ZTEST630AMODATAPROJECT
step3 : Create Entity Type and Entity Set in DataModel Folder
i,e
Right Click DataModel -> Import -> DDIC Structure
Entity Type = Flight
ABAP Structure = BAPISFLDAT
Check Box To Create Entity Set = FlightSet
Next
Select The Fields
Next
Select Key Field ( For Ex : Airlineid )
Finish
step4 : Define Mapping between OData Service and BAPI
( BAPI_FLIGHT_GETLIST )
i,e
Expand Service Implementation Folder
Expand EntitySets ( FlightSet )
Right Click on GetEntitySet ( Query ) option
Select "Map to DataSource"
Select DataSource Type = Remote Function Call
Select DataSource Name = BAPI_FLIGHT_GETLIST
continue
Note : it opens Mapping Screen
Define Input Mapping :
_______________________
Left Side Click on ( + ) icon , Select Airlineid OData Field for Input
save
Drag Drop Airline from BAPI to Airlineid of OData
Define Output Mapping:
_______________________
Drag Drop Each Field from BAPI ( Flight_List ) to Each Field of OData
Service
save
step5 : Re-Generate Runtime Artifacts
i,e
Select Project Folder -> Click on Red color icon
Continue
Note : Latest Metadata will be Updated in MPC Class
and Code is Autogenerated in OData Service DPC Class to Access
BAPI
step6 : Test the OData Service
_______________________________
open Service Maintainence Folder
open Gateway Client
Metadata -> Cleanup Cache -> From Both Systems -> Continue
Select EntitySets ( FlightSet )
To Fetch All Records
_________________________
/sap/opu/odata/SAP/ZTEST630AMODATAPROJECT_SRV/FlightSet
To Fetch Records based on Filter Input
______________________________________
/sap/opu/odata/SAP/ZTEST630AMODATAPROJECT_SRV/FlightSet?$filter=Airlineid
eq 'DL'
/sap/opu/odata/SAP/ZTEST630AMODATAPROJECT_SRV/FlightSet?$filter=Airlineid
eq 'SQ'
/sap/opu/odata/SAP/ZTEST630AMODATAPROJECT_SRV/FlightSet?$filter=Airlineid
eq 'UA'
/sap/opu/odata/SAP/ZTEST630AMODATAPROJECT_SRV/FlightSet?$filter=Airlineid
eq 'AA'
/sap/opu/odata/SAP/ZTEST630AMODATAPROJECT_SRV/FlightSet?$filter=Airlineid
eq 'LH'
__________________________________________________________________________________
________
To Fetch Records based on Filter input & Output in json Format
_______________________________________________________
/sap/opu/odata/SAP/ZTEST630AMODATAPROJECT_SRV/FlightSet?$filter=Airlineid
eq 'DL'&$format=json
__________________________________________________________________________________
________
To Fetch Record Count :
_______________________
/sap/opu/odata/SAP/ZTEST630AMODATAPROJECT_SRV/FlightSet/$count
_________________________________________________________________________________
To Fetch Metadata of OData Service:
__________________________________
/sap/opu/odata/SAP/ZTEST630AMODATAPROJECT_SRV/$metadata
________________________________________________________________________________