cancel
Showing results for 
Search instead for 
Did you mean: 

problems with add annotations in 'MPC_EXT' class.

0 Kudos

Hi all,


I'm testing the UI5 object 'TREETABLE' with 'SMARTTABLE'. It needs adding annotations from the odata service.

I tried to add annotations using the 'XXXXX_MPC_EXT' object. It seems '/IWBEP/IF_MGW_ODATA_ANNOTATABL~create_annotation' can add annotations. But it doesn't add an annotation to the metadata.

Here is my codes in DEFINE() method:


method DEFINE.

     data:

         lo_annotation     type ref to /iwbep/if_mgw_odata_annotation,                "#EC NEEDED

         lo_entity_type    type ref to /iwbep/if_mgw_odata_entity_typ,                "#EC NEEDED

         lo_complex_type   type ref to /iwbep/if_mgw_odata_cmplx_type,                "#EC NEEDED

         lo_property       type ref to /iwbep/if_mgw_odata_property,                  "#EC NEEDED

         lo_entity_set     type ref to /iwbep/if_mgw_odata_entity_set.                "#EC NEEDED

super->define( ).

***********************************************************************************************************************************

*   ENTITY - Zx108TCifppidx

***********************************************************************************************************************************

lo_entity_type = model->get_entity_type( 'Zx108TCifppidx' ). "#EC NOTEXT

***********************************************************************************************************************************

*Properties

***********************************************************************************************************************************

lo_property = lo_entity_type->get_property( iv_property_name = 'Ifname' ). "#EC NOTEXT

lo_annotation = lo_property->/IWBEP/IF_MGW_ODATA_ANNOTATABL~create_annotation( 'sap' ).

lo_annotation->add( iv_key = 'hierarchy-parent-node-for' iv_value = 'Ns' ).

lo_entity_type->bind_structure( iv_structure_name   = 'ZX108_T_CIFPPIDX'

                                 iv_bind_conversions = 'X' ). "#EC NOTEXT

endmethod.

DEBUG shows the annotation is successfully transformed using Transform 'ID', but it is not show in metadata.

I don't know if it is a right method to add annotations. I hope someone can tell me somethings about it. Thank you.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member183212
Participant
0 Kudos

Hi  gemen

   have you solved this problem, i want to use this SAPUI5 Explored control too, but not sure how to write the code on Gateway side, can't find any code related to ZIVZ_COA_SRV which used in the sample code.

  would you please share your code? or any guide link will be a great help for me.

thanks,

Billy

0 Kudos

Hi billy

    Unfortunately I have not  found the solution, just give up using smarttable. You can try the code above. Theoretically it should be working.

BR

dongqiang

kammaje_cis
Active Contributor
0 Kudos

Adding annotation code looks good to me.

-> Did you clear metadata cache?

-> Why do you need to bind structure again? It should be  present already in super->define() isn't it?

0 Kudos

I cleared the cache using  '/iwfnd/cache_cleanup' and '/iwbep/cache_cleanup', and deleted the bind method.

But the metadata still have no annotation information. Maybe the annotations will be added to another file, not metadata?

kammaje_cis
Active Contributor
0 Kudos

Annotations have to be part of $metadata itself. Not sure what is missing in your case.

0 Kudos

I tried to change a property like this:  

lo_property->set_updatable( abap_true ).

It works. Only annotations are not.