<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: CDS View Entity Incorrect Currency Format in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cds-view-entity-incorrect-currency-format/qaa-p/12786366#M4800599</link>
    <description>&lt;P&gt;Hey Ozan,&lt;/P&gt;&lt;P&gt;I've tried changing those parameters and the results are the same. The converted amount still only has 2 decimal places.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;  key t001.waers,&lt;/P&gt;&lt;P&gt;      @Semantics.amount.currencyCode: 'waers'&lt;/P&gt;&lt;P&gt;      bseg.dmbtr               as original_amount,&lt;/P&gt;&lt;P&gt;      cast('IQD' as abap.cuky) as new_key,&lt;/P&gt;&lt;P&gt;      @Semantics.amount.currencyCode: 'new_key'&lt;/P&gt;&lt;P&gt;      currency_conversion(&lt;/P&gt;&lt;P&gt;        amount =&amp;gt; bseg.dmbtr,&lt;/P&gt;&lt;P&gt;        source_currency =&amp;gt; t001.waers,&lt;/P&gt;&lt;P&gt;        target_currency =&amp;gt; cast('IQD' as abap.cuky),&lt;/P&gt;&lt;P&gt;        exchange_rate_date =&amp;gt; $session.system_date,&lt;/P&gt;&lt;P&gt;        round =&amp;gt; '',&lt;/P&gt;&lt;P&gt;        client =&amp;gt; $session.client,&lt;/P&gt;&lt;P&gt;        decimal_shift =&amp;gt; '',&lt;/P&gt;&lt;P&gt;        decimal_shift_back =&amp;gt; 'X'&lt;/P&gt;&lt;P&gt;         )                     as new_amount&lt;/P&gt;&lt;P&gt;This is what my new currency_conversion looks like. I tried turning round off because I was wondering if it was rounding the number and the 3rd decimal digit was becoming 0 and maybe SAP wasn't showing that 0 at the end. I turned decimal_shift off, and left decimal_shift_back on since the parameter's description says, decimal places of the result are moved as specified by the decimal places of the target currency.&lt;/P&gt;&lt;P&gt;Data Preview looks like this.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2210191-decimal-shift-data.png" /&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Silas&lt;/P&gt;</description>
    <pubDate>Tue, 26 Sep 2023 15:45:46 GMT</pubDate>
    <dc:creator>SilasL</dc:creator>
    <dc:date>2023-09-26T15:45:46Z</dc:date>
    <item>
      <title>CDS View Entity Incorrect Currency Format</title>
      <link>https://community.sap.com/t5/technology-q-a/cds-view-entity-incorrect-currency-format/qaq-p/12786362</link>
      <description>&lt;P&gt;Hey All,&lt;/P&gt;
  &lt;P&gt;I'm trying to get a CDS view entity to take a currency amount and convert that amount to follow the format for the given currency code. I have a minimal version of my CDS view below. &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;@AbapCatalog.viewEnhancementCategory: [#NONE]&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@AccessControl.authorizationCheck: #NOT_REQUIRED&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@EndUserText.label: 'CDS for Currency Convertion'&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@Metadata.ignorePropagatedAnnotations: true&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@ObjectModel.usageType:{&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;serviceQuality: #X,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;sizeCategory: #S,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;dataClass: #MIXED&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;}&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;define view entity z_cds_currency_convert&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;as select from bseg&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;inner join t001 on bseg.bukrs = t001.bukrs&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;{&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;key t001.waers,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@Semantics.amount.currencyCode: 'waers'&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;bseg.dmbtr as original_amount,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;cast('ADP' as abap.cuky) as new_key,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@Semantics.amount.currencyCode: 'new_key'&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;bseg.dmbtr as converted_amount&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;}&lt;/P&gt;
  &lt;P&gt;I've been testing with bseg-dmbtr, and I have one column of bseg-dmbtr that uses the local currency code from t001, and another column that uses a hard coded currency code in the view. This is what currency code ADP looks like in my system's table TCURX, in the table it has currency decimal 0.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2210958-adp-currency-code.png" /&gt;&lt;/P&gt;
  &lt;P&gt;So I'm expecting the output to have the currency amounts with no decimal places. However this is what I see when I go to data preview.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2210961-cds-output.png" /&gt;&lt;/P&gt;
  &lt;P&gt;I've tried using currency_conversion function which has a parameter for target_currency, and that also hasn't worked. I tried every combination of decimal_shift and decimal_shift_back and it seems to also not have any effect on the output. Currency Code with more than 2 decimals also doesn't work.&lt;/P&gt;
  &lt;P&gt;However when I go back to CDS views, I can use decimal_shift and that works properly. Here is the code for the CDS View.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;@AbapCatalog.sqlViewName: 'Z_CDS_CURRENCY'&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@AbapCatalog.compiler.compareFilter: true&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@AbapCatalog.preserveKey: true&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@AccessControl.authorizationCheck: #NOT_REQUIRED&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@EndUserText.label: 'CDS for Currency Test'&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;define view z_cds_currency_test_qzgbh1&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;with parameters&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;iv_target_key :abap.cuky&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;as select from bseg&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;inner join t001 on bseg.bukrs = t001.bukrs&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;{&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@Semantics.currencyCode: true&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;t001.waers,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@Semantics.amount.currencyCode: 'waers'&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;bseg.dmbtr as original_amount,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@Semantics.currencyCode: true&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;cast ('ADP' as abap.cuky) as new_key,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;@Semantics.amount.currencyCode: 'new_key'&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;decimal_shift(amount =&amp;gt; bseg.dmbtr, currency =&amp;gt; $parameters.iv_target_key ) as new_amount&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;}&lt;/P&gt;
  &lt;P&gt;With the following output&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2210962-cds-view-output.png" /&gt;&lt;/P&gt;
  &lt;P&gt;However decimal_shift isn't support for CDS View entity. Does anyone know how I can set up my CDS View entity to do the same?&lt;/P&gt;
  &lt;P&gt;Thanks,&lt;/P&gt;
  &lt;P&gt;Silas&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 01:29:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cds-view-entity-incorrect-currency-format/qaq-p/12786362</guid>
      <dc:creator>SilasL</dc:creator>
      <dc:date>2023-09-21T01:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View Entity Incorrect Currency Format</title>
      <link>https://community.sap.com/t5/technology-q-a/cds-view-entity-incorrect-currency-format/qaa-p/12786363#M4800596</link>
      <description>&lt;P&gt;Hi Silas,&lt;/P&gt;&lt;P&gt;currency_conversion function should work for CDS. You can check below code. For sure, exchange rates for given date should be available at TCURR table for given date. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;      currency_conversion(
        amount             =&amp;gt; bseg.dmbtr,
        source_currency    =&amp;gt; t001.waers,
        target_currency    =&amp;gt; cast('ADP' as abap.cuky),
        exchange_rate_date =&amp;gt; date which you want to make exchange rate conversion
      )        as PriceInADP&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Sep 2023 09:42:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cds-view-entity-incorrect-currency-format/qaa-p/12786363#M4800596</guid>
      <dc:creator>ozturkozan</dc:creator>
      <dc:date>2023-09-21T09:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View Entity Incorrect Currency Format</title>
      <link>https://community.sap.com/t5/technology-q-a/cds-view-entity-incorrect-currency-format/qaa-p/12786364#M4800597</link>
      <description>&lt;P&gt;Hey Ozan,&lt;/P&gt;&lt;P&gt;The currency_conversion didn't work for me, here is how I used currency_conversion.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;define view entity z_cds_currency_convert&lt;/P&gt;&lt;P&gt;  as select from bseg&lt;/P&gt;&lt;P&gt;    inner join   t001 on bseg.bukrs = t001.bukrs&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;  key t001.waers,&lt;/P&gt;&lt;P&gt;      @Semantics.amount.currencyCode: 'waers'&lt;/P&gt;&lt;P&gt;      bseg.dmbtr                    as original_amount,&lt;/P&gt;&lt;P&gt;      cast('IQD' as abap.cuky)      as new_key,&lt;/P&gt;&lt;P&gt;      @Semantics.amount.currencyCode: 'new_key'&lt;/P&gt;&lt;P&gt;      currency_conversion(&lt;/P&gt;&lt;P&gt;        amount =&amp;gt; bseg.dmbtr,&lt;/P&gt;&lt;P&gt;        source_currency =&amp;gt; t001.waers,&lt;/P&gt;&lt;P&gt;        target_currency =&amp;gt; cast('IQD' as abap.cuky),&lt;/P&gt;&lt;P&gt;        exchange_rate_date =&amp;gt; $session.system_date,&lt;/P&gt;&lt;P&gt;        client =&amp;gt; $session.client ) as new_amount&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;I had to change to IQD as my system doesn't have an exchange rate between ADP and USD. So IQD has the following values in table tcurx.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2210995-iqd-decimals.png" /&gt;&lt;/P&gt;&lt;P&gt;So I'm expecting a currency amount with 3 decimal places.&lt;/P&gt;&lt;P&gt;However when I run this CDS View entity in data preview, I see the following output.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2210996-cds-currency-conversion-output.png" /&gt;&lt;/P&gt;&lt;P&gt;The converted amount doesn't have 3 decimal places.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Silas&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 14:16:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cds-view-entity-incorrect-currency-format/qaa-p/12786364#M4800597</guid>
      <dc:creator>SilasL</dc:creator>
      <dc:date>2023-09-21T14:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View Entity Incorrect Currency Format</title>
      <link>https://community.sap.com/t5/technology-q-a/cds-view-entity-incorrect-currency-format/qaa-p/12786365#M4800598</link>
      <description>&lt;P&gt;CURRENCY_CONVERSION function has &lt;STRONG&gt;decimal_shift &lt;/STRONG&gt;and &lt;STRONG&gt;decimal_shift_back &lt;/STRONG&gt;parameters. You can check below link.&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abencds_f1_conv_func_unit_curr.htm#!ABAP_VARIANT_2@2@" target="test_blank"&gt;https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abencds_f1_conv_func_unit_curr.htm#!ABAP_VARIANT_2@2@&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 14:46:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cds-view-entity-incorrect-currency-format/qaa-p/12786365#M4800598</guid>
      <dc:creator>ozturkozan</dc:creator>
      <dc:date>2023-09-21T14:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View Entity Incorrect Currency Format</title>
      <link>https://community.sap.com/t5/technology-q-a/cds-view-entity-incorrect-currency-format/qaa-p/12786366#M4800599</link>
      <description>&lt;P&gt;Hey Ozan,&lt;/P&gt;&lt;P&gt;I've tried changing those parameters and the results are the same. The converted amount still only has 2 decimal places.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;  key t001.waers,&lt;/P&gt;&lt;P&gt;      @Semantics.amount.currencyCode: 'waers'&lt;/P&gt;&lt;P&gt;      bseg.dmbtr               as original_amount,&lt;/P&gt;&lt;P&gt;      cast('IQD' as abap.cuky) as new_key,&lt;/P&gt;&lt;P&gt;      @Semantics.amount.currencyCode: 'new_key'&lt;/P&gt;&lt;P&gt;      currency_conversion(&lt;/P&gt;&lt;P&gt;        amount =&amp;gt; bseg.dmbtr,&lt;/P&gt;&lt;P&gt;        source_currency =&amp;gt; t001.waers,&lt;/P&gt;&lt;P&gt;        target_currency =&amp;gt; cast('IQD' as abap.cuky),&lt;/P&gt;&lt;P&gt;        exchange_rate_date =&amp;gt; $session.system_date,&lt;/P&gt;&lt;P&gt;        round =&amp;gt; '',&lt;/P&gt;&lt;P&gt;        client =&amp;gt; $session.client,&lt;/P&gt;&lt;P&gt;        decimal_shift =&amp;gt; '',&lt;/P&gt;&lt;P&gt;        decimal_shift_back =&amp;gt; 'X'&lt;/P&gt;&lt;P&gt;         )                     as new_amount&lt;/P&gt;&lt;P&gt;This is what my new currency_conversion looks like. I tried turning round off because I was wondering if it was rounding the number and the 3rd decimal digit was becoming 0 and maybe SAP wasn't showing that 0 at the end. I turned decimal_shift off, and left decimal_shift_back on since the parameter's description says, decimal places of the result are moved as specified by the decimal places of the target currency.&lt;/P&gt;&lt;P&gt;Data Preview looks like this.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2210191-decimal-shift-data.png" /&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Silas&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 15:45:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cds-view-entity-incorrect-currency-format/qaa-p/12786366#M4800599</guid>
      <dc:creator>SilasL</dc:creator>
      <dc:date>2023-09-26T15:45:46Z</dc:date>
    </item>
  </channel>
</rss>

