Applies until only: S/4HANA 1909

Application to be enhanced:

https://fioriappslibrary.hana.ondemand.com/sap/fix/externalViewer/#/detail/Apps(‘F0735’)/S18OP

Task:

Add new column to the Analytical List and populate with data

SAP Help

https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/ac319d8fa4ea4624b40a58d23e3c4627/c76d8054f87c033de10000000a441470.html?&q=Cash%20Flow%20Item&locale=en-US

So far so good, one would think, like me facing first time enhancement of Analaytical list. I even have an official guide, so I will be ready in one hour. Great, since according the SAP description everything was familiar to me already!

The reality not 1 hour not even 2 :O, I struggled and had to deal withsome unmentioned annotations. At least SAP Help expects from you to know, without any further details.

The enhancement process

Extend the customer include structure
@EndUserText.label : 'Payment Item Extension'
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE
extend type fclm_cp_s_entity_pay_item_incl with zfclm_cp_s_entity_pay_item_a01 {
  zzdocumentreferenceid : xblnr1;

}
Created CDS View extension for Fclm_Paymentdetailflow
@AbapCatalog.sqlViewAppendName: 'ZVAPD_PAYMEN_A01'
@EndUserText.label: 'Payment Item Extension'
extend view Fclm_Paymentdetailflow with ZFclm_Paymentdetailflow
{
  _AccountingDocument.DocumentReferenceID as ZZDocumentReferenceID
}
Dynamic entity property

Instead of redefining the standard OData service FCLM_CP_PAYMENTDETAIL, and replacing this standard service within a brand new Fiori extension app for FIN_PAYDETAIL, I rather added the new property to the standard service FCLM_CP_PAYMENTDETAIL_SRV dynamically. To do so, I added an implicit enhancement at the end of the define method of the model provider extension class CL_FCLM_CP_PAYMENTDETA_MPC_EXT. Future system upgrades kept safe, good.

  "Add reference Document ID to PaymentDetail Item, so that available on UI
  "This solution is combined with the CDS View extension ZFclm_Paymentdetailflow
  DATA(zz_entity_type) = model->get_entity_type( iv_entity_name = 'PaymentDetailItem' ).
  DATA(zz_property) = zz_entity_type->create_property(
    iv_property_name  = 'ZZDocumentReferenceID'
    iv_abap_fieldname = 'ZZDOCUMENTREFERENCEID'
  ).

  zz_property->set_type_edm_string( ).
  zz_property->bind_data_element( EXPORTING iv_element_name = 'XBLNR1' ).
Let know SADL about the new property

Mapping new property via SADL is done by IF_SADL_GW_EXTENSION_CONTROL~SET_EXTENSION_MAPPING method of class CL_FCLM_CP_PAYMENTDETA_DPC. I let me enhance this, to map the new property to the ABAP field appended to the structure enhanced in the first step. This structure is configured in SEGW for the OData entity PaymentDetailItem.

  "Add reference Document ID to PaymentDetail Item, so that available on UI
  "This solution is combined with the CDS View extension ZFclm_Paymentdetailflow
  CASE iv_entity_set_name.
    WHEN 'PaymentDetailItemSet'.
      io_extension_mapping->set_property_mapping(
        it_property_mapping  = value if_sadl_gw_extension_mapping=>tt_property_mapping(
          (
            property_abap_name = 'ZZDOCUMENTREFERENCEID'
            business_entity_element  = 'ZZDOCUMENTREFERENCEID'
          )
        )
      ).
  ENDCASE.

Result

User can select the column in the Fiori app, but content still empty. What am I missing ?

Analyzis

However column visible on UI, the OData request for the sap.ui.comp.smarttable.SmartTable of type sap.ui.table.AnalyticalTable deos not request the new property through the binding. The OData request does not contain the property on the SELECT list.

A new area, new problems. SAP documentation gives no more support. UI5 Guideline, a snippet available, but also not working within an extension project. Hmmm… Ok lets start further deep dive in analyzis.

Common issue with the thousand of SAP Fiori apps, that applications were delivered by SAP at one of the plenty stages of the Fiori and OData evolution Absolutely not obvious, where the job is to be done. In UI5 or CDS or OData service configuration or in SEGW or dynamic programming. This results in lot of headaches for customers.

In this case Freestyle Fiori app is delivered, OData service manually implemented, based on CDS and SADL intermediation, but not as a reference CDS entity/model. So annotations were implemented with tons of manual work those times, and of course later appeared the helper classes.

OK, lets check the MPC_EXT class, and define method in detail which is responsible for any annotation and model extension. There are some interesting annotations which might be in focus for Fiori ALVs. As I saw “dimension” and “single value”, I felt, I am on the right track in context of analytics. Anyway, nothing to lose, to add such annos for my new extension field, due I do not want any aggregation or grouping, So at the end my extension define looked like this:

  "Add reference Document ID to PaymentDetail Item, so that available on UI
  "This solution is combined with the CDS View extension ZFclm_Paymentdetailflow
  DATA(zz_entity_type) = model->get_entity_type( iv_entity_name = 'PaymentDetailItem' ).
  DATA(zz_property) = zz_entity_type->create_property(
    iv_property_name  = 'ZZDocumentReferenceID'
    iv_abap_fieldname = 'ZZDOCUMENTREFERENCEID'
  ).

  zz_property->set_type_edm_string( ).
  zz_property->bind_data_element( EXPORTING iv_element_name = 'XBLNR1' ).  
  cl_fis_filter_annotation=>single_value(
    io_model = model
    iv_entity_type = 'PaymentDetailItem'
    iv_property    = 'ZZDocumentReferenceID'
  ).

  cl_fis_sadl_annotation=>dimension( 
    io_model = model
    iv_entity_type = 'PaymentDetailItem'
    iv_property    = 'ZZDocumentReferenceID' 
  ).

Voila, I got the values!


Lesson

You can be experienced with CDS, but such slap can come :D. When you create Analytical Tables from scratch using new technologies and frameworks, the stuff behind the scenes is covered. This is how you manually manage annotations for analytics, instead of dealing with CDS view annotations.

An alternative way for calculated properties

So what if the value in your custom field cannot be populated into the new ZZ field by simply a CDS View extension, but have to be calculated dynamically. Do not be sad, here are actually two alternatives.

A. Implement BAdI fclm_cp_payment_item_details

B. Create a virtual element in the CDS View

Share this content: