$Batch we use in SAP OData service to send multiple request in single service call using batch call concept, below is the video link and demo [payload code for that.
For complete course on SAP OData service, basic to advance, course is available on udemy and zktutorials.
SAP Odata Service, Rest API, Consume Salesforce API and more on Udemy
SAP OData Service, Rest API Course on ZK Tutorials
Demo Video
Demo Code
method HEADERSET_GET_ENTITY.
data : lv_vbeln type vbeln.
lv_vbeln = it_key_tab[ 1 ]-value.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_vbeln
IMPORTING
OUTPUT = lv_vbeln.
select SINGLE * from zso_header into er_entity WHERE vbeln = lv_vbeln.
endmethod.
method HEADERSET_GET_ENTITYSET.
select * from zso_header into TABLE et_entityset.
endmethod.
method HEADERSET_CREATE_ENTITY.
data : wa_entity like er_entity.
Try.
call METHOD io_data_provider->read_entry_data
IMPORTING
es_data = wa_entity.
insert zso_header from wa_entity.
CATCH cx_root.
ENDTRY.
endmethod.
method HEADERSET_UPDATE_ENTITY.
data : wa_entity like er_entity.
Try.
call METHOD io_data_provider->read_entry_data
IMPORTING
es_data = wa_entity.
modify zso_header from wa_entity.
CATCH cx_root.
ENDTRY.
endmethod.
method HEADERSET_DELETE_ENTITY.
data : lv_vbeln type vbeln.
lv_vbeln = it_key_tab[ 1 ]-value.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_vbeln
IMPORTING
OUTPUT = lv_vbeln.
delete from zso_header WHERE vbeln = lv_vbeln.
endmethod.
method ITEMSET_GET_ENTITY.
data : lv_vbeln type vbeln,
lv_posnr type vbap-posnr.
lv_vbeln = it_key_tab[ 1 ]-value.
lv_posnr = it_key_tab[ 2 ]-value.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_vbeln
IMPORTING
OUTPUT = lv_vbeln.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_posnr
IMPORTING
OUTPUT = lv_posnr.
select SINGLE * from zso_item into er_entity WHERE vbeln = lv_vbeln
and posnr = lv_posnr.
endmethod.
method ITEMSET_GET_ENTITYSET.
select * from zso_item into TABLE et_entityset.
endmethod.
method ITEMSET_CREATE_ENTITY.
data : wa_entity like er_entity.
Try.
call METHOD io_data_provider->read_entry_data
IMPORTING
es_data = wa_entity.
CATCH cx_root.
ENDTRY.
insert zso_item from wa_entity.
endmethod.
method ITEMSET_UPDATE_ENTITY.
data : wa_entity like er_entity.
Try.
call METHOD io_data_provider->read_entry_data
IMPORTING
es_data = wa_entity.
modify zso_item from wa_entity.
CATCH cx_root.
ENDTRY.
endmethod.
method ITEMSET_DELETE_ENTITY.
data : lv_vbeln type vbeln,
lv_posnr type vbap-posnr.
lv_vbeln = it_key_tab[ 1 ]-value.
lv_posnr = it_key_tab[ 2 ]-value.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_vbeln
IMPORTING
OUTPUT = lv_vbeln.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_posnr
IMPORTING
OUTPUT = lv_posnr.
delete from zso_item WHERE vbeln = lv_vbeln
and posnr = lv_posnr.
endmethod.
$Batch Demo Code
Get Call
--salesorders
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET headerSet(Vbeln='1000000001')?$format=json HTTP/1.1
--salesorders
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET itemSet(Vbeln='1000000001',Posnr='10') HTTP/1.1
--salesorders
Content-Type: application/http
Content-Transfer-Encoding: binary
GET itemSet(Vbeln='1000000001',Posnr='20') HTTP/1.1
--salesorders--
Single POST
--batch_2023081101
Content-Type:multipart/mixed; boundary=changeset_1
--changeset_1
Content-Type:application/http
Content-Transfer-Encoding:binary
POST headerSet HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
{
"Vbeln" : "2000000012",
"Erdat" : "/Date(1691712000000)/",
"Auart" : "OR",
"Kunnr" : "17100001",
"Vkorg" : "1200"
}
--changeset_1--
--batch_2023081101--
$Batch Demo Code
Multiple Post Call
--batch_23081402
Content-Type:multipart/mixed; boundary=changeset_01
--changeset_01
Content-Type:application/http
Content-Transfer-Encoding:binary
POST headerSet HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
{
"Vbeln" : "2000000016",
"Erdat" : "\/Date(1691712000000)\/",
"Auart" : "OR",
"Kunnr" : "17100050",
"Vkorg" : "2500"
}
--changeset_01--
--batch_23081402
Content-Type:multipart/mixed; boundary=changeset_02
--changeset_02
Content-Type:application/http
Content-Transfer-Encoding:binary
POST headerSet HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
{
"Vbeln" : "2000000017",
"Erdat" : "\/Date(1691712000000)\/",
"Auart" : "OR",
"Kunnr" : "17100050",
"Vkorg" : "2500"
}
--changeset_02--
--batch_23081402--
Multiple PUT Call
--batch_23081402
Content-Type:multipart/mixed; boundary=changeset_01
--changeset_01
Content-Type:application/http
Content-Transfer-Encoding:binary
PUT headerSet('2000000016') HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
{
"Vbeln" : "2000000016",
"Erdat" : "\/Date(1691712000000)\/",
"Auart" : "OR",
"Kunnr" : "17100060",
"Vkorg" : "5000"
}
--changeset_01--
--batch_23081402
Content-Type:multipart/mixed; boundary=changeset_02
--changeset_02
Content-Type:application/http
Content-Transfer-Encoding:binary
PUT headerSet('2000000017') HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
{
"Vbeln" : "2000000017",
"Erdat" : "\/Date(1691712000000)\/",
"Auart" : "OR",
"Kunnr" : "17100049",
"Vkorg" : "2000"
}
--changeset_02--
--batch_23081402--
$Batch Demo Code
Mixed Methods
--batch_23081402
Content-Type:multipart/mixed; boundary=changeset_01
--changeset_01
Content-Type:application/http
Content-Transfer-Encoding:binary
POST headerSet HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
{
"Vbeln" : "2000000021",
"Erdat" : "\/Date(1691712000000)\/",
"Auart" : "OR",
"Kunnr" : "17100060",
"Vkorg" : "3000"
}
--changeset_01--
--batch_23081402
Content-Type:multipart/mixed; boundary=changeset_02
--changeset_02
Content-Type:application/http
Content-Transfer-Encoding:binary
POST headerSet HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
{
"Vbeln" : "2000000022",
"Erdat" : "\/Date(1691712000000)\/",
"Auart" : "OR",
"Kunnr" : "17100010",
"Vkorg" : "1500"
}
--changeset_02--
--batch_23081402
Content-Type:multipart/mixed; boundary=changeset_03
--changeset_03
Content-Type:application/http
Content-Transfer-Encoding:binary
PUT headerSet('2000000016') HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
{
"Vbeln" : "2000000016",
"Erdat" : "\/Date(1691712000000)\/",
"Auart" : "OR",
"Kunnr" : "17100060",
"Vkorg" : "6000"
}
--changeset_03--
--batch_23081402
Content-Type:multipart/mixed; boundary=changeset_04
--changeset_04
Content-Type:application/http
Content-Transfer-Encoding:binary
PUT headerSet('2000000017') HTTP/1.1
sap-context-accept: header
Content-Type: application/json
Accept: application/json
{
"Vbeln" : "2000000017",
"Erdat" : "\/Date(1691712000000)\/",
"Auart" : "OR",
"Kunnr" : "17100010",
"Vkorg" : "7000"
}
--changeset_04--
--batch_23081402
Content-Type:multipart/mixed; boundary=changeset_05
--changeset_05
Content-Type:application/http
Content-Transfer-Encoding:binary
DELETE headerSet('2000000013') HTTP/1.1
--changeset_05--
--batch_23081402
Content-Type:application/http
Content-Transfer-Encoding:binary
GET headerSet('1000000001') HTTP/1.1
--batch_23081402--
0 Comments