‎2007 Oct 29 11:02 AM
Hi,
i have written a select query as
SELECT SINGLE clear_flag INTO w_clearedflag
FROM zsales_cmpclear
WHERE doctype = bkpf-blart.
t_sales_comp-cleared_flag = w_clearedflag.
clear w_clearedflag.
if the select query does not return any record,then what will be the value moved to t_sales_comp-cleared_flag .
‎2007 Oct 29 11:04 AM
What ever value was in w_clearedflag before the select statement was executed.
You are best clearing this field before the SQL.
‎2007 Oct 29 11:04 AM
Hi
it depnds on the declaration of the variable w_clearedflag
if it is type C it will be space
if it is Type I or P or some CURR then zeros
Regards
ANJI
‎2007 Oct 29 11:06 AM
if the select query fails then initial value that means a blank or any initialised value of w_clearedflag will be filled.
‎2007 Oct 29 11:07 AM
Hi,
If you are using the variable w_clearedflag for the first time then it will have the value space or else the previous value assigned in the program before if the select statement fails.
Thanks,
Muthu.
‎2007 Oct 29 11:08 AM
hi sai,
In that internal table, last record value will store into that workarea.
If the condition matches corresponding record will come other wise
that last record will be assigned to that variable.
Regards,
Surya
‎2007 Oct 29 11:08 AM
Whilst all of the other answers are good and useful, did you not try this code for yourself debugging through it to see exactly what happens? You will learn a lot more that way.
Gareth.
‎2007 Oct 29 11:09 AM
hi,
sai prasad.
SELECT SINGLE clear_flag INTO w_clearedflag
FROM zsales_cmpclear
WHERE doctype = bkpf-blart.
if sy-subrc eq 0.
t_sales_comp-cleared_flag = w_clearedflag.
endif.
clear w_clearedflag.
if u write like this then if select query executed properly then t_sales_comp-cleared_flag contains the value of w_clearedflag.
otherwise it contains default valu of the type decledred to t_sales_comp-cleared_flag.
‎2007 Oct 29 11:11 AM
The value will be the initial value of w_clearedflag, which means the value for w_clearedflag will remain, the one, which is before the select query. Since the select query hasnt fetched any record, the value of w_clearedflag will not get populated.