What is Virtual Key Figure ?

Hello,
I would like to know about Virtual Key Figure. What is Virtual Key Figure ? How to we created ? what is use of Virtual Key Figure?
Thank you
Anup G shah

Hi,
As every one mentioned that Virtual key figure are those KF's whose values are filled at run time.
You can write customer exits to fill values of those Kf's in SAP Enhancement RSR00002.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/59069d90-0201-0010-fd81-d5e11994d8b5#search=%22SAP%20Customer%20Exit%20virtual%20key%20figure%22
http://www.bwexpertonline.com/downloads/Nissen.doc
http://help.sap.com/saphelp_nw2004s/helpdata/en/ac/ef1f43daac9a448f0150a02e3a7aba/content.htm
Please rewad if it helps.

Similar Messages

  • BW : Virtual key figures

    Hii  experts  ,
    What are virtual key figures .
    Plz explain .
    Thanks & regards ,
    Madhavi S Bichakal

    Dear Madhavi,
    Virtual Key figure
    virtual key figures are key figures within an InfoProvider that are not filled with data. Instead the key figure value is determined at runtime of the query using custom ABAP coding .
    this keyfigure is not populated with the data by using update rules. but this virtual keyfigures will detemine the value only at the runtime of the query.
    nomally when we store the key figure value in the cube as we do it for a normnal keyfigure it gives us the fact(Fixed truth ) information but by using virtual keyfigures we can show the present truth in the report.
    for example :- let say we have a transaction on 01/01/2007 for material M100 @ price of 100 and on 02/01/2007 the price of material M100 has changed to 200.
    when we store price as a normal keyfigure in the cube it will give fact i.e, 100
    but if we design the price as a virtual keyfigure it will give out present truth as 200.
    Virtual characteristics and Key figures are useful if you want to dynamically pouplate data from the fact table to the field which doesn't have any data in the fact table and also used to build an internal security model before the data gets passed to DATA_PROVIDER.
    You can get more information if you review the documentation for enhancement RSR00002.Go to SMOD type in RSR00002 and select the documentation radiobutton..
    Some ABAB coding samples:
    Virtual Characterstics & Key Figures
    Virtual Characteristic problem
    how to read characteristic variable value into virtual characteristic
    How to implement Virtual Characteristics or Virtual key figures
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/59069d90-0201-0010-fd81-d5e11994d8b5#search=%22SAP%20Customer%20Exit%20virtual%20key%20figure%22
    For more info
    You can go through the following links.
    Virtual Key Figures
    sampel code for virtual key figures
    Virtual Key Figure - ZXRSRU02
    Virtual Keyfigures and Characterisitics
    How to implement Virtual Characteristics or Virtual key figures
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/biw/g-i/how%20to%20use%20variable%20time%20references%20in%20currency%20conversion
    Search for the keyword virtual keyfigure in the following link :
    https://www.sdn.sap.com/sdn/developerareas/bi.sdn?page=BW_How_To.htm
    Creating Virtual keyfigures
    you create virtual keyfigure just like create normal keyfigure (RSD2),
    populate not via transformation/transfer/update rules, but when query execution via user exit, take a look
    Virtual Characteristic problem
    virtual key figure
    http://www.bwexpertonline.com/downloads/Nissen.doc
    Also
    How to implement Virtual Characteristics or Virtual key figures
    Check post by Sree Rama Tata 
    Hope it helps
    Regards
    Bala

  • Virtual Key figures and Chars

    Can someone explain me what are virtual key figures and how to populate data for them.
    Regards
    Kunal

    AHP,
    Thanks for the help, one last question, i posted same on sdn week back, there was no proper response. I have standard LO datasource and enhanced with around 25 fields, the major problem is none of these fields are delta capable and they are coming from 13 diff tables, with great difficulty i could tie the relation between them. Most of the fields change and none them are picked,
    is there anyway i can write a program for all this fields for delta enabling. The last option which iam left is to load the data every week as full load though data volume is less, which is not practiced.
    Regards
    Kunal

  • Virtual key figures problem?

    Hi Gurus,
    what is Virtual key figures? at what scenerio you go for that.
    please guide me ASAP.
    In advance i appreciate you
    RK

    Hi
    Virtual key figures are used when you want to determine the value of a key figure at runtime , the key figure is not populated in the load process ie its value is not stored in the cube. The logic for populating the keyfigures is written in an SAP Exit RSR00002.
    Since the values are computed at run time, it affects the query performance if you have too many VKF or too many records in your cube.
    There is a how to guide on the steps for working with virual key figures/ characteristics.
    To give an example suppose you need an aging report where you want to show how many orders are delayed by 30 days , how many 30 to 60 days and so on based on todays date, So this number needs to change dynamically based on the date the report is run , you could use VKF in this scenario...There might be other ways of doing but just giving an example to explain the concept.

  • Type conflict with ASSIGN in BADI for Virtual Key Figures

    We get the below error dump in ST22 when executing BEx queries that contain virtual key figures.
    error message - 'Type conflict with ASSIGN in
    program "ZCL_IM_THR_RSR_OLAP_BADI======CP".'
    We have a BADI implementation that calculates few virtual key figures included in some infocubes & multiproviders. The error would arise if we execute two queries (containing common Virtual Key figures) one after the other without closing the first query.
    We found a note "Note 1237689 - Virtual chars. and key figures in input-ready querys" that could be relevant to our issue and wanted to apply this note but unfortunately the note is only applicable to SAPKW70016 to SAPKW70018 and we are support pack 15.
    Can you please advise what the problem could be/suggest corrections for the same.

    Hi Kulmohan,
    Did you fix your issue? We are facing the same issue. Could you please let me know if you have any solution for this issue,
    Thank you,
    Mike

  • Virtual Key Figure

    Hi all,
    Before implementing a virtual key figure, I'd like to make sure this will answer my need. I work for a brewery, and I am looking at our customer taps activity.
    Records in the cube:
    Trading Region A, Brand X, Customer 001, Action "Install": 1 "Tap action"
    Trading Region A, Brand X, Customer 002, Action "Install": 2 "Tap action" (<i>new taps</i>)
    Trading Region A, Brand X, Customer 002, Action "Removal": 1 "Tap action" (<i>old tap</i>)
    So what I want to have in my report is :
    Trading Region A Brand X: 2 "customer activity"
    I am thinking I could use a virtual key figure that will look in the cube and check if there was any activity for a customer on that brand and trading region, and then will allow me to aggregate the result in the query.
    But I am not sure because it seems to me that Virtual Key Figure are calculated at record level...
    Could any of you clarify this for me ?
    Many thanks for your help,
    Nicolas

    Thanks a lot !
    I don't know why I tried such a complicated solution...
    Tried to assign points and close the issue, let me know if it didn't work as this is my first post...

  • Problem with virtual Key Figure in a query

    Hi Experts,
    I would like to share my problem with the virtual key figure in a query:
    I have a query with a virtual key figure and when I eject the query by analyzer, the result sometimes is displayed and sometimes is not displayed (is equal to 0), with the same initials values. And when I eject the query by RSRT always display the result for the virtual key figure.
    Why don't always display the result?
    Thanks a lot

    Hi,
    I think that the problem is the level of support package. We have BI AddOn 7.X (based on 7.20) support package 0.
    What do you think?
    Regards

  • Problems with creating badi implementation for virtual key figures

    Hi,
    I'm running BI 7.0 (unicode).
    I have been trying to follow this blog to calculate the virtual keyfigure in my infoset - Using Virtual Key Figure and Characteris in an InfoSet
    My infoset includes 1 infocube, and 3 master data infoobjects. I have created everything the blog was referring to, and activated fine. However, it seems that when the field symbols are assigned from the c_s_data structure, they do not get referenced correctly, so that no correct memory area is assigned and instead the whole c_s_data structure is assigned to the field symbol, which prevents me from referencing the right mem area correctly.
    For example, in this statement
    ASSIGN COMPONENT P_CHA_ZMYINFOSET___F120 OF STRUCTURE c_s_data
                                                                           TO  <fs_ZMYINFOSET___F120>.
    the component p_cha_zmyinfoset___F120 of c_s_data supposed to be assigned to the field symbol (point to the correct place in structure c_s_data). In other words when this statement is executed, the program looks at structure c_s_data, finds the component zmyinfoset___F120 in it, and assignes the position of that component in the structure to the field symbol, so that it could be referenced in the code. However, the correct assignment does not happen.
    When I debug the code and view the structure c_s_data, I can never find any component with any of the names I can find in my BEX query like ZMYINFOSET___F120. All I see are the components that are named like these: Z____5179 (C_S_DATA-Z____5179), C_S_DATA-S____5150, etc. I see the correct values, but components all have weired names like that. I thought in Infosets the components are named in the following fashion: INFOSETNAME___FXXX which you can see from your BEX query designer. Why is this happening? Why don't I see the correct names in the c_s_data structure? If instead I try to assign those components with their weired names directly, I still get incorrect assignment.
    what am I doing wrong?
    I was reading abap help on this statement:  assign COMPONENT comp OF STRUCTURE struc
    and the following I found:
    With this expression for mem_area, the memory area of a component comp of a structure struc is assigned to the field symbol. While the structure struc is specified directly, a data object must be specified for comp. The evaluation depends on the data type of comp:
    If the field comp has a non-text, elementary type, the content is converted to the type i and interpreted as a position of the component in the structure. if the value for comp is 0, the storage area of the entire structure is assigned to the field symbol.
    From what it says above, my value for comp is always 0, so that the entire structure is always assigned to my field symbol instead of a specific position in that structure.
    please let me know what is wrong here.
    thanks.
    Edited by: AG on Oct 11, 2008 10:41 AM
    Edited by: AG on Oct 11, 2008 10:42 AM

    Hi,
    I am facing the similar issue. Can you please tell me how you solved this problem in more details?
    which sample code and how u can find that in SE24 and where to copy that code.
    Thanks in advance..
    vamsi.

  • Virtual Key Figures - Field Symbol

    Dear guru's,
       We had obtained an ABAP error in the execution of a query when obtaining a virtual key figure. We analyzed the problem and identified the error. We fixed it in our dev system and tested ok.We then transported the includes ZXRSRU02, ZXRSRTOP, ZXRSRZZZ to our quality system and the problem persisted. The error occurs because the structure c_s_data has not updated to include the added object and therefore assigns the structure to the field symbol and not its value.
       I have checked the versions of these includes and they are identical. What could be the possible causes for this problem and solutions?
    Thanks and Kind Regards,
    Alex

    We transfered many times the corrected code and still the probem persisted. If my understanding is correct the structure c_s_data is created by BW according to the appends you make in the code (...RU02).
    The problem was resolved when we regenrated the queries. If anyone can explain why this is so, please let me know so that I may have a better understanding of this process.
    Thanks and Kind Regards,
    Alex

  • Virtual Key Figure ( Currency Problem)

    Hi All,
    I am facing one problem in virtual key figure using BADI. Need your help...
    Scenario: I have a DSO with all many fields. Requirement is to add one more VKF in DSO to get specific period balance of a GL from 0FIGL_O10 DSO and then display it as a column in Bex report. Added VKF is of type amount and unit/currency 0CURRENCY.
    Required Report Format:
    Material --- Col1 u2013 Col2 u2013 Col3(VKF)
    M1--$4, 00-$140, 00u2014<Balance form 0FIGL_O10 for a period>
    Work done so far:
    I have added a virtual key figure ZVKF_BAL in my ZSD_O06 of type amount unit/currency as 0CURRENCY. In RSR_OLAP_BADI I have added a new implementation ZVAR_IMPL.
    In class ZCL_IM_VAR_IMPL there are total three attributes.
    P_KYF_ZVKF_GL u2013 Virtual key figure
    P_CHA_0FISCPER u2013 Period is from ZSD_O06 for which we have to get the balance of a fixed GL account from 0FIGL_O10.
    Given is the code added in define method:
    DATA: l_s_chanm TYPE rrke_s_chanm,
            l_kyfnm TYPE rsd_kyfnm.
      FIELD-SYMBOLS:
            <l_s_chanm> TYPE rrke_s_chanm.
      CASE i_s_rkb1d-infocube.
      WHEN 'ZSD_O06'.
        l_s_chanm-chanm = '0FISCPER'.
        l_s_chanm-mode = rrke_c_mode-read.
        APPEND l_s_chanm TO c_t_chanm.
        APPEND 'ZVKF_GL' TO c_t_kyfnm.
      ENDCASE.
    No code added in initialize method
    Given is the code added in compute method:
    FIELD-SYMBOLS <fs_ZVKF_GL> TYPE ANY.
    FIELD-SYMBOLS <fs_0FISCPER> TYPE ANY.
    DATA :LV_FS_ZVKF_GL TYPE /BI0/OIBALANCE,  
    p_cha_0FISCPER = 8.  "ASSINGING POSITIONS TO THE FIELD AS THEY ARE NOT GETTING IT
    p_kyf_ZVKF_GL = 16.
    ASSIGN COMPONENT p_kyf_ZVKF_GL OF STRUCTURE c_s_data
                TO <fs_ZVKF_GL> .
    ASSIGN COMPONENT p_cha_0FISCPER OF STRUCTURE c_s_data
                TO <fs_0FISCPER>.
    Customized function module which will calculate the GL Balance.
      CALL FUNCTION 'ZGLBALANCE'
        EXPORTING
         FISCPER_I    = <fs_0FISCPER>
         GL_ACCOUNT_I = '0000476000'
        IMPORTING
          BALANCE_O    = LV_FS_ZVKF_GL.
    <fs_ZVKF_GL> = LV_FS_ZVKF_GL.
    Code of ZGLBALANCE:
    DATA: lv0_fiscal type /BI0/OIFISCPER.
    DATA :  X TYPE I VALUE 0,
    types: BEGIN OF ty_/BI0/AFIGL_O1000,
           FISCPER type /BI0/OIFISCPER,
           GL_ACCOUNT type /BI0/OIGL_ACCOUNT,
           BALANCE type /BI0/OIBALANCE,
           CURRENCY TYPE /BI0/OICURRENCY,
            END OF ty_/BI0/AFIGL_O1000.
    data: it_/BI0/AFIGL_O1000 type TABLE OF ty_/BI0/AFIGL_O1000, " Internal table
          wa_/BI0/AFIGL_O1000 type ty_/BI0/AFIGL_O1000.          " Work area
    select single FISCPER GL_ACCOUNT BALANCE CURRENCY from /BI0/AFIGL_O1000 into CORRESPONDING FIELDS OF TABLE it_/BI0/AFIGL_O1000 where GL_ACCOUNT eq GL_ACCOUNT_I and FISCPER eq FISCPER_I and CURRENCY = 'USD'.
    BALANCE_O = X .
    Problem:
    We are getting the balance values but it is coming with numeral with postfix ERROR.
    M1--$4, 00-$140, 00u201412,00 ERROR
    M2--$24, 00-$130, 00u201414,00 ERROR
    Is it something to do with currency? Please let us know what is worng in code?
    If yes please let me know how to get the currency along with the numeric values there in the report.
    Thanks & Regards,
    Mayank

    Hello mayankmishra135,
    Were you able to find a solution for this? I am facing the same issue (with the ERROR in the currency field), wuold appreciate your help.
    Best regards,
    Aleksander Dyl

  • Virtual Key Figure - Cumulation

    Hi all,
    I am trying to cumulate a virtual key figure for all fiscal periods one by one but I want to sort the Fiscal periods in the badi RSR_OLAP_BADI as if the fiscal periods are not sorted then the cumulation does not happen correctly.Could anybody please guide how to access the entire data set of the query in the badi COMPUTE method...What I am getting is only a record by record access in the method.
    Rgds
    Amit

    While Generating the Query it goes to the Break Point , but not where key figure is getting calculated.
    But after that if i execute Query still its teh same

  • Virtual Key figure not getting populated

    Hi All,
    I have included a virtual key figure in a multiprovider  on which the query is created and its underlying ODS.
    This issue is the virtual key figure is not getting populated . I am not sure what I am missing
    I did the following :
    1) Tried Debugging - Put a break point and execute the query in RSRT.It  did not go to the Exit. I also tried  generating the query from RSRT.
    I am using the BADI (RSR_OLAP_BADI) to populate the Vir Key Fig.
    Please guide me.
    Thanks,
    HM

    Hi All,
    Now that I am able to get the logic to come up in debug. I am faced with another issue.
    I am implementing  avery simple logic . I added a integer type key figure to the ODS and I am tryin to assign value 1 to the the key figure in the code (I am assigning 1 just ot check if the value is passed to query or not. I do have acomplex logic tha i need to implement).
    Here I am able ot see the value in the debug but in the qury the value is not populated.
    N ot sure what might be going wrong.
    code is
    l_z_avg = 1.
    <fs_zavglate> = l_z_avg .
    Appreciate help.
    Thanks,
    HM

  • Virtual key figure BADI - does not change value

    I wrote a badi for virtual key figure according to guidelines from an SDN doc on how to create virtual chars and kf's.
    However, the value of the key figure is not changed at all. Below is my code. Please see what I'm doing wrong
    method IF_EX_RSR_OLAP_BADI~DEFINE.
       APPEND 'ZRANKS' TO c_t_kyfnm.
    endmethod.
    method IF_EX_RSR_OLAP_BADI~COMPUTE.
      if P_KYF_ZRANKS > 0.
        assign component p_kyf_zranks of structure c_s_data
        to <fs_ranks>.
        <fs_ranks> = '1.0'.
      endif.
    endmethod.

    There is something you need to do which I have not seen described in any of the documention here.
    You need to copy the source code for the INITIALIZE method directly from the code given in the example class CL_EXM_IM_RSR_OLAP_BAPI. That is where the P_KYF<object> and P_CHA<object> attributes are assigned their values. If you do not copy this code into your own implementation, these attributes have no value in the COMPUTE method and your code will probably not work.
    Bryan

  • Help needed for Virtual Key Figure BADI

    I am trying to implement Virtual Key Figures via BADI.
    Here is what I have done
    Define Method
    method IF_EX_RSR_OLAP_BADI~DEFINE.
    DATA: l_s_chanm TYPE rrke_s_chanm,
    l_kyfnm TYPE rsd_kyfnm.
    FIELD-SYMBOLS:
    <l_s_chanm> TYPE rrke_s_chanm.
    Insert Code
    CASE i_s_rkb1d-infocube.
    WHEN 'ZMCOPA_02'.
      l_s_chanm-chanm = '0CUSTOMER'.
      l_s_chanm-mode = rrke_c_mode-read.
      APPEND l_s_chanm TO c_t_chanm.
      APPEND 'ZCPRC_FLG' TO c_t_kyfnm.
      APPEND 'ZRTNS_PRC' TO c_t_kyfnm.
    ENDCASE.
    ENDMETHOD. "if_ex_rsr_olap_badi~define
    Compute Method
    method IF_EX_RSR_OLAP_BADI~COMPUTE.
    FIELD-SYMBOLS <fs_ZRTNS_PRC> TYPE ANY.
    FIELD-SYMBOLS <fs_ZCPRC_FLG> TYPE ANY.
    FIELD-SYMBOLS <fs_0customer> TYPE ANY.
    DATA: l_zv_20dv TYPE curr09.
    ASSIGN COMPONENT p_kyf_ZRTNS_PRC OF STRUCTURE c_s_data
    TO <fs_ZCPRC_FLG>.
    ASSIGN COMPONENT p_kyf_ZCPRC_FLG OF STRUCTURE c_s_data
    TO <fs_ZCPRC_FLG>.
    ASSIGN COMPONENT p_cha_0customer OF STRUCTURE c_s_data
    TO <fs_0customer>.
      DATA: l_zrtns_prc TYPE /bic/pzcust_prc-/BIC/ZRTNS_PRC.
      DATA: lt_zcust_prc TYPE TABLE OF /bic/pzcust_prc.
      DATA: ls_zcust_prc TYPE /bic/pzcust_prc.
      IF NOT p_cha_0customer IS INITIAL.
      <fs_0customer> =
      ENDIF.
    SELECT SINGLE *
      INTO ls_zcust_prc
      FROM /bic/pzcust_prc
      WHERE /bic/zcust_prc = <fs_0customer>.
    IF sy-subrc = 0.
      <fs_ZCPRC_FLG> = 1.
      <fs_ZRTNS_PRC> = ls_zcust_prc-/BIC/ZRTNS_PRC.
    ELSE.
      <fs_ZCPRC_FLG> = 0.
      <fs_ZRTNS_PRC> = 0.
    ENDIF.
    endmethod.
    I have commented out line in the Compute method because I was getting an error on my SELECT statement.  I think the error is due to the fact that <fs_0customer> is not being populated.
    In debug mode, p_kyf_ZRTNS_PRC, p_kyf_ZCPRC_FLG and p_cha_0customer all return 0.  Shouldn't they have a different value.  I have to admit that I don't really understand how ASSIGN COMPONENT works.
    I have defined p_kyf_ZRTNS_PRC, p_kyf_ZCPRC_FLG and p_cha_0customer in the Attribute tab.
    Any help would be appreciated.  I have spent several hours trying to figure out how this works.
    Thanks.
    Ryan

    Check this if it helps:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e051fda8-71a9-2a10-ac9e-8d17414a8c8c

  • Virtual Key Figure in report giving  values

    Hi Gurus,
    I have created a Virtual Key Figure on a Multi Provide and completed all necessary user-exit coding.
    When I run the BEX report for a single material my Key Figure is populating correct values.
    But when I run the BEX report for multiple material and if the key figure value is zero it is putting  star and due this my result is giving me the wrong value.
    Please suggest me what I need to do to correct this.
    Thanks,
    Saleem.

    Hi,
    Thank you for your responace.
    But still i am getting the same error. While displaying on BEX report some rows showing * and some rows showing ERROR after the value.
    Please advice me .
    Thanks,
    Saleem.

Maybe you are looking for