cancel
Showing results for 
Search instead for 
Did you mean: 

Last Record Values for a given Date Range

sap_cohort
Active Contributor
0 Kudos

Hi, I have a unique requirement to process/report only the values of the last record found in a date range for a given set of characteristics. The order would be by FISCPER.

For example: I have some data with 3 characteristics.

STORE001 MATN001 2004001 100 PCS

STORE001 MATN001 2004005 75 PCS

STORE001 MATN001 2004006 80 PCS

STORE002 MATN002 2003008 10 PCS

STORE002 MATN002 2004001 15 PCS

STORE002 MATN002 2004004 40 PCS

A selected date range of 2003008 to 2004001 would result in the following records being processed.

STORE001 MATN001 2004001 100 PCS

STORE002 MATN002 2004001 15 PCS

A selected date range of 2004002 to 2004006 would result in the following records being processed.

STORE001 MATN001 2004006 80 PCS

STORE002 MATN002 2004004 40 PCS

How can I accomplish this at runtime? Any ideas?

Accepted Solutions (0)

Answers (4)

Answers (4)

sap_cohort
Active Contributor
0 Kudos

Closing Question

Assigning Points

Former Member
0 Kudos

Hi Kenneth,

I wouln't discard the exception aggregation...just make a try...set its aggregation behavior as last value and fiscper as exception aggr. reference char...

Let me know!

Bye,

Roberto

sap_cohort
Active Contributor
0 Kudos

Doesn't work. As soon as I take out the material it takes the last value of store. I tried leaving in the material as a hidden characteristic and this gives me the totals I want but the store characteristic is repeated for every material. And it doesn't go away with the repeated values setting.

Any other ideas? Table API?

Help!

Former Member
0 Kudos

We are doing somewhat similar thing using variable exit.

In the exit code, you could 'sort descending' your records by STORE, MATN and FISCPER. Then 'delete adjacent duplicates comparing STORE and MATN'.

In this case all the duplicates records will be deleted except the first one which is the one you need.

Kumar Gudiseva.

sap_cohort
Active Contributor
0 Kudos

I think your talking about manipulating the query records in the user exit. What exit do you use to gain access to the whole table? And if the data is not avaialable in it's entirety then what do you do? I think the query data is only available in packets of 1000.... ?

Any help is greatly appreciated!

Thanks!

Former Member
0 Kudos

It sounds like you are interested in the last value in some sort of inventory scenario.

I would change the exception aggregation behavior of your key figure to 'Last Value'. That way, when you sum up all the records, only the last value is shown in the total fields.

sap_cohort
Active Contributor
0 Kudos

Nope, it's not an inventory scenario. It could be say the last status of a gas meter within a selected date range.

Any other ideas?

I've considered using VKF, but haven't figured out how this would work yet. If I could modify the selected query data prior to query processing I might be able to number the records and then filter on that..... Anyway I'm open to any suggestions or leads!

I won't forget the points for anyone with a solution!

Thanks!