You are on page 1of 63

CRUDQ OPERATIONS IN ODATA SERVICE

• Create operation
• Read Operation
• Update Operation
• Delete Operation
• Query Operation

1

ASSOCIATION/NAVIGATION PROPERTIES
• Associations define the relationship between two
or more Entity Types (for example, Employee
WorksFor Department). Instances of
associations are grouped in Association Sets.
• Navigation Properties are special properties on
Entity Types which are bound to a specific
association and can be used to refer to
associations of an entity.

2

ODATA QUERY OPTIONS
• Don’t need any custom • Needs custom
implementation: implementation:
– $select – $order by
– $count – $top
– $expand – $skip
– $format – $filter
– $links – $inlinecount
– $value – $skiptoken

3

CREATE OPERATION • CREATE_ENTITY method 4 .

CREATE OPERATION 5 .

CREATE OPERATION 6 .

CREATE OPERATION 7 .

READ OPERATION • GET_ENTITY method 8 .

READ OPERATION 9 .

UPDATE OPERATION • UPDATE_ENTITY method 10 .

UPDATE OPERATION 11 .

UPDATE OPERATION 12 .

UPDATE OPERATION 13 .

DELETE OPERATION • DELETE_ENTITY method 14 .

DELETE OPERATION 15 .

DELETE OPERATION 16 .

QUERY OPERATION • GET_ENTITYSET method 17 .

QUERY OPERATION 18 .

CREATING ASSOCIATION 19 .

CREATING ASSOCIATION 20 .

CREATING ASSOCIATION 21 .

CREATING ASSOCIATION 22 .

• <path>/SalesOrderSet(‘<S O_ID>’) 23 .SALESORDERSET_GET_ENTITY • First we will implement logic in method SALESORDERSET_GET_ ENTITY by redefining it. • We will use below execution URI in Gateway Client (Transaction /IWFND/GW_CLIENT) to check the response payload.

SALESORDERSET_GET_ENTITY 24 .

• <path>/SalesOrderSet 25 . • We will use below execution URI in Gateway Client (Transaction /IWFND/GW_CLIENT) to check the response payload.SALESORDERSET_GET_ENTITYSET • We will implement logic in method SALESORDERSET_GET_ ENTITYSET by redefining it.

SALESORDERSET_GET_ENTITYSET 26 .

27 .SALESORDERITEMSE_GET_ENTITY • LS_NAVIGATION_PATH type /IWBEP/S_MGW_NAVIGATION_PATH .

SALESORDERITEMSE_GET_ENTITY 28 .

USING NAVIGATION KEY ‘OrderToItems’ 29 .

USING NAVIGATION KEY ‘OrderToItems’ • NA-KEY ‘OrderToItems’ with SoID & SoItemPos 30 .

SALESORDERITEMSE_GET_ENTITYSET 31 .

USING NAVIGATION KEY ‘OrderToItems’ • NA-KEY ‘OrderToItems’ 32 .

PRODUCTSET_GET_ENTITYSET • Using filter option for ‘PRODUCT_ID’ & ‘CATEGORY’ 33 .

PRODUCTSET_GET_ENTITYSET 34 .

PRODUCTSET_GET_ENTITY 35 .

PRODUCTSET_GET_ENTITY 36 .

• Call function 'BAPI_EPM_SO_GET_DETAIL‘ to get key ‘PRODUCT_ID’.  So we’ll get the detail product.USING NAVIGATION KEY ‘ItemToProduct’ • Using NA-KEY ‘OrderToItems’ to get keys SoId & SoItemPos. • Using ‘PRODUCT_ID’ to call function ‘BAPI_EPM_PRODUCT_GET_DETAIL’. 37 .

USING NAVIGATION KEY ‘ItemToProduct’ 38 .

USING NAVIGATION KEY ‘ItemToProduct’ 39 .

BuyerName 40 .ODATA QUERY OPTIONS • $select /sap/opu/odata/SAP/ZGW_SALESORDER_SRV/SalesOrderSet? $select=SoId.

ODATA QUERY OPTIONS • $count /sap/opu/odata/SAP/ZGW_STUDENT_SRV/STUDENTSet /$count 41 .

