Skip to Content
0
Jun 23, 2020 at 05:12 AM

How to map for deep insert request for odata in java?

38750 Views

Hi experts,

I created sap custom odata gateway service with association for deep insert.

The following is the json data format to post odata request.

{
  "DummyKey":"XXX",
  "TBL_BSEG": [
    {
      "Belnr": "XXXXXXXXXX",
      "Bukrs": "XXXX",
      .....
    },
    {
      "Belnr": "XXXXXXXXXX",
      "Bukrs": "XXXX",
      .....
    }
  ]
}

And also, I generated VDM from metadata of sap custom odata service using command line interface of the generator.

Git Hub - here is the my VDM source code. ( DummyHeaderSet is for header data and BSEGSet is for child table)

I am stuck in the mapping of data for body of ODataCreateRequestBuilder.

Normally, for a single entity set, it will work the following like that.

Map<String, Object> body = new HashMap<>();
body.put("Dummykey", "XXX");

ODataCreateRequest createRequest =
    ODataCreateRequestBuilder
        .withEntity("/sap/opu/odata/sap/Y_ODATA_SZ_06_SRV", "DummyHeaderSet")
        .withBodyAsMap(body)
        .build();

createRequest.execute("DestinationName");  

But, I do not know how to map for a child node table data.

I searched the related blogs for ODataCreateRequestBuilder body mapping, but I don't quite understand at all.

Is there related sample for above requirements?

Or should I map with related VDM?

I will be grateful for any help you can provide.

Best Regards,