‎2005 Aug 25 12:23 PM
Hai guys
I have Condition screen having
three select options parameter
How to use query SELECT statement with selection option parameter.?
say for example.
<b> Order date - SEL1 (SELECT-OPTION- FROM..TO Range)
Shipment no - SEL2 (SELECT-OPTION)
item no - SEL3 (SELECT-OPTION)</b>
How to use this three parameter in SELECT statement.
SELECT ... from VBAP where ORD IN SEL1 AND ORD IN SEL2 and ORD IN SEL3.
was the above condition usage is correct?
pls let me know.
ambichan
‎2005 Aug 25 12:26 PM
SELECT ... from VBAP
into table i_tab
where ord IN sel1
AND ship IN sel2
AND item IN sel3.Its correct.
See this sample code
SELECT-OPTIONS: sel1 FOR VBAP-ERDAT,
sel2 FOR VBAP-AUFNR, (or whatever it is)
sel3 FOR VBAP-POSEX.
SELECT ... from VBAP
into table i_tab
where erdat IN sel1
AND aufnr IN sel2
AND posex IN sel3.
If sy-subrc = 0.
endif.<b>The code u have writen is correct</b>.
Kindly close the previous threads open by you.
‎2005 Aug 25 12:26 PM
SELECT ... from VBAP
into table i_tab
where ord IN sel1
AND ship IN sel2
AND item IN sel3.Its correct.
See this sample code
SELECT-OPTIONS: sel1 FOR VBAP-ERDAT,
sel2 FOR VBAP-AUFNR, (or whatever it is)
sel3 FOR VBAP-POSEX.
SELECT ... from VBAP
into table i_tab
where erdat IN sel1
AND aufnr IN sel2
AND posex IN sel3.
If sy-subrc = 0.
endif.<b>The code u have writen is correct</b>.
Kindly close the previous threads open by you.
‎2005 Aug 25 12:31 PM
Hi,
The SELECT statement u have used is correct.
Thanks,
Ruthra.R
‎2005 Aug 25 1:18 PM
Sometimes there could be requirement that if even of the select option matches then the corresponding data should be queried.
So suppose ur order dates are valid and shipment number is invalid even then u want the program to obtain data then u have to use OR condition ( although this is a very rare case and a weird requirement )
SELECT ... from VBAP where ORD IN SEL1 OR ORD IN SEL2 OR ORD IN SEL3.
otherwise the select statement is perfect.
‎2005 Aug 25 1:35 PM
From a syntax perspective, yes your statement is correct. To tell whether it is going to give you correct results or not, depends on your requirement.
You are going to VBAP table which is line item table for sales orders. Then what is shipment number doing in that select unless you mean sales order number?
Also, if you have the sales order number VBELN and the item number POSNR, then you can use only those two to go to VBAP, but order date is on the header table VBAK. Another thing to look for is, suppose if the users enter 10 order numbers for SEL2 and 10 item numbers for SEL3, does that mean all 10 item numbers will be there in all 10 sales orders? Do you mean material number MATNR when you say item number? Then you will find all of them in VBAP.
So, as you can see, there will be too many questions, if you simply ask if your statement is correct. It is correct from a syntax perspective. If you are getting a syntax error, please post your exact select statement here.
Regards,
Srinivas