This website is not affiliated with, sponsored by, or approved by SAP AG.

Populate Virtual Key Figure with Average

Business Warehouse

Moderators: Snowy, thx4allthefish

Populate Virtual Key Figure with Average

Postby TOKBW » Mon Feb 28, 2005 4:36 pm

Hello,

At query execution time I need to populate a virtual key figure with the average of the lowest 4 values of all records selected from the InfoProvider. I have written code in zxrsrtop and zxrsru02. I am now trying to finish it up in zxrsrzzz. My problem is that this code is executed for each record that is pulled from the infoprovider. Is there anyway to group the records after selection is complete so that I can identify the lowest 4 records and then populate my virtual key figure with their average?

Any suggestions are greatly appreciated. Thank you in advance for your help.

TOKBW
TOKBW
 

Postby tchhichhia » Sun Mar 06, 2005 2:02 pm

HI,

Pls give examples , maybe I can have a go at the numbers cheers,

TC
tchhichhia
 

Re: Populate Virtual Key Figure with Average

Postby Guest » Mon Mar 07, 2005 10:06 am

Hi there,

a virtual key figure might not be the correct place. As you have correctly recognized you can only process record by record. I would rather use conditions in the query definition (BEx analyzer). For the new condition choose Bottom N as operator and 4 as a value. You can also define a variable so the last n values will be displayed depending on the variable input.

Hope that helps,

Thomas aka /H

TOKBW wrote:Hello,

At query execution time I need to populate a virtual key figure with the average of the lowest 4 values of all records selected from the InfoProvider. I have written code in zxrsrtop and zxrsru02. I am now trying to finish it up in zxrsrzzz. My problem is that this code is executed for each record that is pulled from the infoprovider. Is there anyway to group the records after selection is complete so that I can identify the lowest 4 records and then populate my virtual key figure with their average?

Any suggestions are greatly appreciated. Thank you in advance for your help.

TOKBW
Guest
 

Postby TOKBW » Mon Mar 07, 2005 4:38 pm

I'm afraid that conditions/exceptions will not work because I need to AVERAGE the lowest 4, not just display them.

Here is an example of what I am trying to do
I have the following records (simplified for this example):

Company(Characteristic) Price (Key Figure)
A 1.25
B 1.37
C 1.24
D 1.33
E 1.50
F 1.46

Now I need to compute an average of the lowest 4. I can display this as another company (characteristic) or as another key figure. Unfortunately, I cannot do this at load time because our users can choose to exclude companies from the query - so that should not be included in the average. Thus, I think the averaging needs to be computed at run-time. Do you have any ideas regarding how I can accomplish this?

Thank you in advance for your help.

Sincerely,
TOKBW
TOKBW
 

Postby jlaruss » Tue Mar 08, 2005 12:14 pm

Create a condition for the bottom 4 and then on the properties of the key figure set the result as average of values.

thanks,
jlaruss
jlaruss
 
Posts: 193
Joined: Fri May 16, 2003 8:56 am
Location: Memphis, TN

Postby TOKBW » Tue Mar 08, 2005 2:41 pm

Thank you for the response. Unfortunately, that won't work because the users need to see all of the records at the same time, not just the lowest 4. A condition will only return the lowest 4. Additionally, I need to create some other calculations as well (average of all values, average of lowest 4 +.1, etc.)

Thanks,
TOKBW
TOKBW
 

Postby TOKBW » Wed Mar 09, 2005 11:11 am

I am still trying to find a way to make this work. I am not certain it is possible but I am trying and need to test the use of virtual objects. My code in zxrsrtop, zxrsru02, zxrsru01, and zxrsrzzz is all active but I am getting an error when I try to run the query. The error says
Field Symbol has not yet been assigned
RFC_ERROR_SYSTEM_FAILURE.
I think that all of my field symbols have been assigned. Has anyone seen this error before? Alternatively, does anyone know how to debug these user exits?

Thank you again for all of your help and suggestions.

TOKBW
TOKBW
 

Postby TOKBW » Tue Mar 15, 2005 9:29 am

I don't know if anyone is still looking at this posting, but I am still updating with my successes and new problems.

This last problem was a simple mistake on my part. I now have all field symbols assigned correctly. However, my problem now is that not all of the field symbols are getting the right values. It looks like the program is not recognizing all of the fields in C_S_DATA (numeric characteristics and date/time fields in particular). I don't know if it is a problem with the field catalog/field symbol assignments or what. Has anyone encountered this situation before? Again, all suggestions/help are appreciated.

Thank you,
TOKBW
TOKBW
 

Postby ed » Wed Mar 16, 2005 12:17 pm

TOKBW wrote:This last problem was a simple mistake on my part. I now have all field symbols assigned correctly. However, my problem now is that not all of the field symbols are getting the right values. It looks like the program is not recognizing all of the fields in C_S_DATA (numeric characteristics and date/time fields in particular). I don't know if it is a problem with the field catalog/field symbol assignments or what. Has anyone encountered this situation before? Again, all suggestions/help are appreciated.

Thank you,
TOKBW


I know it's no consolation but we are having the exact same issue at the moment. So I'll bump it back to the top and hopefully someone will be able to help.

Thanks, Ed
ed
 
Posts: 9
Joined: Mon Dec 01, 2003 11:04 am
Location: London

Postby TOKBW » Fri Mar 18, 2005 2:37 pm

We were able to figure out that C_S_DATA did not recognize some of our fields because when the query was built some of the data definitions and field assignments in the ZXRSRTOP and ZXRSRZZZ includes were incorrect. We had to go into the query and make some changes (drag those fields into rows/columns, etc.) so that it would pick up the new code in those includes.

Now my problem is that sometimes the average is double or triple what it should be. I can't figure out where that is occurring. At the end of my code in ZXRSRZZZ the field assignment picks up the correct average. When it leaves there and goes through some SAP code something happens and a few of the averages become incorrect. Any ideas on what could be causing this? I am trying to debug through the SAP code, but I haven't found it yet.

I appreciate any help/suggestions. Let me know if I can help you Ed!

Thanks,
TOKBW
TOKBW
 

Postby TOKBW » Fri Mar 18, 2005 4:17 pm

Oops! Our mistake again. Sorry for the confusion. The averages are computing properly. Thanks!
TOKBW
 

Re: Populate Virtual Key Figure with Average

Postby ShubhShree » Thu Sep 29, 2011 5:44 am

Hi ,

Can you please explain how you corrected this error. I could not understand much out of your post and also facing this error while executing some queries but we dont have Virtual Characteristic and Key Figure in my Query.

Any pointers would be helpful.

Thanks.
ShubhShree
 
Posts: 1
Joined: Thu Sep 29, 2011 5:26 am


Return to Business Warehouse

Who is online

Users browsing this forum: No registered users and 4 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.