Showing results for 
Search instead for 
Did you mean: 

[Extension]-Stock - Multiple Materials App [F1595] for field aggregation


Hello All ,

The requirement is to Extend Fiori application “Stock - Multiple Materials “ for a custom column and display aggregated sum value at end of table for the column

Decided Approch :

Append Structure MMIM_MATERIAL_MULTI_STOCK with Custom fields

created a Cutsom Odata service extension in SGEW to extend and override standard odata service MMIM_MULTIPLE_MATERIAL_SRV

extended odata service MPC_EXT Define method with below snippet

DATA(lo_entity_type) = model->get_entity_type( 'MaterialMultiStockByDate' ) 
    DATA(lo_property) = lo_entity_type->get_property( '<custom_field_name')
    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-measure-measure ).


Get_Entity : simply calling super method

Get_EntitySet: modified et_entityset to add custom logic and populate custom field data .

Above changes give below result:

To add Aggregation at the bottom of the table :

Have redefined SET_QUERY-OPTIONS METHODS and added below snippet

  METHOD if_sadl_gw_query_control~set_query_options.
CALL METHOD super->if_sadl_gw_query_control~set_query_options
iv_entity_set = iv_entity_set
io_query_options = io_query_options.
CATCH cx_sadl_gw_contract_violation.
CATCH /iwbep/cx_mgw_busi_exception.
CATCH /iwbep/cx_mgw_tech_exception.

CASE iv_entity_set.
WHEN 'MaterialMultiStockByDates'.

io_query_options->set_aggregation( VALUE #(
( element = '<Custom_field_name_in_caps>' alias = '<abap_field_name_for_custom_field>' type = if_sadl_gw_query_options=>co_aggregation_type-sum ) ) ) .


The application breaks when custom fields are selected to be displayed in table

In standard gateway project the entity set has Mapping to Consumption view F0_Mmim_Matstockquanvalbydate . Possibly because the custom fields are not mapped the at run time the custom field is not found and application is braking . however in extended gateway project No option to map the custom fields and code breaks at “check_Unknown aggregation” method

Am not sure what extra i need to do to make it work properly.

View Entire Topic
Active Contributor
0 Kudos

My requirement was a little different but for the same app. I hope there is a better option than what I did which was to recreate the service from scratch copy-pasting everything. That way I was able to add any new mapping that I wanted (first extend the CDS view).

Maybe someone will comment with a more upgrade-safe approach for these kind of services, but considering the lack of blogs/questions about something that should be so simple, I really doubt it.

0 Kudos
OData service development with SAP Gateway - code-based service development - Part I