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

slin check warning with select statement

Former Member
0 Likes
1,783

experts

data : vari1 type ztable-field1.

Now i want to check whether the entry exists in the table or not.

select single field1 from table into vari1

where vbeln = p_vbeln.

In the slin check i got a warning message like

"No read access to field VARI1."

I am not using the varaible anywhere in the program except in the select query.

Please tell is this correct way of coding or not.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,347

Hi,

use it this way...

just write an if condition like the way it is shown below.....

select single field1 from table into vari1
where vbeln = p_vbeln.
if sy-subrc = 0.
"  your logic.......
else.
if vari1 is not initial.  " add this if condition if sy-subrc is not equal to zero.......
  clear vari1. " this will not affect the flow of your program and also neither the output.....
endif.

Regards,

Siddarth

experts

data : vari1 type ztable-field1.

Now i want to check whether the entry exists in the table or not.

select single field1 from table into vari1

where vbeln = p_vbeln.

In the slin check i got a warning message like

"No read access to field VARI1."

I am not using the varaible anywhere in the program except in the select query.

Please tell is this correct way of coding or not.

7 REPLIES 7
Read only

Former Member
0 Likes
1,348

Hi,

use it this way...

just write an if condition like the way it is shown below.....

select single field1 from table into vari1
where vbeln = p_vbeln.
if sy-subrc = 0.
"  your logic.......
else.
if vari1 is not initial.  " add this if condition if sy-subrc is not equal to zero.......
  clear vari1. " this will not affect the flow of your program and also neither the output.....
endif.

Regards,

Siddarth

Read only

matt
Active Contributor
0 Likes
1,347

>

> Hi,

>

> use it this way...

> just write an if condition like the way it is shown below.....

>

>

select single field1 from table into vari1
> where vbeln = p_vbeln.
> if sy-subrc = 0.
> "  your logic.......
> else.
> if vari1 is not initial.  " add this if condition if sy-subrc is not equal to zero.......
>   clear vari1. " this will not affect the flow of your program and also neither the output.....
> endif.

>

> Regards,

> Siddarth

All that message means is that the field isn't used after being filled. Often, this could be an indication of useless code.

So, what you're suggesting., is that you put in some more spurious, useless code, just so that the message goes away! That is absolutely the wrong way of going about it. It makes the code MORE complex, therefore LESS maintainable, therefore MORE expensive.

In this case - an existence check - it's the only way to do it. You have to have a variable which is never read - so that is why it is perfectly fine to use #EC NEEDED. and why SAP provided the option!

matt

Read only

0 Likes
1,347

Thank you Matt for the suggestion,

I never knew this option thou it looked simple...

Learned something new from this....

Thanks,

Siddarth

Read only

Former Member
0 Likes
1,347

I think what ever u r doing is correct from validation point of view and u r getting this msg, b'cause u r only storing the value in the field but not using it any where. Infact you can also avid this message by using following technique.......

suppose u have a workarea (say w_var) that u r using in the prog. where ztable-field1 is a field of it.

Then u can reconstruct the select:

select single field1 from table into w_var-field1

where vbeln = p_vbeln.

after sy-subrc check clear this field.

clear w_var-field1.

Now if you run SLIN u will not get this message any more.

Regards,

Joy.

Read only

former_member156446
Active Contributor
0 Likes
1,347

check the ztable-field1 does it have any read only access, or check if it is using some authority check and restricting you to acess it.

Read only

Former Member
0 Likes
1,347

you can add a pseudo comment which you can get in the SLIN error itself to HIDE the error.

pseudo codes are like

" #EC_NEEDED. 

-->check the exact one given in SLIN

that you will add to the end of code.

select single field1 from table into vari1
       where vbeln = p_vbeln. " #EC_NEEDED.

Read only

Former Member
0 Likes
1,347

Hi

the error is there because may be you are not using this variable anywhere.

You filling the variable but not reading it .

These are warnings .

Just initialize the variable .

Hope this helps .

Thanks and Regards .

Aditi Wason