cancel
Showing results for 
Search instead for 
Did you mean: 

Unit of Measure (UOM) truncated in Core Data Service (CDS) based OData Service

gregorw
Active Contributor
0 Kudos

Hello CDS / SAP Gateway Experts,

I have an interesting issue with a CDS View that should show the ProductBaseUnit. The issue occurred in a SAP ERP 6.0 EhP8 (NetWeaver 7.50 SP5) System, but I’m able to repeat the issue also in the NetWeaver Developer Edition system (7.50 SP2) using the EPM Demo Data Model. If I create a CDS View with the following source:

@AbapCatalog.sqlViewName: 'ZGWEPMPROD'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'EPM Product'
@OData.publish: true
define view ZGW_C_EPM_Product as select from SEPMRA_C_PD_Product {
    *
}

when I then maintain a Product using the also provided Fiori App to maintain Products with a Base Unit of Pallets (PAL) and the Weight Unit of US Tons (TON):

then this is correctly shown when I use the ABAP in Eclipse Data Preview:

But when I call the same Material using the generated OData Service I get back:

<d:ProductBaseUnit>PF</d:ProductBaseUnit>

I've dug a little bit deeper now and when setting a breakpoint in the /iwbep/if_mgw_appl_srv_runtime~get_entityset or /iwbep/if_mgw_appl_srv_runtime~get_entity methods of class cl_sadl_gw_generic_dpc I see the data is still intact. So I guess this has something to do with a conversion exit.

Is that a bug or a error on my side?

Best regards
Gregor

Accepted Solutions (0)

Answers (1)

Answers (1)

nitschket
Advisor
Advisor
0 Kudos

Hello Gregor,

this is not a truncation but still a strange behavior. The base unit in the product table of the EPM model uses domain MEINS which refers to a conversion exit CUNIT. Hence, the direct exposure of the CDS View should make use of this conversion. But CUNIT just maps the language-specific UoMs (technically, MSEHI to MSEH3 in table T006A). Your OData service should return PAL as well. I tried to reproduce it and got PAL.

PF is the ISO-Code of PAL - please refer to table T006. So it seems that an ISO conversion is happening which is the default handling for currency codes and units of measure. So somehow the conversion exit is not taken into account in your specific case.

Finding the root cause would require some debugging...

So far, I did not publish the third blog post of the conversion series. It would deal with the specialties of currency and measure conversions.

Thomas

gregorw
Active Contributor
0 Kudos

Hi Thomas,

I did a trace and found out that this Methods/Functions Modules are called:

Call M. CL_GDT_CONVERSION=>UNIT_CODE_OUTBOUND
Load Report SAPLSCV0
Call Function UNIT_OF_MEASURE_SAP_TO_ISO
Select Single T006

So you're right the ISO Code is returned in the OData Service.

Best regards
Gregor

_jonas_
Participant
0 Kudos

Hi gregorw

I ran into the same problem just the other day: using a simple case statement inside a CDS view returning CUNIT will output the ISO code instead of MSEHI. W/O the case statement everything works as expected. I know this is an old question but did you figure out how to fix/influence the conversion?

Thank you.

Regards
--jonas

nitschket
Advisor
Advisor

Does not help directly but this is the blog post I was mentioning in my first reply: https://blogs.sap.com/2019/08/26/conversions-in-sap-gateway-foundation-part-3-currency-amounts/