cancel
Showing results for 
Search instead for 
Did you mean: 

is it possible to add eTag only by adding annotation in CDS

walter52abc
Product and Topic Expert
Product and Topic Expert
0 Kudos

here is the question:

A CDS view is referenced in SEGW, and i would like to add a eTag for this entitytype, the whole program logic is maintained by BOPF. i think what is the easiest way to achieve this is by adding annotation in CDS View. And of course i have tried in that way, however, the field still not shown in the eTag field in SEGW.

the link below is i refered to:

https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/201809.000/en-US/7dcd82b0dcf242618dfabb...

is this the right way to solve this or there is another better way to do so?

Accepted Solutions (0)

Answers (3)

Answers (3)

maheshpalavalli
Active Contributor

Hi Walter Wu,

You need to use the entityChangeStateId annotation to enable the Etag. You can check the below blog for more information on locking in new ABAP(>7.52)

https://blogs.sap.com/2019/01/09/abap-programming-model-for-sap-fioridraft-durable-locks-cds-view-ob...

Thanks,

Mahesh

sumita_nagpal
Explorer
0 Kudos

Were you able to check if CDS annotations alone support eTag?

How did you solve your problem?

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

You should not check in the SEGW project because the Change might not be reflected in the project but you would have to test the entity set itself whether it responds with an ETag.

If the annotation does not work (because you are working on an older release) you can try to set the annotation via redefining the DEFINE method in MPC_EXT.

 method define.

    data lo_entity_type type ref to /iwbep/if_mgw_odata_entity_typ.
    data lo_property    type ref to /iwbep/if_mgw_odata_property.

    super->define( ).

    lo_entity_type = model->get_entity_type( iv_entity_name = 'Zsepm_C_Salesorder_TplType' ).
    lo_property = lo_entity_type->get_property( iv_property_name = 'LastChangedDateTime' ).
    lo_property->set_as_etag( ).

endmethod.

walter52abc
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Andre,

Firstly, really thanks for your instant response. For my project, it is prefer to use an annotation in CDS View to achieve the eTag function. The way that i used to check whether the annotation is worked as follow steps:

step1: Send get request in GW_CLIENT

step2: check the response header

step3: if there is field called eTag returned.

i hope the test method above is correct.

The version of ADT that i am using is 2.98.0 and for SEGW system is 752. Any suggestions?

What is more, i would like to know what is the exactly correct release version to use this annotation.

Thanks in advance.

Best Regards,

Walter