This blogpost will explain details of Odata implimentation ’$Batch Processing’ step by step.
@AbapCatalog.sqlViewName: 'ZUICDS001'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: '$Batch Processing Example'
define view zui_cds_001
as select from zui_t001
{
key column0 as Column0,
column1 as Column1,
column2 as Column2
}
The ODATA CDS View Entity
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'ODATA $Batch'
@ObjectModel.createEnabled: true
@ObjectModel.deleteEnabled: true
@ObjectModel.updateEnabled: true
@OData.publish: true
@OData.entitySet.name: 'Odata_Test'
define view entity zui_odata_001
as select from zui_cds_001
{
key Column0,
Column1,
Column2
}
DATA : ls_change_request TYPE /iwbep/if_mgw_appl_types=>ty_s_changeset_request.
DATA : ls_change_response TYPE /iwbep/if_mgw_appl_types=>ty_s_changeset_response.
DATA: ls_entity TYPE zui_t001.
DATA: lt_entity TYPE TABLE OF zui_t001.
LOOP AT it_changeset_request INTO ls_change_request WHERE operation_type EQ 'CE' ."To Create Operation
ls_change_request-entry_provider->read_entry_data(
IMPORTING
es_data = ls_entity ).
APPEND ls_entity TO lt_entity.
CLEAR : ls_entity.
ENDLOOP.
IF lt_entity IS NOT INITIAL.
INSERT zui_t001 FROM TABLE lt_entity.
COMMIT WORK AND WAIT.
ENDIF.
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
GET zui_odata_001(Column0='1000') HTTP/1.1
--batch--
//If you want to display json format you can also use;
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
GET zui_odata_001(Column0='1000') HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
--batch--
--batch
Content-Type: multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST zui_odata_001 HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
{
"Column0" : "1111",
"Column1" : "9999888877",
"Column2" : "9999888877"
}
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST zui_odata_001 HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
{
"Column0" : "2222",
"Column1" : "9999888877",
"Column2" : "9999888877"
}
--changeset--
--batch--
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |