cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
Read only

Update operation of Multiple Items using Deep entity method, code based approach

Former Member
7,924

Hello Everyone,

I am aware that create_deep_entity method is generally used for creating deep entities in OData. However , If we need to perform an update operation on multiple items without using $Batch functionality we need to manually implement a code based approach on  create_deep_entity method using extension _*EXT class. How can this be achieved ?Generally this method gets called when we are performing a deep entity operation and the same cannot be applied while doing an update  request on multiple items. Please advice.

Best Regards,

Lakshman.

View Entire Topic
JyotiD
Active Participant

Hi Laksham,

How about writing an additional piece of code to identify if request is for create or update in Create Deep Entity itself.

As when creating you will not be having key value, and when updating you should be having key value for which you are updaing.

Lets say after reading Payload in structure.


io_data_provider->read_entry_data( IMPORTING es_data = ls_struct ).

if ls_struct-key is initial.  "Create

<Your Create Logic>

elseif ls_struct-key is not initial. "Update

<Your Update Logic>

endif.

Regards,

Tarun

Former Member
0 Likes

Hi Tarun,

Agree it as an alternative , but per coding standards will it always work. There should be some official way to do that. Any Ideas?

And one more question, We are doing an update operation and we're  going to select PUT operation. But create_deep_entity is purely for POST operation. In what way this is going to be trigerred during an PUT operation and we dont have a method like update_deep_entity as well?

Best Regards,

Lakshman.

EkanshCapgemini
Active Contributor
0 Likes

Hi Lakshman,

There is no such thing like 'Deep Update' for OData v2 and thus not supported in SAP Gateway as well. As per the standard, 'Create_Deep_Entity' is for CREATE operation only thus can not be triggered by PUT operation. However you can use it as a workaround. In this case, you have to trigger a POST call for both the operations(Create/Update).

The recommended approach as per the standards is to use $batch 'changeset at once'.

Regards,

Ekansh

JyotiD
Active Participant
0 Likes

Hi Laksham,

Well I don't found Update deep entity method in framework, so had to go with this workaround and It saved me many time without any issues.

As per this you will have to use POST operation only in both case (Create, Update).

Only diff will be in your Payload, while Create you don't have to pass header key(i.e. null values) and when doing Update provide the value against key Property in Payload.

Eg. You are working with SO and SO Item, so when you are creating new sales order you have to pass null values for sales document (vbeln) in your payload, so your logic will do an create operation and new sales order will be created.

and when updating sales order, pass the sales document in payload, identify it in create deep entity method and your update logic will be executed.

Once using POST, create deep entity method is triggered you can identify within code, which operations to be performed.

Ashwin Dutt REkansh Saxena  Even I would like to know, if there is better or official approach for this.

Regards,

Tarun

EkanshCapgemini
Active Contributor
0 Likes

Hi Tarun,

The standard way to achieve this would be using $batch with 'chagneset at once/changeset in differ mode' . You can find more details about this in the below mentioned blog link

However there is some performance gain in using Deep_Insert workaround in contrast to batch.

This topic has already been discusses quite a lot in past. One can check this link (one of many on same topic )

Regards,

Ekansh

Former Member
0 Likes

Yes, This has been widely discussed in the forums.

Thanks everyone for your help.