Mal eine ganz wüste Möglichkeit Annotationen in einem oData-Service umzusetzen. Aber mit einem 7.40 Release ohne Fiori-Programmiermodell oder RAP bleibt einem eben nicht ganz so viel übrig. 🙂
Hier geht es darum eine Suchhilfe in einem oData-Service bzw. der darüber liegenden Fiori Elements-Anwendung zu implementieren. (Der nächste Schritt ist dann die Erstellung eines Dropdowns)
Hier die Implementierung der entsprechenden MPC_EXT-Klasse.
METHOD define.
DATA lo_entity_set TYPE REF TO /iwbep/if_mgw_odata_entity_set.
DATA lo_ann_target TYPE REF TO /iwbep/if_mgw_vocan_ann_target.
DATA lo_annotation TYPE REF TO /iwbep/if_mgw_vocan_annotation.
DATA lo_collection TYPE REF TO /iwbep/if_mgw_vocan_collection.
DATA lo_function TYPE REF TO /iwbep/if_mgw_vocan_function.
DATA lo_fun_param TYPE REF TO /iwbep/if_mgw_vocan_fun_param.
DATA lo_property TYPE REF TO /iwbep/if_mgw_vocan_property.
DATA lo_record TYPE REF TO /iwbep/if_mgw_vocan_record.
DATA lo_simp_value TYPE REF TO /iwbep/if_mgw_vocan_simple_val.
DATA lo_url TYPE REF TO /iwbep/if_mgw_vocan_url.
DATA lo_label_elem TYPE REF TO /iwbep/if_mgw_vocan_label_elem.
DATA lo_reference TYPE REF TO /iwbep/if_mgw_vocan_reference.
super->define( ).
lo_reference = vocab_anno_model->create_vocabulary_reference( iv_vocab_id = '/IWBEP/VOC_CORE' iv_vocab_version = '0001' ).
lo_reference->create_include( iv_namespace = 'Org.OData.Core.V1' ).
lo_reference = vocab_anno_model->create_vocabulary_reference( iv_vocab_id = '/IWBEP/VOC_COMMON' iv_vocab_version = '0001' ).
lo_reference->create_include( iv_namespace = 'com.sap.vocabularies.Common.v1' ).
lo_ann_target = vocab_anno_model->create_annotations_target( 'abrechnung/Abr' ).
lo_ann_target->set_namespace_qualifier( 'DZBW_GW_HR_ZW_RUFB_ABRECHNUNG_SRV' ).
lo_annotation = lo_ann_target->create_annotation( iv_term = 'com.sap.vocabularies.Common.v1.ValueList' ).
lo_record = lo_annotation->create_record( ).
lo_property = lo_record->create_property( iv_property_name = 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Art der Abrechnung' ).
lo_property = lo_record->create_property( iv_property_name = 'CollectionPath' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'abrechnungSHSet' ).
lo_property = lo_record->create_property( iv_property_name = 'CollectionRoot' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Z_GW_HR_ZW_RUFB_ABRECHNUNG_SRV' ).
lo_property = lo_record->create_property( iv_property_name = 'SearchSupported' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_boolean( 'X' ).
lo_property = lo_record->create_property( iv_property_name = 'Parameters' ).
lo_collection = lo_property->create_collection( ).
lo_record = lo_collection->create_record( iv_record_type = 'com.sap.vocabularies.Common.v1.ValueListParameterOut' ).
lo_property = lo_record->create_property( iv_property_name = 'LocalDataProperty' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_property_path( 'Abr' ).
lo_property = lo_record->create_property( iv_property_name = 'ValueListProperty' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Domvalue' ).
lo_record = lo_collection->create_record( iv_record_type = 'com.sap.vocabularies.Common.v1.ValueListParameterDisplayOnly' ).
lo_property = lo_record->create_property( iv_property_name = 'ValueListProperty' ).
lo_simp_value = lo_property->create_simple_value( ).
ENDMETHOD.
Und schon erscheint die richtige Suchhilfe wenn auch mit etwas Aufwand.






Sei der Erste der einen Kommentar abgibt