Professional Documents
Culture Documents
Class 6789101112
Class 6789101112
Note : This is just one of the Approach for Develop OData Service
____________________________________________________________________
_
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet?$filter=Airlin
eid eq 'JL'
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet?$filter=Airlin
eid eq 'DL'
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet?$filter=Airlin
eid eq 'AA'
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet?$filter=Airlin
eid eq 'LH'
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet?$filter=Airlin
eid eq 'SQ'
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet?$filter=Airlin
eid eq 'UA'
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet?$select=Airlin
e,Airlineid,Price
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet?$select=Airlin
e,Airlineid,Cityfrom,Cityto,Price
To Fetch Records with Filter Input and Output with Specific Fields
--------------------------------------------------------------------
------------------------------------
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet?$filter=Airlin
eid eq 'UA'&$select=Airline,Airlineid,Cityfrom,Cityto,Price
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet/$count
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/$metadata
/sap/opu/odata/SAP/Z6AMODATAPROJECTBAPI_SRV/FlightSet?$format=json
____________________________________________________________________
Note :
Class 7
---------------------------------------------------------------------
Developing OData ABAP Service using Get_Entity( ) method
__________________________________________________________
er_Entity :it will Send Output Record to Front-end App (SAP Ui5/Fiori )
Note :
To Deal with Key Field Name and Value within the code
Then we can use Standard STructure = /IWBEP/S_MGW_NAME_VALUE_PAIR
Save
________________________________________________________
Select "Get" option and Execute the Service with Below URL's
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet(Userid='1001',Firstname
='VIJAY')
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet(Userid='1002',Firstname
='VARUN')
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet(Userid='1003',Firstname
='AJAY')
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet(Userid='1001',Firstname
='VIJAY')?$format=json
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/$metadata
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet(Userid='1001',Firstname
='VIJAY')?$select=Userid,Firstname,Emailid,Salary
_______________________________________________________________________
Note :
==============================
___________________________________________________
The Service URL's syntax remains same for SAP Gateway and Rest Client
,But use protocal , IP Address , PortNumber additionally when we test
from RestClient(or) Third party plugins
Class 8
Developing OData ABAP Service using Get_EntitySet( ) Method:
_________________________________________________________________
Requirement 1:
--------------------------------
/ServiceURL/EMPSet
/ServiceURL/EMPSet?$filter=Userid eq '1001'
/ServiceURL/EMPSet?$filter=Country eq 'INDIA'
/ServiceURL/EMPSet?$filter=Salary gt 70000
else.
populate Status = 'Fresher EMP'.
if Country = 'INDIA'
else
populate Currency = 'US Dollar'.
________________________________________________________________
step2 : Make sure that Entity Type and Entity Set is Available
-----------------------------------------------------------------------
step3 : Add New Fields ( Virtual Fields ) inside Entity Type at OData
level
-----------------------------------------------------------------------
-------------------------------------------
if Wa-country = 'INDIA' .
wa-currency = 'Indian Rupee'.
else.
wa-currency = 'US Dollar'.
endif.
Append Wa To Et_EntitySet.
endLoop.
_______________________________________________________
Select "Get" option and Execute the Service with below Service URL's
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet?$filter=Userid eq
'1004'
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet?$filter=Country eq
'INDIA'
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet?$filter=Salary gt 70000
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet?$filter=Country eq 'US'
and Salary gt 80000
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet?$filter=Country eq
'INDIA' and Salary gt 70000
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/$metadata
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet/$count
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet?$filter=Country eq
'US'&$format=json
_______________________________________________________________________
Difference between Get_Entity( ) Method Vs Get_EntitySet( ) Method
-----------------------------------------------------------------------
/ServiceURL/EMPSet('1001')
/ServiceURL/EMPSet(Userid='1001')
/ServiceURL/EMPSet(Userid='1001',Firstname='VIJAY')
_______________________________________________________________________
/ServiceURL/EMPSet
/ServiceURL/EMPSet?$filter=Userid eq '1001'
/ServiceURL/EMPSet?$filter=Country eq 'INDIA'
/ServiceURL/EMPSet?$filter=Salary gt 70000
Ans:- Old metadata will be deleted from Cache memory and New Metadata
will be loaded into Cache Memory so Next Time onwards Odata Service is
executed with Latest metadata only so we can expect proper and
consistent results during Service Execution
_______________________________________________________________________
Note :
Solution
Class 9
Developing OData ABAP Service using Create_Entity( ) method :
__________________________________________________________
( optional )
Step2 : Make sure that Entity Type and Entity Set is Available
commit WORK.
endif.
______________________________________________________________
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet(Userid='1002',Firstname
='VARUN')
_______________________________________________________________________
Class 10
Developing OData ABAP Service using
Update_Entity( ) Method
Delete_Entity( ) Method
_________________________________________________________
Update_Entity( ) Method :
--------------------------------------
( optional )
Delete_Entity( ) Method :
---------------------------------------
step2 : Make sure that Entity Type and Entity Set is available
Entity Type = EMP
Entity Set = EMPSet
commit work.
____________________________________________________________
save and activate
_________________________________________________________
save and activate
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet(Userid='1003',Firstname
='AJAY')
Now Select "Use As Request" option ( To Copy XML Format from HTTP
Response to HTTP Request )
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/EMPSet(Userid='1012',Firstname
='Sachin')
Note :
Get_Entity( ) 200
Get_EntitySet( ) 200
Create_Entity( ) 201
Update_Entity( ) 204
Delete_Entity( ) 204
_____________________________________________________________________
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
Class 11
Developing OData ABAP Service using
Update_Stream( ) Method -> For File Upload Functionality
Get_Stream( ) Method -> For File Download Functionality
& For File Preview Functionality
_______________________________________________________________________
Update_Stream( ) Method :
----------------------------------------
Get_Stream( ) Method :
------------------------------------------
er_Stream = To Send Output File Type and Output File Content To Front-
end App(SAP Ui5/Fiori)
_______________________________________________________________________
To deal with File Type and File Content, we can use Standard Structure
TY_S_MEDIA_RESOURCE
Note : Rawstring Data Type can Store any Type of File Content
( Image Files, Text Files, PDF Files, Audio Files , Video File
, Excel Files etc )
_______________________________________________________________________
WA-userid = wa_key_tab-value.
WA-sydate = Sy-datum.
WA-sytime = Sy-uzeit.
WA-filetype = is_media_resource-mime_type.
WA-filecontent = is_media_resource-value.
Commit Work.
_______________________________________________________________________
save and Activate
_______________________________________________________________________
save and Activate
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/FileSet(Userid='2001')/$value
________________________________________________________________
Add File -> Pick File
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/FileSet(Userid='2002')/$value
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/FileSet(Userid='2003')/$value
/sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/FileSet(Userid='2004')/$value
_______________________________________________________________________
sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/FileSet(Userid='2001')/$value
sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/FileSet(Userid='2002')/$value
sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/FileSet(Userid='2003')/$value
sap/opu/odata/SAP/Z6AMODATAPROJECT2_SRV/FileSet(Userid='2004')/$value
Select "Get" option and Execute The Service
_______________________________________________________________________
Class 12
Today Theory ( Next Session will be Practical )
________________________________________________
Association
Association Set
Referential Constraint
NavigationProperty
Get_Expanded_Entity( ) Method
Create_Deep_Entity( ) Method
_________________________________________________________
Entity Type which Maintains Collection of "Item Data Fields" with Data
Type and length
This Entity Type is Technically Considered as "Dependent Entity Type"
Association :
----------------------------
Association Set:
-----------------------------
Association Set is the Name of the Relationship between Two Entity Sets
i,e
Assocation Set is the Name of the Relationship between Principle Entity
Set and Dependent Entity Set
Referential Constraint:
----------------------------------------
Navigation Property:
-------------------------------------
Navigation Property is an "InterLink" between Header Record and its
Corresponding Item Records at Runtime
Navigation Property is used as "InterLink" in two Situations
1. To Fetch Output Data -> Header Record + its Item Records
Simultaneously
Get_Expanded_Entity( ) Method :
---------------------------------------------------
This Method is used to Fetch Output Data ( Header Record + its Items
Records Simultaneously )
This Method is used to "Send" Output Data ( Header Record + its Items
Records Simultaneously ) to Front-end App(SAP Ui5/Fiori )
Create_Deep_Entity( ) Method:
-------------------------------------------------
This Method is used to Insert Header + item Records Simultaneously
This Method can "Receive" Header + item Records Simultaneously From
Front-end App(SAP Ui5/Fiori )
end of DeepStructure.
_______________________________________________________________
Note :
DeepStructure-FieldName -> Refers to Accomodation of HeaderRecord
DeepStructure-NavigationProperty -> Refers to Accomodation of Item
Record(S)
Note :
Deep Structure Format can be used to Send Output Header + item Records
Simultaneously & to Accept Input Header + item Records Simulataneously