How to…currency conversion

download How to…currency conversion

of 18

Transcript of How to…currency conversion

  • 8/2/2019 How tocurrency conversion

    1/18

    SAP (SAP America, Inc. and SAP AG) assumes no responsibility for errors or omissions in these materials.

    These materials are provided as is without a warranty of any kind, either express or implied, including but not limited to, the

    implied warranties of merchantability, fitness for a particular purpose, or non-infringement.

    SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages

    that may result from the use of these materials.

    SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within

    these materials. SAP has no control over the information that you may access through the use of hot links contained in these

    materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third

    party web pages.

    mySAP BI How -To papers are intended to simplify the product implementation. While specific product features and

    procedures typically are explained in a practical business context, it is not implied that those features and procedures are

    the only approach in solving a specific business problem using mySAP BI. Should you wish to receive additional information,

    clarification or support, please refer to SAP Professional Services (Consulting/Remote Consulting).

    How t o

    Use var iab le t im e re fe rencesin cu r r ency conv e rsions

    BUSINESS INFORMATION WAREHOUSE

    Applicable Releases: 3.X

  • 8/2/2019 How tocurrency conversion

    2/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    1998 SAP AMERICA, INC. AND SAP AG TABLE OF CONTENTS

    Release date: March 2003

  • 8/2/2019 How tocurrency conversion

    3/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    1 Business Scenario

    Today, in SAPs Business Information Warehouse, currency conversion can take place using different

    parameters defined in a currency translation key (source currency, target currency, exchange rate

    type and time reference) and in different layers (during update of data to the data targets, at query

    definition time and at query runtime). The following table gives an overview which currency conversion

    can be used in which layer:

    One major requirement, not fully covered by todays architecture, is the dynamic time currency

    conversion using variables in Reporting. The dynamic time reference in the above mentioned table only

    includes dynamic conversion using a date InfoObject (no variable input) or the query key date

    (applicable in only some business cases, see comment below).

    Therefore, this technical solution shows you how to implement multiple and dynamic time currency

    conversions in one query. This includes especially variable time conversions allowing the customer to

    execute different conversions to the same target currency using different dates (example: simulate

    influence of exchange rates on sales). Please note: the variable selection of the target currency

    mentioned in this paper can be achieved using standard functionality.

    PLEASE NOTE THAT WITH BW 3.0B SP 16 / BW

    3.1C SP10 A STANDARD SOLUTION TO THIS

    SCENARIO IS AVAILABLE. PLEASE FIND MOREINFORMATION IN DOCUMENT HOW TO... USE

    VARIABLES FOR CURRENCY CONVERSION AND

    IN SAP SERVICE MARKETPLACE NOTE 656863.

    BEx / Web BExReporting

    ad hoc

    Query

    Designer

    Update

    Rules

    Source currency from data record X X X

    from InfoOb ect XTarget currency fixed X X X

    from InfoOb ect X Xselection X X X

    Exchange rate fixed ty e X X X

    from InfoObject X

    Time reference fixed X X Xdynamic X X

  • 8/2/2019 How tocurrency conversion

    4/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    The solution needs to be implemented only once per InfoCube but is very usable for the BW end users.

    Only the conversion rates (table TCURR) have to be loaded (and maintained on R/3) on a regular basis.

    Key benefits of this solution are:

    Very easy to use (simple input of time reference by user)

    Independent of data model (solution works with any Infocube and query).

    Correct aggregation of converted quantities (totals and subtotals are calculated).

    Low performance impact: usage of the OLAP BADI (virtual exit) is not leading to bigger data

    amounts being processed by the OLAP processor.

    No impact on transaction data stored in the BW database.

    2 Introduction

    The basis of this technical solution is to use the virtual InfoObject ZCURRDATE for dynamic time

    reference in the currency translation key. Virtual InfoObject means, that this InfoObject is not loaded

    using the BW data staging (it contains no data on the BW database) and is declared as being virtual

    (ig.processed at query runtime) in a customer enhancement (BADI or SAP enhancement possible, see

    step by step solution for further details).

    Therefore, the date (on which every single line read from the InfoProvider tables is converted in the OLAP

    processor) will not be retrieved from the BW database, but, will be assigned to ZCURRDATE at query

    runtime deriving its value from a variable entry.

    The following graphic gives you an overview on which implementation steps have to be performed in

    order to implement such a scenario (more details can be found in the section The Step by Step

    solution):

  • 8/2/2019 How tocurrency conversion

    5/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

  • 8/2/2019 How tocurrency conversion

    6/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    The major steps performed at query runtime will be:

    - Enter the date for which the currency conversion has to take place using the characteristics

    value variable ZCURDAT based on virtual characteristic ZCURRDATE

    -Read variable value using the standard exit RSR00001 and assign it to the class attributeCURRDATE

    - Assign the value of this class attribute to CURRDATE using the BADI RSR_OLAP_BADI. This

    BADI only available from BW 3.X onwards was formerly known as Exit for virtual characteristics

    and key figures

    - The OLAP processor will then perform a standard currency conversion using a translation key

    with dynamic time reference based on InfoObject ZCURRDATE

    The following objects must be implemented for this solution:

    - Characteristics: InfoObject type date (ZCURRDATE)

    -Currency translation key (ZCURRTK1)

    - Characteristic value variable for the time reference: ZCURDAT

    - Characteristic value variable for selection of the target currency (ZCURTC) (optional)

    - Text Variable: display selected currency conversion date in column header (ZCURDT) (optional)

    - BADI Implementation ZCURRCONV with generated class ZCL_IM_CURRCONV

    - Static global attribute CURRDATE in class ZCL_IM_CURRCONV

    - User Exit: Variable Exit (ZXRSRU01) within enhancement RSR00001

    Please be aware of the fact that with BW 3.0B SP8 the Key Date stored in the Query Properties

    (used for time dependent master data objects) can be used as variable time reference in a

    currency translation key. This standard technique might replace the following step-by-step

    solution in some business cases (e.g. if only one conversion is necessary and key date is the

    date to be used for conversion). For further information see SAP Service Marketplace (OSS)

    note 570050.

    Please note that having a support package level inferior to BW 3.0B SP13 (BW 3.1 Content

    SP7) this solution (using a virtual characteristic) leads to deactivation of the OLAP Cache per

    relevant query. From BW 3.0B SP13 / BW 3.1 Content SP7 on, you can set the flag Use OLAP

    cache even with virtual chararcteristic / key figure within the query properties in transaction

    RSRT WHEN USING THE SOLUTION DESCRIBED IN THIS PAPER. All other queries using the

    OLAP BADI should be checked case per case on potential reactivation of the OLAP cache!

  • 8/2/2019 How tocurrency conversion

    7/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    3 The Step by Step Solution

    The following high level implementation steps must be performed. Please find below the recommendedimplementation sequence (taking into account the dependent objects used in the different steps):

    1. Enhance or create InfoProvider with virtual characteristics

    2. Create a query and a characteristic value variable on the virtual characteristic

    3. Implement RSR_OLAP_BADI

    4. Implement variable exit RSR00001

    5. Define currency translation keys

    6. Implement the currency translation in your query

    This step-by-step solution explains how to implement this scenario for an InfoProvider of type InfoCube.

    The same implementation is possible for other InfoProvider types. Only information given in step 1 is

    InfoCube specific.

    Note: during the implementation of this scenario you will get transport dialog boxes at several times

    (e.g. during activation of objects). Our recommendation is to assign all objects created for this scenario

    to one transport request (reporting elements need to be collected and assigned to it manually)!

    1. Enhance or create InfoProvider with virtual characteristics

    1 . Createcharacteristic

    ZCURRDATE type

    date (Transaction

    RSD1)

  • 8/2/2019 How tocurrency conversion

    8/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    2 . Enhance / Create

    InfoCube with

    characteristic

    ZCURRDATE.

    (Transaction RSA1

    or RSDCUBE)

    This virtual

    characteristic is

    getting a value

    assigned at query

    runtime and must

    not be loaded with

    data. Therefore, no

    change to existing

    update rules is

    necessary !

    2. Create query

    1 . Create a Query in the

    Business Explorer

    Query Designer

  • 8/2/2019 How tocurrency conversion

    9/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    2 . Create Variable

    ZCURDAT

    - Characteristics value

    variable on

    characteristic

    ZCURRDATE

    - Variable contains

    single value, is

    processed by user

    entry and is

    mandatory

    - Put this variable in

    the filter area of the

    query!

    IMPORTANT NOTE:

    The last step (putting the variable in the filter area of the query) is mandatory, as theRSR_OLAP_BADI is not called if the virtual characteristic is not part of the query

    definition! This statement also applies when using the SAP enhancement RSR00002.

  • 8/2/2019 How tocurrency conversion

    10/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    3 . Implement RSR_OLAP_BADI

    Note: This BADI (only available with BW 3.x) can be used alternatively to the SAP Enhancement

    RSR00002 BW: Virtual characteristics and key figures in Reporting. Even if, in BW 3.x, both areavailable, we opted for this new implementation technique which has clear advantages regarding

    flexibility and usability.

    Means, if you want to downgrade this solution to BW 2.x, you need to implement step 3 with the SAP

    enhancement RSR0002 (same approach, but the coding not identical).

    1 . Create BADI

    Implementation

    ZCURRCONV based on

    Business Add-In

    RSR_OLAP_BADI(Transaction SE19).

    - Set Filter on InfoProvider

    or use Wildcard (p.eg.

    0SD*). This is very

    important to only execute

    the BADI for specific

    InfoProviders.

    - Copy sample code. This

    can be done in the menu:

    Goto Sample Code

    Copy. Please note that

    sample code can only be

    copied when Implemen-

    tation is inactive!

    Not copying the sample

    code will result in higher

    implementation effort on

    methods and class

    attributes!

  • 8/2/2019 How tocurrency conversion

    11/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    2 . Define attributes for

    generated class

    ZCL_IM_CURRCONV

    (Transaction SE24).

    - You can get the name of

    the generated class bylooking at the interface tab

    of your BADI

    Implementation in

    transaction SE19.

    - Create attribute P_CHA_ZCURRDATE (Level: Instance, Visibility: Public, Type I). This means defining a

    global variable representing InfoObject CURRDATE.

    - Create attribute CURRDATE (Level: Static, Visibility: Public, Type D). This attribute will be called from

    the variable exit to keep the date value entered in the variable screen of variable ZCURDAT.

    3 . Implement the DEFINE Method ofthe interface of the BADI

    Implementation ZCURRCONV

    (Transaction SE19 Interface

    double click on DEFINE method)

    - Please see appendix for the

    coding example

    - Another check on the InfoProvider

    can be implemented at this time

    (p.eg. if having worked with

    wildcards in the BADI

    Implementation)

    - Check on usage of characteristic

    ZCURRDATE at query definition

    time (CASE L_S_CHANM_USED).

    Only then ZCURRDATE will be

    declared as virtual characteristic

    and therefore computed during

    runtime.

    - Note that the DEFINE method is

    called at query generation time.

    Means, that the best way to debug

    it is to use transaction RSRT

    button Generate Report.

    - Please note: there is no need to

    change the INITIALIZE method.

    Declaration of global attributes for

    virtual characteristics (or key

    figures) has been done when

    maintaining the class attributes

    (see 3.2.)

  • 8/2/2019 How tocurrency conversion

    12/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    4 . Implement the COMPUTE method

    of the interface of the BADI

    Implementation ZCURRCONV

    (Transaction SE19 Interface

    double click on COMPUTE method)

    - Please see appendix for the

    coding example

    - The value of the global attribute

    CURRDATE is assigned to the

    virtual characteristc (represented by

    attribute P_CHA_ZCURRDATE)

    - Please remember that the filling of

    CURRDATE attribute with the

    variable value will be done in SAP

    enhancement RSR00001 (see next

    chapter)

    - Please note that the best way of

    debugging the COMPUTE method

    is to use transaction RSRT.

    3. Implement variable exit RSR00001

    1 . Implemement SAP Enhancement

    RSR00001 (transaction CMOD)

    - Create project (e.g. RSR00001)

    - Assign enhancement RSR00001

    to that project

    - Double click on

    EXIT_SAPLRRS0_001(Customer Exit Global Variables in

    Reporting)

    - Double click on include

    ZXRSRU01

    - Note that project needs to be

    activated after implementation of

    ZXRSRU01!

  • 8/2/2019 How tocurrency conversion

    13/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    2 . Write Include ZXRSRU01

    - Coding should only be used for

    specific InfoCube (IF i_s_rkbid-

    infocube )

    - Call exit for I_STEP =3, this

    means after variable entry

    - Read entered value for variable

    ZCURDAT (has been created in

    2.2) and assign it to class

    attribute CURRDATE (see 3.2)

    - the variable I_VNAM can not be

    used as it is not assigned for

    I_STEP = 3 !

    Please note that the best way of

    debugging this include is to use

    transaction RSRT.

    Additional information: At this stage syntax errors can occur (depending on implementation

    sequence) informing you that class ZCL_IM_CURRCONV is not defined. You then have to define

    the class in include ZXRSRTOP of function group XRSR (transaction SE80) using the following

    statement:

    CLASS ZCL_IM_CURRCONV DEFINITION LOAD.

    4. Define currency translation keys

    1 .Create translation keys(transaction RRC1)

    - Enter fix exchange rate type

    - Source currency: from data

    record

    - Target currency: Selection of

    target currency with

    translation. This enables you

    to enter the target currency in

    variable screen when

    executing the query.

    -Time reference: VariableTime Reference from Special

    InfoObject. The special

    InfoObject to enter is the

    virtual characteristic

    ZCURRDATE.

  • 8/2/2019 How tocurrency conversion

    14/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    5. Implement the currency translation in your query

    1 . Define currency

    translation in key figure

    - Define the currencytranslation in the

    properties of your

    selected key figure(s) by

    assigning the currency

    conversion key

    (ZCURRTK1).

    - Assign a fix target

    currency or create a

    variable for selecting the

    target currency at query

    runtime (optional)

    -In our example we use avariable ZCURTC (based

    on characteristic

    0CURRENCY) which

    can contain a single

    value, is processed by

    user entry and is

    mandatory.

    2 . (OPTIONAL) Use a text

    variable to display the

    currency conversion date

    in the column header

    - Create text variableZCURDT with

    replacement path for

    characteristic

    ZCURRDATE

  • 8/2/2019 How tocurrency conversion

    15/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    3 . Execute the Query

    Note that wrong or missing results at this point might occur due to missing exchange rates.

    Please check all exchange rate types, source currencies, target currencies and timereferences used in your scenarios on available exchange rates in table TCURR (Transaction

    SPRO SAP Reference IMG BW Customizing Implementation Guide General Settings Currencies Enter exchange rates).

  • 8/2/2019 How tocurrency conversion

    16/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    4 . (OPTIONAL)

    Duplicating this scenario (means creating the

    same set of objects several times) allows you to

    convert several key figures in one query to

    different target currencies for different time

    references. Note that the variable screen can bearranged in the query properties.

  • 8/2/2019 How tocurrency conversion

    17/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA, INC. AND SAP AG

    4 Appendix (Sample ABAP Coding)

    1. Coding for DEFINE Method of RSR_OLAP_BADI

    METHOD IF_EX_RSR_OLAP_BADI~DEFINE .

    DATA: l_s_chanm TYPE rrke_s_chanm,

    l_s_chanm_used TYPE rschanm,

    l_kyfnm TYPE rsd_kyfnm.

    FIELD-SYMBOLS:

    TYPE rrke_s_chanm.

    case i_s_rkb1d-infocube.

    when 'RHCURCON'.

    loop at i_th_chanm_used into l_s_chanm_used.

    case l_s_chanm_used.

    when 'ZCURRDATE'.

    l_s_chanm-chanm = 'ZCURRDATE'.

    l_s_chanm-mode = rrke_c_mode-no_selection.

    append l_s_chanm to c_t_chanm.

    when others.

    endcase.

    endloop.

    endcase.

    ENDMETHOD. "if_ex_rsr_olap_badi~define

    2. Coding for COMPUTE Method of RSR_OLAP_BADI

    METHOD IF_EX_RSR_OLAP_BADI~COMPUTE .

    field-symbols: type d.

    if not p_cha_zcurrdate is initial.

    assign component p_cha_zcurrdate of structure c_s_data to .

    = currdate.

    endif.

    ENDMETHOD. "IF_EX_RSR_OLAP_BADI~COMPUTE

  • 8/2/2019 How tocurrency conversion

    18/18

    HOW TO USE VARIABLE TIME REFERENCES IN CURRENCY CONVERSIONS

    2003 SAP AMERICA INC AND SAP AG

    3. Coding for include ZXRSRU01 of SAP enhancement RSR00001

    DATA: l_s_var_range TYPE rrs0_s_var_range.

    IF i_s_rkb1d-infocube EQ 'RHCURCON'.

    IF i_step = '3'.

    LOOP AT i_t_var_range INTO l_s_var_range WHERE vnam EQ 'ZCURDAT'.

    ZCL_IM_CURRCONV=>currdate = l_s_var_range-low.

    ENDLOOP.

    ENDIF.

    ENDIF.