cancel
Showing results for 
Search instead for 
Did you mean: 

Missformated amounts in excel exports of oData-V4 Fiori Apps

mark05
Explorer
1,413

Hello Community,

I am currently struggling with an issue that seems to affect all Fiori Elements apps that use the V4-oData model. When I assign a currency field to an amount there via annotation, the currency is written to a cell with the amount (as a string) during Excel export. Further processing in Excel is then not directly possible. In addition, the language setting is also ignored, the amounts are always delivered with "." as a comma separator.

With V2 apps, on the other hand, only the amount is written to the cell, the currency is then displayed via the formatting options. Further processing is possible without any problems. In addition, a "," is used here as a comma separator (correct).

Here is the output with the V2 app:

And here the output of the V4 app:

DB schema:

aspect CommonCostsModel : managed, cuid {
    ...
    @Semantics.currencyCode
    currency       : Currency                    @title : '{i18n>Currency}';
    ...
}
entity Test : CommonCostsModel {
    ...
    @Semantics.amount.currencyCode :                                    'currency'
    netCost          : Decimal(15, 7)              @title :             '{i18n>NetCost}';
    ...
}

Annotations CDS of the application:

annotate service.Test with {
    ...
    netCost                 @(Measures.ISOCurrency : currency_code);
    ...

}<br>

Do I need some other annotations for the V4 variant of the oData service? I could not find anything in the documentation regarding this.

UPDATE 2021-12-22:

The application was developed with SAPUI5 version 1.87.9. This version is no longer LTS, so I have now updated the version to 1.96.2 or 1.97.0. Unfortunately, the problem has even worsened with both newer versions. Now, in addition to the wrong format, an error message appears when opening the xlsx file:

"We have detected a problem with some content in 'XXX.xlsx'. Should we restore as much as possible? If you trust this workbook, click 'Yes'."

Now when I click Yes, the Excel looks like it did before, but still with the formatting problem.

-----------------------------

UPDATE 2022-01-20:

I've debugged into the ExportBase class to find the column settings for the Excel Export. I've done this for the V2 and the V4 app to find any difference. Furthermore I've compared the oData metadata file and also the values from the response.

Column settings | UI5 1.87.9 | oData V2 (working)

Column settings | UI5 1.87.9 | oData V4 (wrong format in xlsx file)

Metadata | oData V2

Metadata | oData V4

oData Response | oData V2

oData Response | oData V4

-----------------------------

Thank you very much in advance!

Best Regads,

Mark

Accepted Solutions (0)

Answers (1)

Answers (1)

HerzogIgzorn
Associate
Associate
0 Kudos

Hello Marc,

thank you for sharing this additional information. As you can see, the V2 configuration is of type "Currency" with all corresponding properties maintained. In contrast to V2, the V4 configuration is of type "String" and a template is applied on the input. This means the values of netCost and currency_code will be applied to the template and stored as a string. That's the reason why the editing bar in MS Excel also shows the currency code in V4. It is also not possible to apply formulas to the "String" output (at least no numerical formulas).

I assume that you are using Fiori ListReport template for your application? The difference between OData V2 and V4 is usually the type of table that is used by the different templates. While OData V2 utilizes the sap.ui.comp.SmartTable, the V4 template utilizes the sap.ui.mdc.Table which does not evaluate the $metadata directly. The sap.ui.mdc.Table is based on a Delegate that provides the propertyInfo to the table. This propertyInfo also contains specific exportSettings for each column. If there is no exportSettings available in the propertyInfo, it will use the default fallback to a column of type sap.ui.export.EdmType.String which will result in the current scenario.

The question that now remains is, whether your V4 application uses the sap.ui.mdc.Table and why the Delegate does not provide the corresponding exportSettings for this particular column.

What you can do in this situation is either creating a support ticket (if you are a licensed SAP customer) or gather more details in your application. In case the sap.ui.mdc.Table is used, you can set a breakpoint in the following function to get some insights:

Table.prototype._createExportColumnConfiguration

This function uses the PropertyHelper mixin to access the propertyInfo of the Delegate.

Regards Sebastian

mark05
Explorer
0 Kudos

Hey Sebastian,

first of all: Yes, I'm using the Fiori ListReport template.

I've now debugged a little bit into the sap.ui.mdc.Table object. I'm not sure if that is relevant, but I found a code line in the PropertyHelper, where the method gets the ColumnDataProperty, with the included ExportSettings. In this oProperty Object it contains the type on root level and some other type in the ExportSettings. And they are different:

description: "Nettokosten"
exportSettings:
  delimiter: false
  falseValue: undefined
  format: undefined
  inputFormat: undefined
  label: "Nettokosten"
  scale: 7
  template: "{0}  {1}"
  trueValue: undefined
  type: "String"
  [[Prototype]]: Object
filterExpression: "auto"
filterable: false
group: ""
groupLabel: ""
groupable: false
isAggregatable: ƒ ()
key: false
label: "Nettokosten"
maxConditions: null
maxLength: undefined
metadataPath: "/-SECRET-/@com.sap.vocabularies.UI.v1.LineItem/10"
name: "netCost"
path: null
precision: undefined
propertyInfos: (2) ['Property::netCost', 'Property::currency_code']
scale: undefined
sortable: false
type: "Edm.Decimal"
typeConfig: null
unit: undefined
visible: true
As you can see, the type on root level is Edm.Decimal, but in the ExportSettings it's String.

Apart from that, I have not been able to detect anything unusual.

Best regards,

Mark