METHOD define_test. DATA: lo_annotation TYPE REF TO /iwbep/if_mgw_odata_annotation, lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ, lo_complex_type TYPE REF TO /iwbep/if_mgw_odata_cmplx_type, lo_property TYPE REF TO /iwbep/if_mgw_odata_property, lo_entity_set TYPE REF TO /iwbep/if_mgw_odata_entity_set. DATA: lt_output TYPE STANDARD TABLE OF ztable_fields_op, ls_output TYPE ztable_fields_op. ********************************************************************** * ENTITY - TEST ********************************************************************** lo_entity_type = model->create_entity_type( iv_entity_type_name = 'TEST' iv_def_entity_set = abap_false ). "#EC NOTEXT ********************************************************************** *Properties ********************************************************************** SELECT * FROM ztable_fields_op INTO TABLE lt_output. IF sy-subrc = 0. LOOP AT lt_output INTO ls_output. lo_property = lo_entity_type->create_property( iv_property_name = ls_output- field_label ). lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_nullable( abap_false ). TRY. DATA: lv_element TYPE string. lv_element = ls_output-data_element. CALL METHOD lo_property->bind_data_element EXPORTING iv_element_name = lv_element. CATCH /iwbep/cx_mgw_med_exception . ENDTRY. ENDLOOP. ENDIF. ********************************************************************** * ENTITY SETS ********************************************************************** lo_entity_set = lo_entity_type->create_entity_set( 'TESTSet' ). "#EC NOTEXT lo_entity_set->set_has_ftxt_search( abap_false ). lo_entity_set->set_subscribable( abap_false ). lo_entity_set->set_filter_required( abap_false ). ENDMETHOD. |
METHOD /iwbep/if_mgw_appl_srv_runtime~get_entityset. DATA: lt_output TYPE STANDARD TABLE OF ztable_fields_op, ls_output TYPE ztable_fields_op. DATA: lt_cat TYPE TABLE OF lvc_s_fcat, ls_cat LIKE LINE OF lt_cat, d_ref TYPE REF TO data. FIELD-SYMBOLS : <f_fs> TYPE table. IF iv_entity_name = 'TEST'. SELECT * FROM ztable_fields_op INTO TABLE lt_output. IF sy-subrc = 0. LOOP AT lt_output INTO ls_output. ls_cat-tabname = ls_output-table_name. ls_cat-fieldname = ls_output-field_label. ls_cat-ref_field = ls_output-field_label. ls_cat-ref_table = ls_output-table_name. APPEND ls_cat TO lt_cat. ENDLOOP. ENDIF. ""create a dynamic internal table CALL METHOD cl_alv_table_create=>create_dynamic_table EXPORTING it_fieldcatalog = lt_cat IMPORTING ep_table = d_ref. ASSIGN d_ref->* TO <f_fs>. **--Fetch records dynamically SELECT * FROM (ls_output-table_name) INTO CORRESPONDING FIELDS OF TABLE <f_fs>. ** Call methos copy_data_to_ref and export entity set data copy_data_to_ref( EXPORTING is_data = <f_fs> CHANGING cr_data = er_entityset ). ENDIF. ENDMETHOD. |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
9 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |