2009 Aug 23 7:08 PM
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.
2009 Aug 23 7:41 PM
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.
2009 Aug 23 7:41 PM
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
2009 Aug 23 9:08 PM
>
> 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
2009 Aug 23 9:12 PM
Thank you Matt for the suggestion,
I never knew this option thou it looked simple...
Learned something new from this....
Thanks,
Siddarth
2009 Aug 23 8:23 PM
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.
2009 Aug 23 8:28 PM
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.
2009 Aug 23 8:58 PM
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.
2009 Aug 23 9:58 PM
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
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |