‎2009 Apr 22 11:39 AM
Hi,
I have a problem with a select statement.
I need to retrieve data from S889 table. I have written a select statement as follows. But it is not working.
Please let me know my mistake.
SELECT SSOUR
VRSIO
SPMON
SPTAG
SPWOC
SPBUP
BZIRK
KDGRP
VTWEG
SPART
HIEZU04
MVGR1
ZZPRODH1
MATNR
WERKS
ABSAT
LFIMG
OAUME
ZZSALES_12
ZZSALES_24
FROM S889
INTO TABLE T_S889
WHERE VRSIO = '000'
AND SPMON = P_MONTH
AND BZIRK = P_SADIS
AND KDGRP = P_CUGRP
AND VTWEG = P_SADCH
AND SPART = P_SADIV
AND HIEZU04 = P_CUPAR
AND MVGR1 = P_MAGRP
AND ZZPRODH1 = P_PRHIE
AND MATNR IN S_MATNR
AND WERKS = P_PLANT.
‎2009 Apr 22 11:45 AM
Hi Rajani,
Please check whether the internal table T_S889 is having all the fileds which you have mentioned in the select query. And also all the fields are of type that are in the table S889.
Regards
vachana
‎2009 Apr 22 11:43 AM
Please tell us in brief what error u r getting exactly, there are many possibilities.
1) Open the table with se16 and see if any entry exist in this table
2) See if this table is activated
Thank You,
Ganesh
‎2009 Apr 22 11:45 AM
Hi Rajani,
Please check whether the internal table T_S889 is having all the fileds which you have mentioned in the select query. And also all the fields are of type that are in the table S889.
Regards
vachana
‎2009 Apr 22 11:48 AM
Hi,
code
first try with the following code and see whether the data is getting populated in the internal table.
or
use 'OR' instead of 'AND' in the WHERE condition.
or
mention only the Key fields in WHERE condition.
data:
t_ S889 type standard table of S889,
fs_s889 like line of t_S889.
select <fields>
from s889
into table t_s889
WHERE VRSIO eq '000'.thanks
ravi
‎2009 Apr 22 11:51 AM
Hi,
Ur select query is correct.
explain if ur getting any error or dump.
if you are not getting data it means ur condition has filtered the data
so change the condition or maintain data as per the condition.
close the thread if you found ur solution
Regards,
Jayaram
‎2009 Apr 22 11:51 AM
HI,
Check the data exists in the table S889 for the consdition given as in the Where clause of select statement.
Make VRSIO = '000' as VRSIO is initial and Try.
‎2009 Apr 22 12:08 PM
Hi Rajani,
1. I Was unable to find the table S889 in my system. Is the table name is correct ?
2. When you need data of 1/3 of the fields of a database table then you can write
select * from S889 into table t_s889
where ......
Regards
Kumar M
‎2009 Apr 22 12:27 PM
Check if you have provided values in the parameters P_MONTH, P_CUGRP, P_SADCH, P_SADIV, P_CUPAR, P_MAGRP, P_PRHIE, P_PLANT. If any of these selection parameters do not contain a value, it takes up initial value which is compared while fetching data from the table and may result into zero entries being fetched.
‎2009 Apr 22 12:39 PM
Hi,
I don't find any problem in ur query.
could u tell me the error that you are getting.
chek ur data base table from se16 and pass all the data that u are passing in ur select query during the time of fillteration.
Thanks
Arun
‎2009 Apr 23 9:46 AM
Hi Arun,
Thank you for response.
I am not getting the data at all with this selection statement.
But I do have proper in my system. only problem is with that select statement.
I also put the OR condition. But the session is getting terminated. Because all the data is being retrieved.
‎2009 Apr 23 9:51 AM
HI,
Are you passing values to all the parameter fields ...if any of these parameter are blank then check the DM table with the same combination.
WHERE VRSIO = '000'
AND SPMON = P_MONTH
AND BZIRK = P_SADIS
AND KDGRP = P_CUGRP
AND VTWEG = P_SADCH
AND SPART = P_SADIV
AND HIEZU04 = P_CUPAR
AND MVGR1 = P_MAGRP
AND ZZPRODH1 = P_PRHIE
AND MATNR IN S_MATNR
AND WERKS = P_PLANT.
‎2009 Apr 23 9:52 AM
Hello Rajani,
May be you have to check the values in the WHERE conditions parameters. Is there any data against these values in S889?
May be you can have a look into "Conversion Exits" against the fields used in the WHERE clause. If so you have to use them, else the SELECt may fail.
Hope this helps.
BR,
Suhas
‎2009 Apr 22 12:45 PM
Hi,
The table S889 is not there. There is a table with name s009. Check ur query once.
‎2009 Apr 22 1:24 PM
well dudes Sxxx tables where xxx = numeric stand for Infostructure tables.
Sxxx tables with xxx >= 600 are own customer infoistructures, so dont be afaid he got this table and you not.
now to your Select. I just had a short look at it, but as far as i can see it, you are missing the statement 'corresponding fields of* between INTO and TABLE.
‎2009 Apr 22 1:08 PM
Hello,
I couldn't find this table either. Perhaps a customizing-generated table. Do you get any short dump when executing this statement?
Anyway, I recommend you to check the following on your statement:
(1) Check the name of the fields. One wrong fieldname can result in short dump.
(2) You are using INTO TABLE. Using this clause in a SELECT statement, you have to be sure that the order of the fields in your SELECT statement is in the same order you declared your internal table. This is very important. In case you don't want to worry about this, use INTO CORRESPONDING FIELDS OF TABLE instead of INTO TABLE (this is not recommended when you're thinking about performance).
(3) Check the types as well as the values you expect to have on your parameters used on WHERE clause. Wrong types/values can lead to unexpected results.
Regards,
Eduardo
‎2009 Apr 22 1:30 PM
Hi Rajani,
When u r using both select-options and parameters in where clause you should provide data for all the parameters in selection screen, otherwise it will take value blank for parameters and it will search the records in data base with value blank, where as if u do not give value in select-options it will fetch all the data.
Hope it will work now.
Vinod
‎2009 Apr 23 9:51 AM
Hi,
Your internal table should have all
the fields which you are fetching from
your select query and they should
be present in the internal table in the
same order in which they are being
fetched from the select query.
Hope it helps
Regards
Mansi
‎2009 Apr 23 9:53 AM
change
WHERE VRSIO = '000' and
to
WHERE ( VRSIO = '000' or
VRSIO eq space ) and
:
:
Also input all the values that u are having in the where condition,(which u can check in debugging) to the table in SE16 . check if there is any entry. If its there..your select query should not fail.
‎2009 Apr 23 10:07 AM
Hi,
Kindly check the where clause of query weather the table possess that entry that u have applied in where clause.
Check your query by using your where condition one by one.
Otherwise your query is correct . Apply the above and watch for sy-subrc = 0 , if it is 4 than that where clause creating problem.
Regards,
Himanshu
‎2009 Apr 23 10:08 AM
‎2009 Apr 23 10:13 AM
Hi Rajani,
Try it this way. In where condition of your select query use OR for parameter and use AND for select-options:
INTO TABLE T_S889
WHERE VRSIO = '000'
or SPMON = P_MONTH
or BZIRK = P_SADIS
or KDGRP = P_CUGRP
or VTWEG = P_SADCH
or SPART = P_SADIV
or HIEZU04 = P_CUPAR
or MVGR1 = P_MAGRP
or ZZPRODH1 = P_PRHIE
or WERKS = P_PLANT
and MATNR IN S_MATNR.And if you are not passing data in all the parameters then better write the where condition as below:
*declare the selction screen parameters in this way, means change the parameters to select-options with addition of no intervals & no-extension
Select-options:
s_SPMON for SPMON no intervals no-extension
s_BZIRKfor BZIRK no intervals no-extension.
* and write the where constion this way:
INTO TABLE T_S889
WHERE VRSIO = '000'
and SPMON IN P_MONTH
and BZIRK IN P_SADIS
and KDGRP IN P_CUGRP
and VTWEG IN P_SADCH
and SPART IN P_SADIV
and HIEZU04 IN P_CUPAR
and MVGR1 IN P_MAGRP
and ZZPRODH1 IN P_PRHIE
and WERKS IN P_PLANT
and MATNR IN S_MATNR.With luck,
Pritam.
‎2009 Apr 27 6:28 PM
Hi All,
My problem is not solved yet.
SELECT SSOUR
VRSIO
SPMON
SPTAG
SPWOC
SPBUP
BZIRK
KDGRP
VTWEG
SPART
HIEZU04
MVGR1
ZZPRODH1
MATNR
WERKS
ABSAT
LFIMG
OAUME
ZZSALES_12
ZZSALES_24
FROM S889
INTO CORRESPONDING FIELDS OF TABLE T_S889
WHERE VRSIO EQ '000'
AND SPMON EQ P_MONTH
AND BZIRK EQ P_SADIS
AND KDGRP EQ P_CUGRP
AND VTWEG EQ P_SADCH
AND SPART EQ P_SADIV
AND HIEZU04 EQ P_CUPAR
AND MVGR1 EQ P_MAGRP
AND ZZPRODH1 EQ P_PRHIE
AND WERKS EQ P_PLANT
AND MATNR IN S_MATNR.
From the above satement,for eg. if I give P_MONTH, P_SADIS, I am getting the records which are having blank values for the remaining fields.But if I put OR condition then all the data is being retrieved irrespective of the select stmt.
Please help on this. Thanx in advance.