Assigning variable values in the virtual key figures Badi
Hi,
I'm currently using the virtual chars and key figures RSR_OLAP_BADI to calculate days late as 0NETDUEDATE - sy-datum. This works fine, but the query actually uses variable 0P_KEYDT to determine the key date (set in restricted key figures so not directly).
I want to use this key date variable value rather than the system date to calculate Days Late in the CALCULATE method of the Badi. In the old user exits I could have retrieved the value from internal table i_t_var_range in the variables user exit ZXRSRU01 and stored it globally.
Does anyone know how to get a query variable value within the RSR_OLAP_BADI Badi? I've tried using BAPI_REPPROV_GETVARIABLES but don't know how to pick up the session id to make it work. Is there a BADI equivalent of EXIT_SAPLRRS0_001?
I'm sure one of you out there has the answer!
Thanks,
Stuart
Hi József
Yes I have, I think using SAP's white paper on virtual characteristics and key figures.
My only outstanding question would be: is there a replacement BADI for the variables user exit and if not why not, since BADIs are supposed to be the preferred way now?
Similar Messages
-
Using Variable values to populate virtual key figure
Hi Gurus,
I want to populate virtual key figure in my report. I am using BADI for this. To populte VKF I want to use the variable values in my calculation. For eg. variable name is ZCAL_MON based on 0CALMONTH. When the user enters some value in this variable say 03.2010 I want to populate VKF for the last 12 months (sum for a period 04.2008 to 03.2009). I have written a customer exit in CMOD for variables but for vkf I am using BADI. Can anyone tell me how do I pass the variable value in populating vkf and also how do I total for the last 12 months?
UtpalHi,
Did you find a solution. I'm just looking for the same thing.
best regards.. -
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 -
Do we write variable customer exits for virtual key figures in Bex?
Hi all,
Am I thinking the right here " We write variable customer exits in CMOD for virtual key figures in BEx " or am I totally wrong. If thats the case where do we write it.
Thanks,
JBNevermind
-
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.
RyanCheck this if it helps:
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e051fda8-71a9-2a10-ac9e-8d17414a8c8c -
Virtual Key Figures - How are they triggered?
HI,
I am trying to implement the Virtual Key Figure user-exit. I have created all the necessary coding and activated the user-exit.
My cube contains data but the VKF in question has not been populated with any data because I have set the update rules to "NO UPDATE", so the VKF is completly empty.
I've defined my query to use the VKF, but when I execute it, the user-exit is not triggered.
<b>How does BW determine if a query should call the user-exit?</b> I though it was to do with creating the variables in ZXRSTOP in line with the cube/kf name as I have done (<b>DATA: g_pos_0IC_C03_zfcstwk TYPE i.</b>).
I'm using BW 3.5 by the way if this makes any difference.
Here is the code I have created in the various includes:
<u><b>ZXRSTOP</b></u>:
* INCLUDE ZXRSRTOP *
DATA g_pos_0ic_c03_fcstwk.
**Global fields for virtual characteristics - *
DATA: g_pos_0IC_C03_0plant TYPE i.
DATA: g_pos_0IC_C03_0material TYPE i.
DATA: g_pos_0IC_C03_0calday TYPE i.
DATA: g_pos_0IC_C03_zfcstwk TYPE i.
* End Program ZXRSRTOP *
<u><b>ZXRSRZZZ</b></u>:
* Includes for specific subroutines for each avriable
Include: zxrsrf01, "Common Subroutines
zxrsrf02, "Fiscal Period / Year Variables
" zxrsrf05, "Fill selections from Variable value table
zxrsrf04. "Fill virtual chars + KF
FORM USER_0IC_C03 USING i_s_rkb1d TYPE rsr_s_rkb1d
CHANGING c_s_data TYPE any.
DATA: lsgid LIKE i_s_rkb1d-genuniid. "query ID
* Define ODS temp table
DATA: l_zic_forc_itab LIKE STANDARD TABLE OF /bic/azic_forc00.
* Define cooresponding work area
DATA: l_zic_forc_wa LIKE /bic/azic_forc00.
* field symbols definitions
FIELD-SYMBOLS <l_plant>.
FIELD-SYMBOLS <l_material>.
FIELD-SYMBOLS <l_calday>.
FIELD-SYMBOLS <l_zfcstwk>.
CASE i_s_rkb1d-infocube.
WHEN '0IC_C03'.
* Which Query are we deriving for ?.
CASE i_s_rkb1d-compid.
WHEN 'Z0IC_STKVAL' OR
'Z0I_EXP_DAT' OR
'Z0IC_PCM_STKVAL'.
* Assign object values to field symbols
ASSIGN COMPONENT g_pos_0ic_c03_0plant
OF STRUCTURE c_s_data TO <l_plant>.
ASSIGN COMPONENT g_pos_0ic_c03_0material
OF STRUCTURE c_s_data TO <l_material>.
ASSIGN COMPONENT g_pos_0ic_c03_0calday
OF STRUCTURE c_s_data TO <L_CALDAY>.
ASSIGN COMPONENT g_pos_0ic_c03_zfcstwk
OF STRUCTURE c_s_data TO <l_zfcstwk>.
SELECT * INTO TABLE l_zic_forc_itab
FROM /bic/azic_forc00
WHERE material = <l_material>
AND plant = <l_plant>.
IF sy-subrc NE 0.
* no sort required
ELSE.
* Fill the VKF by reading the itab and locating the first record that exists >= 0calday
SORT l_zic_forc_itab BY calday ASCENDING.
LOOP AT l_zic_forc_itab INTO l_zic_forc_wa
WHERE calday <= <l_calday>.
IF sy-subrc EQ 0.
<l_zfcstwk> = ''.
ELSE.
<l_zfcstwk> = l_zic_forc_wa-/bic/zfcstwk.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ENDCASE.
ENDCASE.
ENDFORM. "user_0IC_C03
* End Program ZXRSRZZZ *
<u><b>ZXRSRU02</b></u>:
* ZXRSRU02 Exits for Virtual chars and Key Figs *
DATA: l_s_chanm TYPE rrke_s_chanm.
DATA: l_s_kyfnm TYPE rsd_kyfnm.
* Which cube are we deriving for ?.
DATA: l_stop(1) TYPE c VALUE 'Y'.
WHILE l_stop = 'Y'.
ENDWHILE.
CASE i_s_rkb1d-infocube.
WHEN '0IC_C03'.
* Which Query are we deriving for ?.
CASE i_s_rkb1d-compid.
WHEN 'Z0IC_STKVAL' OR
'Z0I_EXP_DAT' OR
'Z0IC_PCM_STKVAL'.
* set up the chars to be used or abused. (based on mode)
l_s_chanm-chanm = '0MATERIAL'.
l_s_chanm-mode = rrke_c_mode-read.
APPEND l_s_chanm TO e_t_chanm.
l_s_chanm-chanm = '0PLANT'.
l_s_chanm-mode = rrke_c_mode-read.
APPEND l_s_chanm TO e_t_chanm.
l_s_chanm-chanm = '0CALDAY'.
l_s_chanm-mode = rrke_c_mode-read.
APPEND l_s_chanm TO e_t_chanm.
l_s_kyfnm = 'ZFCSTWK'.
APPEND l_s_kyfnm TO e_t_kyfnm.
ENDCASE.
ENDCASE.
* End Program ZXRSRU02 *hi Peter,
try to check with RSRT, put in your query technical name,
and click 'technical information', check info on 'virtual char/keyfigures', it should have 'Y' and a list of virtual char/kf. and also check 'execute+debug', mark checkbox 'display sql', after that check the sql statement if your virtual kf is in select statement.
try in RSRT menu 'environment'->delete old abaps.
if you want the virtual kf only run for certain query,
you can restrict in ZXRSRZZZ, using
if I_S_RKB1D-compid = 'your query technical name'.
... your logic for virtual kf ...
endif.
hope this helps. -
Virtual Key Figures its not populated when execute query
Hi All
I did a BADI for populate a Virtual Key Figure, I follow the instructions of link
Link:[http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60e34f63-f44c-2c10-488e-c89b04e0ca7c?quicklink=index&overridelayout=true]
In addition I add the code section of data declarated on example of: CL_EXM_IM_RSR_OLAP_BADI section define: IF_EX_RSR_OLAP_BADI~DEFINE, only information that said:
DATA: l_s_chanm TYPE rrke_s_chanm,
l_kyfnm TYPE rsd_kyfnm.
FIELD-SYMBOLS:
<l_s_chanm> TYPE rrke_s_chanm.
I test the query on RSRT and the virtual Key Figure is "0.00" this look like if the virtual key figure is not populated.
I did other things like:
Set a Break Point on COMPUTE section of my BADI, I saw that the value is assigned, but I don't know how I can continue reviewing the pass of this value to result of query.
I generate again the query on RSRT.
My code is:
IF_EX_RSR_OLAP_BADI~DEFINE
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.
case I_S_RKB1D-INFOCUBE.
when 'ZGTO_OB2'.
append 'ZVIRTKF' to C_T_KYFNM.
endcase.
endmethod.
IF_EX_RSR_OLAP_BADI~COMPUTE
method IF_EX_RSR_OLAP_BADI~COMPUTE.
field-symbols <FS_ZVIRTKF> type any.
P_KYF_ZVIRTKF = 16.
assign component P_KYF_ZVIRTKF of structure C_S_DATA
to <FS_ZVIRTKF>.
<FS_ZVIRTKF> = 10 .
endmethod.
I will appreciate your recommendations, Thanks in advanced.
AlThank you very much Sanganya
I saw this:
I put a break point on P_KYF_ZVIRTKF = 16., then I saw that P_KYF_ZVIRTKF obtain value 16.
Then on sentence: assign component P_KYF_ZVIRTKF of structure C_S_DATA
to <FS_ZVIRTKF> , when the system pass this line, I review the sy-subrc and is equal 4, as I understood the ASSIGN sentence did not be complete, the value shoul be 0.
Then when the system try to run the sentence: <FS_ZVIRTKF> = 10 the system send an Execution error that say: GETWA_NOT_ASSIGNED...
Error analysis
You attempted to access an unassigned field symbol
(data segment 32780).
This error may occur if
- You address a typed field symbol before it has been set with
ASSIGN
- You address a field symbol that pointed to the line of an
internal table that was deleted
- You address a field symbol that was previously reset using
UNASSIGN or that pointed to a local field that no
longer exists
- You address a global function interface, although the
respective function module is not active - that is, is
not in the list of active calls. The list of active calls
can be taken from this short dump.
Exactly the line selected with error is:
>>>> <fs_zvirtkf> = '10.0'.
I will appreciate your help
Thank you
Al -
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,
HMHi 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 -
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 lotHi,
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 -
Virtual Key Figures in RSR_OLAP_BADI not re-calculated correctly
Hello BW/BI Experts!
Please clarify why is the COMPUTE METHOD of RSR_OLAP_BADI not triggered or executed
if you remove a drilldown to a certain characteristic.
For instance, my query is drilled down by customer and material by default. Upon
opening the query and after entering the appropriate selections, the virtual key figures
that I have used in the query are correct .
However, if you remove the drilldown by customer(for example), the virtual key figure
is not re-computed. I was able to verify this by setting break-point in the COMPUTE
method. However, if you drilldown by customer again, the re-calculation for the virtual
key figure is correct likewise, if you refresh query, the results will be correct.
Is this really the normal behavior of the said BADI? Why is it unstable? If I will
use RSR00002(the user exit version), will I not have the same issue?
Thanks in Advance!If I will use RSR00002(the user exit version), will I not have the same issue?
I dont see any reason why this wouldnt behave the same way.
I assume from ur post that you need to read ur customer and material to derive ur virtual KF in the BAdi. When you remove the drilldown the customer value is no more available for the exit to calculate the KF, thats when it throws out a wrong number. I havent seen a work around for this. Please update the form if you find a solution to get the customer values into the exit even after removing the drill down. -
Virtual Key Figures in RSR_OLAP_BADI COMPUTE Method not recalculated
Hi,
Please clarify why is the COMPUTE METHOD of RSR_OLAP_BADI not always
triggered or executed.
For instance, my query is drilled down by customer and
material by default. Upon opening the query and after entering
the appropriate selections, the virtual key figures that I have
used in the query are correct .
However, if i make any change to the query and run it in RSRT, the BADi method COMPUTE is not executed.
Is this really the normal behavior of the said BADI? Why is
it unstable?Hi Rohit,
I have a similar problem the compute method is not trigerring and i am trying to debug it but it is not breaking at all, although when i generate from rsrt it breaks at a breakpoint of define method however i have defined another break at compute method but not breaking.
I am using the infoobject inside the query but and tried to hard code it for testing in the compute method but doesnt seem to be getting executed.
Please help.
Cheers,
Jad -
Hi All,
I have created a Virtual Key Figure : "Product Price (ZPRICE)", this infoobject has 0CURRENCY associated.
My question is : Do i have to populated 0CURRENCY in the Virtual Key Figure Logic?
Please, i will appreciate a quick example of Virtual Key Figure with currency object associated.
THANKS IN ADVANCEDHi,
Do you have any other key figure exists in data target with reference 0currency? If yes then no need to populate it.
Thanks. -
Customer Ext Variable is NOT working correctly in the Restricted Key Figure
Hi all,
I have created a variable ZVCBLMTH (Period from 01/1996 to Last Month) with reference to
0CALMONTH and it will be populated through Customer Exit and it works fine.
In the selection for 0CALMONTH, I gave the range as '05/2008' to '08/2008' and this new
variable passed the value of range as '01/1996' to '04/2008' in RSRT.
The properties of the variable are:
Type of Variable - Characteristic, Processing by - Customer Exit, Variable Represents - Interval
and Variable is - Optional.
No change in the result after changing the 'Variable is' from Optional to 'Mandatory'.
This variable is used in Restricted Key Figure to calculate the number of matching records between
01/1996 & 04/2008 and somehow it is not recognizing this variable and NOT passing the results correctly.
But, there are records with 0CALMONTH between 01/1996 & 04/2008.
How could I test that which value is passed into the Restricted Key Figure for this variable, PLEASE ?
Thanks in advance.
Regards,
Venkat.Hi Clemens Li
I agreed on your point. When we define the Internal table the type for element EQUNR & QUMNR , we are referring the SAP data element for EQUNR, QMNUM field.
Our doubt is even though we refer the standard data element, in the ALV display, it shows with leading zeros and also it creates problems in the filtering and in the filter window all values instead of unique nos.
Hi Abhii
I have given below the fieldcat coding.
Friends, can you kindly clarify the above said problems. Since we use SAP ECC 6.0 any notes or patches apply is required. ( this is the basic functionality in ALV, that is my doubt).
wls_fieldcat-col_pos = wpv_pos.
wls_fieldcat-fieldname = wpv_champ.
wls_fieldcat-tabname = wlc_tabname.
wls_fieldcat-seltext_s = wls_fieldcat-seltext_m
wls_fieldcat-seltext_l = wpv_libelle.
wls_fieldcat-ddictxt = 'L'.
wls_fieldcat-no_out = wv_no_out.
APPEND wls_fieldcat TO gt_fieldcat.
Kind regards,
Jegathees P. -
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 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
-
Installed Itunes on my Windows XP Computer
I am getting an error message of: The APP or DLL C:\windows\system32\mssip32.dll is not a valid windows image. Pleases check this against your installation disk. Anyone have any suggestions?
-
Hi, How do I organize the order my tracks play in on my iPod? Can the track order be altered once I have copied it in to my iTunes or iPod library?
-
How to express the unsigned byte in Java?
we know that data are normally in unsigned byte format when communicating with COMM. How to express the unsigned byte in Java? java only supports 127 ~ -127 as byte, but I need 255~0. Anyone know how? Thanks!
-
Cannot Turn Down Brightness Fully on ML
I recently replaced my 2009 15" MacBook Pro's display myself as it was coming apart. My MBP originally came with a glossy display and the replacement part I used was an anti-glare display. Thankfully the anti-glare display works, however there is a c
-
New Portal implimentation - KM+C required?
hello, We are going to start a new Portal implimentation in the near future. My question is: Do we need to use KM+C and TREX? The business strategy for the Portal has not been defined yet. One of the Portal's purposes would be to replace our current