CRUD:- Create Read Update Delete
Read -
/sap/opu/odata/sap/ZEMPLOYEE_002_SRV/EmployeeSet + GET => employeeset_get_entityset.
/sap/opu/odata/sap/ZEMPLOYEE_002_SRV/EmployeeSet(2) + GET => EMPLOYEESET_GET_ENTITY
Create:-
/sap/opu/odata/sap/ZEMPLOYEE_002_SRV/EmployeeSet + POST => employeeset_create_entity
Update
/sap/opu/odata/sap/ZEMPLOYEE_002_SRV/EmployeeSet(6) + PUT => 'EMPLOYEESET_UPDATE_ENTITY'
Delete
/sap/opu/odata/sap/ZEMPLOYEE_002_SRV/EmployeeSet(6) + DELETE => 'EMPLOYEESET_DELETE_ENTITY'
Access data through navigation
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders('4969')/Items
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderItems => salesorderitems_get_entityset
Read with navigation path
/sap/opu/odata/sap/ZSALESORDER_001_SRV/SalesOrderHeaderS + Get
=>salesorderheader_get_entityset
/sap/opu/odata/sap/ZSALESORDER_001_SRV/SalesOrderHeaderS('4970')/OrderToItem_nav + Get
=> salesorderitems_get_entityset
/sap/opu/odata/sap/ZSALESORDER_001_SRV/SalesOrderItemS => salesorderitems_get_entityset
Expand Query option :-
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$expand=Items
salesorderheader_get_entityset => 100
salesorderitems_get_entityset => 7970 ....100 times
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders('4970')?$expand=Items
salesorderheader_get_entity => 4970
salesorderitems_get_entityset => one time
If we have implemented this then we have to implement
/IWFND/TRACES
/IWFND/CACHE_CLEANUP
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$expand=Items&$format=json
They are automatically available in the framework, no further actions needed by development.
$format
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$format=json
$expand
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$expand=Items
$select
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$select=SalesOrder,SalesOrg,Vtweg&$format=json
$count
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders/$count
$links
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders('4970')/$links/Items
$value
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders('4970')/Bstnk/
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders('4970')/Bstnk/$value
They are available, but they require implementation efforts from development.
Without implementation query option :-
$select :-
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$select=SalesOrder,Auart&$format=json
$count :-
/sap/opu/odata/sap/ZSALESORDER_001_SRV/SalesOrderHeaders/$count
$link :-
/sap/opu/odata/sap/ZSALESORDER_001_SRV/SalesOrderHeaders('764')/$links/Items
value :-
/sap/opu/odata/sap/ZSALESORDER_001_SRV/SalesOrderHeaders('764')/Auart?$format=json
$value
/sap/opu/odata/sap/ZSALESORDER_001_SRV/SalesOrderHeaders('764')/Auart/$value
$skiptoken
$batch :-
GET EmployeeSet?
$skip=0&
$top=20&
$select=EmployeeId%2cName%2cCity%2cCompanyName%2cDepartment%2cStratDate%2cEndDate%2cSalary%2cCurrency&
$inlinecount=allpages
http://183.82.1.220:8073/sap/opu/odata/sap/ZEMPLOYEE_002_SRV
****************************************************************************
Content-Type multipart/mixed; boundary=batch
--batch_01
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET SalesOrderHeaders('4970') HTTP/1.1
--batch_01--
********************************************************************************
--batch_01
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET SalesOrderHeaders('4970') HTTP/1.1
--batch_01
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET SalesOrderHeaders('4969') HTTP/1.1
--batch_01--
********************************************************************************
To perform changeset operations, we have two ways:
To redefine respective operations & handle all operations there itself. :- which we have done
Enable defer mode & handle all changeset operations in one place.
--batch_01
Content-Type:multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
PUT EmployeeSet(12) HTTP/1.1
Content-Type: application/json
{
"EmployeeId" : 12,
"Name" : "Ram",
"City" : "New Jaipur 1",
"CompanyName" : "SAP Technomaniac",
"Department" : "SAP Technomaniac",
"StratDate" : "\/Date(1643500800000)\/",
"EndDate" : "\/Date(1706054400000)\/",
"Salary" : "2400000.00",
"Currency" : "INR"}
--changeset--
--batch_01--
******************************************************************************
--batch_01
Content-Type:multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
DELETE EmployeeSet(12) HTTP/1.1
--changeset--
--batch_01--
*****************************************************************************
--batch_01
Content-Type:multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
PUT EmployeeSet(12) HTTP/1.1
Content-Type: application/json
{
"EmployeeId" : 12,
"Name" : "Ram",
"City" : "New Jaipur 2",
"CompanyName" : "SAP Technomaniac",
"Department" : "SAP Technomaniac",
"StratDate" : "\/Date(1643500800000)\/",
"EndDate" : "\/Date(1706054400000)\/",
"Salary" : "2400000.00",
"Currency" : "INR"}
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
DELETE EmployeeSet(12) HTTP/1.1
--changeset--
--batch_01--
*********************************************************
$orderby
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$orderby=SalesOrder desc&$format=json
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$orderby=Kunnr asc,SalesOrder desc&$format=json
$filter
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$filter=Kunnr eq '1390'
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$filter=( Kunnr eq '1390' or Kunnr eq '1175')
/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$filter=( Kunnr eq '1390' or Kunnr eq '1175') and Vtweg eq '10'
List report page
$top
$skip
$inlinecount
$skiptoken
****************************************************
*Skiptoken
*/sap/opu/odata/sap/ZSALESORDER_002_SRV/SalesOrderHeaders?$skiptoken=98
DATA: lv_page_size TYPE i VALUE 50.
DATA: lt_entityset TYPE zcl_zsalesorder_002_mpc=>tt_salesorderheader .
DATA(lv_skiptoken) = io_tech_request_context->get_skiptoken( ).
IF lv_skiptoken IS NOT INITIAL.
*Clear skiptoken value, if internal table is empty
DATA(lv_table_size) = lines( et_entityset )."Count the number of records
IF lv_table_size IS INITIAL.
CLEAR es_response_context-skiptoken.
EXIT.
ENDIF.
*If the table size is less than the predefined page size, send all data
IF lv_table_size < lv_page_size.
*Send all data
ELSE.
DATA(lv_index_start) = lv_skiptoken.
DATA(lv_index_end) = lv_skiptoken + lv_page_size.
ENDIF.
*Show the output
LOOP AT et_entityset INTO DATA(ls_entityset).
IF sy-tabix > lv_index_start AND
sy-tabix <= lv_index_end.
APPEND ls_entityset TO lt_entityset.
ENDIF.
ENDLOOP.
et_entityset = lt_entityset.
* Generate Next Link
es_response_context-skiptoken = lv_index_end + 1.
CONDENSE es_response_context-skiptoken.
ENDIF.
Comments
Post a Comment