on 2024 Jan 08 1:19 PM
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.
Request clarification before answering.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, there are two ways to extend the application to meet your needs:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can refer to detail here
https://community.sap.com/t5/technology-blogs-by-sap/odata-service-development-with-sap-gateway-code...
User | Count |
---|---|
98 | |
39 | |
8 | |
6 | |
5 | |
3 | |
3 | |
2 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.