10-08-2005 8:15 AM
Hi All,
Can anyone please explain the concept of using SELECT-OPTIONS in data fetching (In, Select statement, where clause).
For Ex.
SELECTION-SCREEN BEGIN OF BLOCK selsrn WITH FRAME TITLE
text-001.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln NO-EXTENSION,
s_erdat FOR vbak-erdat NO-EXTENSION
NO INTERVALS,
s_vbtyp FOR vbak-vbtyp,
s_auart FOR vbak-auart,
s_vkbur FOR vbak-vkbur.
PARAMETER: p_kunnr TYPE vbak-kunnr.
SELECTION-SCREEN END OF BLOCK selsrn.
START-OF-SELECTION.
SELECT vbeln
vbtyp
kunnr
FROM vbak INTO TABLE it_vbak1
WHERE vbeln = s_vbeln AND
erdat = s_erdat AND
vbtyp = s_vbtyp AND
auart = s_auart AND
vkbur = p_vkbur.
WHERE vbeln IN s_vbeln AND
erdat IN s_erdat AND
vbtyp IN s_vbtyp AND
auart IN s_auart AND
vkbur IN s_vkbur AND
kunnr EQ p_kunnr.
Here, I need to know what is the diffrence in the commented "WHERE" and the other. Iam also aware of the select-option structure (Option, Sign, Low and High).
Regards,
Sumanth.
10-08-2005 9:13 AM
Sumanth,
The way SELECT-OPTIONS have been used in the commented code is not right. Usually you use SELECT-OPTIONS to cover a range or multiple single values or mulitple range of values or range plus some additional single values. For this to work properly you have to use the IN operator.
If you use '=', it tries to take the header line of the SELECT OPTIONS tables and might not return the values that you are expecting.
Hope this clarifies your questions.
Regards,
Ravi
Note : Please reward points if this solves your problem.
10-08-2005 9:13 AM
Sumanth,
The way SELECT-OPTIONS have been used in the commented code is not right. Usually you use SELECT-OPTIONS to cover a range or multiple single values or mulitple range of values or range plus some additional single values. For this to work properly you have to use the IN operator.
If you use '=', it tries to take the header line of the SELECT OPTIONS tables and might not return the values that you are expecting.
Hope this clarifies your questions.
Regards,
Ravi
Note : Please reward points if this solves your problem.
10-08-2005 10:08 AM
Hi,
One more remark about SELECT-OPTIONS, be aware that if it is empty, then it as if the condition does not exist.
In your example, if S_VBELN is empty then there won't be any filter on this criterion.
10-08-2005 11:27 AM
Hi Sumanth,
Yes, and despite all these simplicity, the select-options can also be used to indicate single values, ranges, multiple single values, and also <> , <,> etc.
And you can also say Exclude and give a range/single value/multiple values.
Thats just how complex it cud get.
Rgds,
Prash.