cancel
Showing results for 
Search instead for 
Did you mean: 

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

appu24
Explorer

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 ).

In DPC_Ext method redefined MATERIALMULTISTO_GET_ENTITY , MATERIALMULTISTO_GET_ENTITYSET

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.
TRY.
CALL METHOD super->if_sadl_gw_query_control~set_query_options
EXPORTING
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.
ENDTRY.


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 ) ) ) .

ENDCASE.

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
Yanbing
Advisor
Advisor
0 Kudos