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 for select single statement

Former Member
0 Likes
4,504

MY ztable contains 4 key fields bukrs,vkorg,vbeln,ertim .

SELECT SINGLE * FROM Ztable INTO zitab

WHERE BUKRS = P_bukrs

AND VKORG = P_vkorg

AND vbeln = P_vblen

AND FLAG = 'X'.

Here i am checking whether the record exist or not. but i am not including the key field ertim ie time field in the above query because i am not getting this as input to pass.

But my requirement is to check whether the record exists or not.

Please gurus tell me how to correct it , is there any other way, can i use the any alternative select statement or i need to compulsory add the ertim field also?

SLIN RESULTS :

Syntax check warning

This warning is only displayed in SLIN.

In "SELECT SINGLE ...", the WHERE condition for the key field "ERTIM" does

not test for equality. Therefore, the single record in question may not be

unique.

(You can hide the message using "#EC *)

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,562

Try this.....

SELECT *

FROM Ztable

INTO zitab

upto 1 rows

WHERE BUKRS = P_bukrs

AND VKORG = P_vkorg

AND vbeln = P_vblen

AND FLAG = 'X'.

ENDSELECT.

if sy-subrc eq 0.

write: record exists.

endif.

MY ztable contains 4 key fields bukrs,vkorg,vbeln,ertim .

SELECT SINGLE * FROM Ztable INTO zitab

WHERE BUKRS = P_bukrs

AND VKORG = P_vkorg

AND vbeln = P_vblen

AND FLAG = 'X'.

Here i am checking whether the record exist or not. but i am not including the key field ertim ie time field in the above query because i am not getting this as input to pass.

But my requirement is to check whether the record exists or not.

Please gurus tell me how to correct it , is there any other way, can i use the any alternative select statement or i need to compulsory add the ertim field also?

SLIN RESULTS :

Syntax check warning

This warning is only displayed in SLIN.

In "SELECT SINGLE ...", the WHERE condition for the key field "ERTIM" does

not test for equality. Therefore, the single record in question may not be

unique.

(You can hide the message using "#EC *)

11 REPLIES 11
Read only

former_member156446
Active Contributor
0 Likes
2,562

try :

SELECT distinct * FROM Ztable INTO zitab
WHERE BUKRS = P_bukrs
AND VKORG = P_vkorg
AND vbeln = P_vblen
AND FLAG = 'X'.
if sy-subrc eq 0.
  write: record exists.
endif.

Read only

Former Member
0 Likes
2,562

Hi,

Gofor ..SELECT * UPTO 1 ROWS.....ENDSELECT. Instead of SELECT SINGLE...

Read only

Former Member
0 Likes
2,563

Try this.....

SELECT *

FROM Ztable

INTO zitab

upto 1 rows

WHERE BUKRS = P_bukrs

AND VKORG = P_vkorg

AND vbeln = P_vblen

AND FLAG = 'X'.

ENDSELECT.

if sy-subrc eq 0.

write: record exists.

endif.

Read only

0 Likes
2,562

Is it not necessary to include the key field to check whether the record exists or not?

and my another question is

to hide the message in slin (You can hide the message using "#EC *)

so i included "#EC * as shown below , but still showing the same message in slin , please correct me if i used it wrongly

SELECT SINGLE * FROM Ztable INTO zitab "#EC *

WHERE BUKRS = P_bukrs

AND VKORG = P_vkorg

AND vbeln = P_vblen

AND FLAG = 'X'.

Read only

0 Likes
2,562

hi,

U can try to hide the messages in slin by writing extended check off/on.

Try this

SET EXTENDED CHECK OFF.

SELECT SINGLE * FROM Ztable INTO zitab

WHERE BUKRS = P_bukrs

AND VKORG = P_vkorg

AND vbeln = P_vblen

AND FLAG = 'X'.

SET EXTENDED CHECK ON.

Hope this helps.

Regards,

Sravnthi Chilal

Read only

Former Member
0 Likes
2,562

data:r_ERTIM type range of ertim.

SELECT SINGLE * FROM Ztable INTO zitab

WHERE ertim in r_ertim

BUKRS = P_bukrs

AND VKORG = P_vkorg

AND vbeln = P_vblen

AND FLAG = 'X'.

try to pass empty ranges,this will clear the Slin check.

Read only

0 Likes
2,562

Is it not necessary to include the key field to check whether the record exists or not?

Read only

0 Likes
2,562

Hi,

It is not always possible to add all the key fields of a table.. It depends on your requirement.. But when you are using SELECT SINGLE it is always safe to use all key fields to get a unique record..

Using key fields ensure performance..

Read only

0 Likes
2,562

i need to check whether a record exists or not in the table ,then i need to input all the key fields or not? if yes then what is the correct select statement to use it if two key fields are missing?

Read only

0 Likes
2,562

Hi,

As i have already mentioned it is not always essential that you have to use all the key fields.. It depends entirely on your requirement.. If you miss any of the key fields it wil still fetch records for you.. KEY FIELDS ensure performance.. If you mention all key fields then the data fetch from the table will be faster.. But you dont use all key fields, even then the records will be fetched but the performance will be lowered..

Again, if in your requirement two key fields are missing do not use SELECT SINGLE.. It will not fetch unique record always.. For this as already suggested you can use either

SELECT DISTINCT or ..SELECT * UPTO 1 ROWS.....ENDSELECT

Hope i am clear now..

Read only

0 Likes
2,562

if your motive is just to check if an entry is ther or not for your selection, then you can try:

select count(*) from ztable where XXXXX

check sy-subrc = 0 for record availability.

or

select field1 upto 1 rows (instead of select * to improve performance)

into w_field1

from ztable

where XXXXX.

endselect.

select single should be used only if you have all the key fields available in the where condition. else use select/endselect.

thanks,

Bikash