ODATA QUERY OPTIONS • $expand • /sap/opu/odata/SAP/ZGW_SALESORDER_SRV/SalesOrderSet ('500000000')?$expand=OrderToItems&$format=json 42 .

ODATA QUERY OPTIONS • $format 43 .

ODATA QUERY OPTIONS • $links • /sap/opu/odata/SAP/ZGW_SALESORDER_SRV/Sales OrderSet('500000000')/$links/OrderToItems 44 .

ODATA QUERY OPTIONS • $value • /sap/opu/odata/SAP/ZGW_SALESORDER_SRV/SalesOrderS et('500000000')/Note/$value 45 .

46 .ODATA QUERY OPTIONS • $order by • data LS_ORDER type /IWBEP/S_MGW_SORTING_ORDER.

ODATA QUERY OPTIONS • $order by • /sap/opu/odata/SAP/ZGW_SALESORDER_SRV/ProductSet?$ord erby=Price asc&$select=Price&$format=json 47 .

ODATA QUERY OPTIONS

• $top & $skip

• $top=n query option will retrieve the top n
records from the OData service feed/collection.

• $skip=x & $top=n will retrieve top n records by
skipping the first x recordsfrom the OData service
feed/collection.

48

ODATA QUERY OPTIONS
• $top & $skip
• data:
LV_TOP type I,
LV_SKIP type I,
LV_TABLE_SIZE type I.
LV_TOP = IO_TECH_REQUEST_CONTEXT->GET_TOP( ).
LV_SKIP = IO_TECH_REQUEST_CONTEXT->GET_SKIP( ).

49

ODATA QUERY OPTIONS
• $top & $skip

50

ODATA QUERY OPTIONS • $top & $skip • /sap/opu/odata/SAP/ZGW_SALESORDER_SRV/ProductSet?$top =2&$skip=2&$format=json 51 .

ODATA QUERY OPTIONS • $filter DATA: LT_FILTERS type /IWBEP/T_MGW_SELECT_OPTION. LT_FILTERS = IO_TECH_REQUEST_CONTEXT- >GET_FILTER( )->GET_FILTER_SELECT_OPTIONS( ). 52 . LS_SO type /IWBEP/S_COD_SELECT_OPTION. LS_FILTER type /IWBEP/S_MGW_SELECT_OPTION.

ODATA QUERY OPTIONS • $filter 53 .

ODATA QUERY OPTIONS • $filter 54 .

ODATA QUERY OPTIONS • $filter • /sap/opu/odata/SAP/ZGW_SALESORDER_SRV/ProductSet?$filter =Price le 7.0000&$select=Price&$format=json 55 .

ODATA QUERY OPTIONS • $inlinecount • Query option $inlinecount is used to get the overall count of feed/collection together with the entity set collection data. 56 .

ODATA QUERY OPTIONS • $inlinecount • /sap/opu/odata/SAP/ZGW_SALESORDER_SRV/ProductSet?$inli necount=allpages&$format=json 57 .

58 .A next link is provided back to the application to get the next bulk of data. This also helps in boost-up the performance if huge number of entries requested.ODATA QUERY OPTIONS • $skiptoken • Query option $skiptoken is used to limit the amount of entries sent to the application.

• If entries in the entity set are more than the page size. 59 .e GET_ENTITYSET method in the DPC_EXT class. • Send the requested set of entries to the application based on skiptoken value and also the next link to next set of entries.ODATA QUERY OPTIONS • $skiptoken • You have to define the page size in the server i.divide the entries by page size.

ODATA QUERY OPTIONS • $skiptoken 60 .

ODATA QUERY OPTIONS • $skiptoken DATA: lv_page_size type i value 2. lv_skiptoken type STRING. lv_index_end type i. "define the page size. lv_skiptoken = IO_TECH_REQUEST_CONTEXT-> GET_SKIPTOKEN( ). lv_index_start type i. 61 .

ODATA QUERY OPTIONS • $skiptoken 62 .

ODATA QUERY OPTIONS • $skiptoken 63 .