Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

case endcase with integer variables

jyothsna1234
Explorer
0 Likes
2,829

DATA: RESULT(3) TYPE P DECIMALS 2,

OPERATOR TYPE C.

case val.

when >=97.

operator = 'A+'.

when others.

operator = 'F'.

endcase.

how can i use value of variable val with comparision operands of >= or <= signs in case statement ?Thanks

1 ACCEPTED SOLUTION
Read only

anujawani242683
Active Participant
0 Likes
2,706

Hi,

You can use case statement with conditions inside select statement.

for e.g.

SELECT
werks,

 matnr,

 ersda,

 clabs,

 cinsm,

 cspem, 

CASE WHEN clabs > 0 OR cinsm > 0 AND cspem > 0 THEN
matnr && charg END AS ztest

 FROM mchb INTO TABLE 

@DATA(it_mchb).

But Outside select statement you can't do this. If you want to compare you can use if statement.

Regards,

Anuja Kawadiwale

4 REPLIES 4
Read only

lenapadeken
Product and Topic Expert
Product and Topic Expert
2,706

Hi jp1239,

use an IF statement instead of the CASE statement. With CASE, you compare two operands and it's best to have constant values after WHEN.

Best regards,

Lena

Read only

Sandra_Rossi
Active Contributor
2,706

Your syntax is wrong.

CASE is only for = comparison, as explained in the ABAP Documentation.

Read only

anujawani242683
Active Participant
0 Likes
2,707

Hi,

You can use case statement with conditions inside select statement.

for e.g.

SELECT
werks,

 matnr,

 ersda,

 clabs,

 cinsm,

 cspem, 

CASE WHEN clabs > 0 OR cinsm > 0 AND cspem > 0 THEN
matnr && charg END AS ztest

 FROM mchb INTO TABLE 

@DATA(it_mchb).

But Outside select statement you can't do this. If you want to compare you can use if statement.

Regards,

Anuja Kawadiwale

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,706

Use a IF .... ELSEIF .... ELSEIF .... ELSE ... ENDIF