‎2007 Dec 13 2:33 AM
Is it possible to declare a select within a case statement?
I got an error.. I declared the CASE under my WHEN statement...
Please advise... Thanks!
regards,
Mark
‎2007 Dec 13 3:05 AM
Hi,
check this sample code..
TABLES: MARA,
MVKE.
CASE sy-subrc.
WHEN 0.
SELECT SINGLE * FROM MARA where MATNR = 'TEST'.
WHEN 1.
SELECT SINGLE * FROM MVKE WHERE MATNR = 'TEST'.
ENDCASE.
Also please post your code..
Thanks
Naren
‎2007 Dec 13 2:37 AM
Hi Mark,
Here is a sample
case decision_field.
when something.
select * etc......
when something_else.
when others.
endcase.
thanks.
Jamie
‎2007 Dec 13 2:51 AM
Thanks Jamie,,,
But thats the code I used when I encounter an error ...
Seem not to work..
‎2007 Dec 13 4:40 AM
if you use select * ... use ENDSELECT incase not importing to internal table...
other wise it will work perfectly.
‎2007 Dec 13 3:05 AM
Hi,
check this sample code..
TABLES: MARA,
MVKE.
CASE sy-subrc.
WHEN 0.
SELECT SINGLE * FROM MARA where MATNR = 'TEST'.
WHEN 1.
SELECT SINGLE * FROM MVKE WHERE MATNR = 'TEST'.
ENDCASE.
Also please post your code..
Thanks
Naren
‎2007 Dec 13 4:37 AM
Hi Mark,
can u paste the code where u get error?
Also tell us what is the error u get?
‎2007 Dec 13 5:20 AM
are you using endselect with select statement without into any internal table
just add error in this thread for more clear picture
‎2007 Dec 13 5:34 AM
hi mark,
if u use select statement fetching the data into an internal table then u won't have this problem
select * from trans_table into table itab where cond.
eg:
case 'X'.
when 0.
select statement.
when 1.
select statement.
when others .
select statement.
end case.
hope this helps u.
regards,
sohi
‎2007 Dec 13 5:45 AM
Hi Mark,
Why did you get error it is perfectly work.
Try this code.
Data t_table type table of spfli with header line.
data w_temp type c value 'X'.
Case w_temp.
when 'X'.
Select * from spfli into table t_table.
endcase.
Plz Reward if useful,
Mahi.