Skip to Content
0
Former Member
May 21, 2015 at 08:13 PM

Is it possible to do a SUM( CASE... END ) in ABAP 7.4 SP04?

5039 Views

Hi everyone,

We recently upgraded to EHP7 and we gain new features in ABAP.

Particularly the enhancements of open sql suits us very well with programs we are developing now.

However a SELECT I'm trying to do is not working. By the ABAP online help it should work, I think, but it is not.

I explain myself:

In the online help it states that you do a SELECT like this:

SELECT result

Where result is ... lines select_list ...

And select_list could be a col_spec

And col_spec could be aggregate

And aggregate could be SUM( [DISTINCT] col|sql_exp )

And sql_exp could be sql_case

And sql_case could be CASE operand

WHEN operand1 THEN result1

[WHEN operand2 THEN result2]

...

[ELSE resultn]

END

So, I think, I can do something this:

SELECT some_field, SUM( CASE ... END ) ...

FROM some_table

GROUP BY some_field.

But the ABAP editor keep saying that there is a syntax error after CASE given the message ')' was expected here. no matter what I write after the word CASE.

I'm sure ABAP is using the new syntax 'cause in fact I can use CASE in a SELECT, but notSUM( CASE... as I said.

So:

am I missing something?,

SUM( CASE... isn't supported and it's a glitch in the syntax help?

Maybe the ABAP 7.4 SP4 I have does not support it and a later one does?

Any hint would be highly appreciated.

J.