How is the GENERATED_ID created in a custom oData Service to feed an Analytical Table?

时光总嘲笑我的痴心妄想 提交于 2020-01-14 06:12:16

问题


In a custom oData Service I need an Entity that will feed an analytical Table in sapui5. The table should show the sum of the VBELN positions.

The Entity collects already the VBELN positions and all the needed supplementary attributes and the data can be displayed in sapui5 in a Responsive Table.

Now this Table has been changed to an analytical table and the annotations for aggregation, dimensions and measures were done in the DEFINE method of the MPC_EXT class.

In SEGW a mapping was done between the Entity Set and the Structure used in the back-end to collect the data.

In the DPC_EXT class, the method if_sadl_gw_query_control~SET_QUERY_OPTIONS defines the SUM columns, and the method GET_ENTITY calls get_keys_from_analytical_id.

But something seems to be missing. In my front-end application I receive many copies of the very same record and when looking at the data I can see that the GENERATED_ID is empty.

How do I populate the GENERATED_ID in a custom oData Service?

I followed these documentations:

  • https://archive.sap.com/kmuuid2/b0405b7f-c1d2-3110-79bd-ce64f64ea6b7/How%20to%20Use%20OData%20Analytics%20in%20SADL-Based%20Services.pdf
  • https://blogs.sap.com/2018/01/12/fiori-elements-analytical-table-with-sadl/

ABAP code:

method DEFINE.
  DATA(lo_entity_type) = model->get_entity_type( 'Overview' ).
  lo_entity_type->set_semantic(
      /iwbep/if_ana_odata_types=>gcs_ana_odata_semantic_value-query-aggregate ).

  DATA(lo_property) = lo_entity_type->get_property( 'Auftraggeber' ).
  DATA(lo_annotation) = lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 
      /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ).
  lo_annotation->add( 
      iv_key   = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
      iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-dimension-dimension ).


  lo_property = lo_entity_type->get_property( 'Verkaufsbeleg' ).
  lo_annotation->add( 
      iv_key   = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
      iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-dimension-dimension ).

  lo_property = lo_entity_type->get_property( 'Position' ).
  lo_annotation->add( 
      iv_key   = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
      iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-dimension-dimension ).

  lo_property = lo_entity_type->get_property( 'Menge' ).
  lo_annotation->add( 
      iv_key   = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
      iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-measure-measure ).

  lo_property = lo_entity_type->get_property( 'Umsatz' ).
  lo_annotation->add( 
      iv_key   = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
      iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-measure-measure ).
endmethod.      


method IF_SADL_GW_QUERY_CONTROL~SET_QUERY_OPTIONS.
  io_query_options->set_aggregation( VALUE #(
  ( element = 'MENGE'  alias = 'MENGE'  type = if_sadl_gw_query_options=>co_aggregation_type-sum )
  ( element = 'UMSATZ' alias = 'UMSATZ' type = if_sadl_gw_query_options=>co_aggregation_type-sum )
  ) ).
endmethod.      

method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITY.
  if_sadl_gw_dpc_util~get_dpc( )->get_keys_from_analytical_id(
      EXPORTING io_tech_request_context = io_tech_request_context
      IMPORTING et_keys = DATA(lt_keys) ).
endmethod.

来源:https://stackoverflow.com/questions/56838791/how-is-the-generated-id-created-in-a-custom-odata-service-to-feed-an-analytical

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!