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
lukaspreidt
Explorer
0 Kudos

Hi, there are two ways to extend the application to meet your needs:

  1. The field you want to add is a SAP field but not included in the OData Service: To do this, you can use the Custom Fields app in the Fiori Launchpad and create a 'Data Source extension'. For the data source with the same name as the app:
    lukaspreidt_1-1712658231076.png
    The field can then be added to the UI using "adapt ui". There is a blog post I can recommend that gives an example: Adding Field in standard Fiori apps of S/4HANA wit... - SAP Community
  2. The field you want to add is a real custom field (not from SAP) and not included in the OData Service: So you need to append the field to a database table (which depends on your field) or create a new database table. Then you need to extend the CDS view(s).
     F0_Mmim_Matstockquanvalbydate is the name of the CDS View which is used by the OData Service. Learn how to extend CDS views and apply database fields to them in this blog: Extending Transactional Fiori App based on Fiori E... - SAP Community  - The example is for transactional applications, but the extension process should work for analytical applications as well.
    You can add the fields to the UI using "adapt ui".