Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
2,524

Introduction


In this article, I would like to show an example of implementing Currency Translation enhancement spot BADI_FINCS_CTR_EXCHANGE_RATES which enable users to select deviating Exchange Rates than the one determined by the standard Currency Translation task in Group Reporting.

Validity


This BADI is planned in 2023 for SAP S/4HANA, SAP S/4HANA Cloud, private edition, and SAP S/4HANA Cloud, public edition. It is also available for SAP S/4HANA release 2021 and 2022 via SAP note 3299211. It will be available for Cloud Developer Extensibility in 3 System Landscape.

 

Exemplified Use Case


The rule definition of the standard Currency Translation does not allow using selections objects that contain anything other than Chart of Accounts, Financial Statement items, Subitems, and Document types.

In my use case, balance sheet FS items with transaction type 901 "Incoming units" are translated using Translation Method S0903 in rule nr. 035. The Exchange Rate determined by the system is /1.47060.

However, I want to use a deviating Exchange Rate /1.39170 for postings between cons. unit AM03 and its partner unit AM02.

 

Exemplified Custom Configurations


For this use case, I defined a new customizing DB table called ZCTR_PARTNR_RATE where I can store the Year/Period dependent combination of cons. unit and partner unit and their assigned exchange rate type and date.

The table script for this example is as below:
@EndUserText.label : 'Rate by Partner'
@AbapCatalog.enhancement.category : #EXTENSIBLE_CHARACTER
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #C
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zctr_partnr_rate {

key mandt : mandt not null;
key cons_unit : fincs_rbunit not null;
key partner_unit : fincs_rbunit not null;
key fiscal_year : fc_ryear not null;
key fiscal_period : fc_perid not null;
exchange_rate_type : fc_exrtyp;
rate_valid_from : datum;

}

 

Cloud Customers can create their Business Configurations as described here or as shown in this torturial. They also need to use publically released data elements.

 

BADI Implementation


 

You can check this tutorial on how to implement a BADI in Cloud.

In my example, I implemented enhancement spot BADI_FINCS_CTR_EXCHANGE_RATES and copied the example class.

I also created a constructor method to get required customizing into buffer.

The example class that I copied is created privately so I changed that to public.

In the BADI method implementation, I simply check if there is an entry for the current executed cons. unit, partner unit, fiscal year, and fiscal period. If the business user assigned a certain Exchange Rate Type and a validity date, the public method tries to fetch the relevant Exchange Rate (ER). if the ER was not found, it raises an exception, otherwise, it returns the ER.

You don’t have to buffer the result from the database. This is already done by the standard development.

The class syntax is illustrated below:
class zcl_rate_by_parnter definition
public
final
create public.

public section.
interfaces if_badi_interface.
interfaces if_badi_fincs_ctr_get_ex_rate.

methods: constructor.
private section.
data: mt_fsitems type sorted table of I_CNSLDTNFSITEMBYTIMEVERSION with unique key
ConsolidationChartOfAccounts
CnsldtnFinancialStatementItem
ConsolidationVersion
ToFiscalYearPeriod.

data: mt_rate_by_partner type sorted table of ZCTR_PARTNR_RATE with unique key cons_unit
partner_unit fiscal_year fiscal_period.
ENDCLASS.



CLASS ZCL_RATE_BY_PARNTER IMPLEMENTATION.

METHOD CONSTRUCTOR.

select * from ZCTR_PARTNR_RATE into table @mt_rate_by_partner.

ENDMETHOD.

method if_badi_fincs_ctr_get_ex_rate~get_exchange_rate.

read table mt_rate_by_partner with table key cons_unit = is_lookup_parameters-consolidationunit
partner_unit = is_lookup_parameters-partnerconsolidationunit
fiscal_year = is_lookup_parameters-fiscalyear
fiscal_period = is_lookup_parameters-fiscalperiod
into data(ls_partner_rate).

if sy-subrc is initial.

select single * from I_EXCHANGERATERAWDATA where
SourceCurrency = @is_lookup_parameters-consolidationcurrencysource
and TargetCurrency = @is_lookup_parameters-groupcurrency
and ExchangeRateType = @ls_partner_rate-exchange_rate_type
and ValidityStartDate = @ls_partner_rate-rate_valid_from
into @data(ls_rate).

if sy-subrc is initial.
ev_exchange_rate = ls_rate-ExchangeRate.
else.
raise exception type cx_exchange_rates message id 'ZCTR' type 'E' number '001'
with is_lookup_parameters-consolidationcurrencysource
is_lookup_parameters-groupcurrency
ls_partner_rate-exchange_rate_type
ls_partner_rate-rate_valid_from .
endif.

endif.

endmethod.


ENDCLASS.

 

The public interface of this BADI provides the below runtime parameters:








  • ConsolidationVersion : The current version processed. Either the one visible on the selection screen of currency translation or an extension version of it.

  • ConsolidationChartOfAccounts : As on the selection screen of currency translation.

  • FiscalYear and FiscalPeriod : As on the selection screen of currency translation.

  • FiscalYearVariant : The fiscal year variant assigned to the unit or to the version

  • ConsolidationUnit : As on the selection screen of currency translation or from Group Structure.

  • FinancialStatementItem : The current processed financial statement item.

  • SubItem : The current processed SubItem.

  • ConsolidationDocumentType : The current processed document type.

  • PartnerConsolidationUnit : The current processed partner unit.

  • CnsldtnCrcyTranslationMethod : The assigned currency translation method of the processed cons. unit

  • CnsldtnCrcyTransMethodStep : The current applied translation method step.

  • CurrencyTranslationKey : The assigned Currency Translation Key to the method step.

  • ExchangeRateType : The applicable Exchange rate type to the currency translation method step.

  • CurrencyTranslationDate : The applicable date of the exchange rate for the current processed line

  • ConsolidationCurrencySource : This can be either the Local Currency or Transaction Currency.

  • GroupCurrency : The target currency conversion.



 

Best Regards / Viele Gruesse /Mnoho pozdravů /Amicalement /Distinti Saluti /Cumprimentos /Abraço /Saludos / 敬具 / 此致 /  تحياتي

 

Mazen Abbas
4 Comments