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

Switch Statment - case

former_member181966
Active Contributor
0 Likes
799

i have a function module , its returning some codes and I am showing some error messages on the bases of codes ....

EXCEPTIONS

ID_NOT_FOUND = 1

R_NOT_FOUND = 2

NOT_ACTIVE = 3

OTHERS = 4.

case Error.

When '0'

When 'others'...

endcase.

but i am getting short dump when it execute others why is that ?

I re-write the code in this way .. and its working fine...

EXCEPTIONS

ID_NOT_FOUND = 1

R_NOT_FOUND = 2

NOT_ACTIVE = 3

OTHERS = 4.

case Error.

When '0'

When '1' or '2' or '3' or '4' ...

endcase.

1 ACCEPTED SOLUTION
Read only

suresh_datti
Active Contributor
0 Likes
778

Hi ,

it should be when others ie without the quotes..

regards,

Suresh Datti

5 REPLIES 5
Read only

suresh_datti
Active Contributor
0 Likes
779

Hi ,

it should be when others ie without the quotes..

regards,

Suresh Datti

Read only

Former Member
0 Likes
778

When 'others'...

'others' should not be in codes.

Read only

Former Member
0 Likes
778

It should be


CASE SY-SUBRC.
  WHEN 0.
    .....
  WHEN 1
    .....
  WHEN 2.
     ....
  WHEN 3.
    ....
  WHEN 4.
    ....
  WHEN OTHERS.
ENDCASE.

Read only

0 Likes
778

Why OTHERS dont work like 'OTHERS' ..SAP syntax? right ...

Complier doesnt understand ...

Read only

Former Member
0 Likes
778

dont write OTHERS in codes

here OTHERS works like a variable but not a constant , so it is not written in quotes

Message was edited by: chandrasekhar jagarlamudi