‎2008 Apr 02 11:55 AM
Is it necessary that a case statement should always be followed by a when statement?? i mean will i get any error if i dont do the same?
‎2008 Apr 02 12:00 PM
Hi Sneha..
U can use Case statement like this ....this is the example case statement formate....
CASE .
WHEN .
WHEN .
WHEN OTHERS.
ENDCASE.
Reward me points ..
By
Pari
‎2008 Apr 02 11:56 AM
‎2008 Apr 02 11:57 AM
‎2008 Apr 02 12:00 PM
i mean i know when is mandatory... what i wanted to know is wht if my stucture is sumthing like this ......
case abc.
sum lines of code here.................
when '1'.
...............
‎2008 Apr 02 12:06 PM
Hi,
You should have at least one when.
with is case...endcase the first statement should be the WHEN.
if u want to write some condition statements(i.e,irrespective of whens)
write them before the case...endcase.
rgds,
bharat.
‎2008 Apr 03 8:47 AM
Hi sneha
might be u have not used endcase.
try this it will work
case sy-ucomm.
when '1'.
-
-
endcase.
‎2008 Apr 03 8:50 AM
‎2008 Apr 02 12:00 PM
Hi Sneha..
U can use Case statement like this ....this is the example case statement formate....
CASE .
WHEN .
WHEN .
WHEN OTHERS.
ENDCASE.
Reward me points ..
By
Pari
‎2008 Apr 02 12:01 PM
U will not get any error .
But there is no use of such a statement.
case v_check.
endcase.
‎2008 Apr 02 12:03 PM
hi,
there is no point of using a case statement without when.
if you dont use u will get a warning saying case must be folloed by when.
reward if helpful
prasanth
‎2008 Apr 03 9:08 AM
Hi,
I dont think it is can ever be a requirement for discussion
However, in short, there are specific requirements and mandatory rules/ syntax in every language, and is same in ABAP as well.
Pts to remember in Case-Endcase:
Pt1) A Case-EndCase should have atleast one When statement.
Pt2) You cannot write any statement between Case and the first When statement.
In otherwords, When must be the first statement after a Case statement.
Hope it answers you query
Regards, Tapas
‎2009 Jun 17 10:58 AM
Hi Sneha,
You wont be getting any error without using WHEN with CASE, but it wont give u any fruitful results, as it will come out of processing without any condition.
Instead of this, try IF....ENDIF.
--
Prateek.