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

select query

Former Member
0 Likes
765

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 .

8 REPLIES 8
Read only

Former Member
0 Likes
736

What ever value was in w_clearedflag before the select statement was executed.

You are best clearing this field before the SQL.

Read only

Former Member
0 Likes
736

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

Read only

Former Member
0 Likes
736

if the select query fails then initial value that means a blank or any initialised value of w_clearedflag will be filled.

Read only

Former Member
0 Likes
736

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.

Read only

Former Member
0 Likes
736

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

Read only

Former Member
0 Likes
736

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.

Read only

Former Member
0 Likes
736

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.

Read only

Former Member
0 Likes
736

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.