2009 Jun 16 11:11 PM
Hi All,
I want to find the count the no of Orders from VBAK for a combination of VBTYP and AUART.
Select Count(*) from vbak into table t_vbak where vbeln in s_vbeln
and vkorg eq p_vkorg
group by vbtyp auart.
This will only give the count.
I also need other data like erdat ernam and a bunch of other fields for this combination.
Do I need to select again from VBAK??
Any ideas.
Meghna
2009 Jun 17 2:09 AM
yes you have to select again from VBAK.
program code would look like this:
select count(*) from vbak where.....
select field1
field2
from vbak
where ....
2009 Jun 17 2:12 AM
Hi Meghna,
The statement you written above, Is it correct, Is it working,,,
I will not work as in count(*) it will not allow to select the data into a table and instead you need to write like this.
DATA : i_vbak type i.
Select Count(*) from vbak into i_vbak where vbeln in s_vbeln
Then you will get the no. of records,,,
It give No difference again to count Erdat or Ernam...! As it will be the same count.
If you need the Maximum then it will give you ethe maximum date but for time it give maximum time in 24 Hours but it may be different from the latest date time....
lets say you ha two record in April & May,, May you created time at 1 PM.. In April you created at 3 PM..
for max time,,,, you will get April,
And for max date you will get May,,,
remember that.
Count is for No. of records,,, & Max is for maximum no. or date or version,,,
Thanks & regards,
Dileep .C
2009 Jun 17 4:54 AM
Hi,
You have to select the fields again... Select count will just return a number i.e. the count of the conditions specified in the where condition... To fetch the individual field values you have to write a separate select statement to fetch it... You can put an initial check before going for the next database hit, so that if no records are found in the database for those selection criteria it will not hit the database again to fetch blank data...
2009 Jun 17 5:09 AM
Hi,
In this case you don't have to select Count(*) first, Directly select the necessary fields into the itab and after the select use Sy-dbcnt or Describe table to find the number of records returned.
Regards
Karthik D
2009 Jun 17 5:27 AM
Hi,
first u dont count the data,always u first select the data and split the data for your requirement and then use :
AT END OF FIELD NAME.
SUM.
ENDAT.
hope this will help u.
Regards,
K.Karthikeyan.
2009 Jun 17 5:37 AM
Hi Meghna,
its not possible to combine the query to get the count of a certain table or its fields and at the same time get some of its fields.
You would need to create two separate select statements: one SELECT statement to get the count and another SELECT statement to get the table fields and store it in an internal table.
Hope it helps!
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |