12-13-2011 1:43 AM
HI All,
I have worte the belwo select statement to get the records from 2 tables and counting ans summing based some paraaters.
Internal table structure
------------------------------------------------------------------
* bukrs TYPE dfkkinvdoc_i-bukrs,
* budat TYPE dfkkinvdoc_h-budat,
* waers TYPE dfkkinvdoc_i-waers,
* count TYPE i,
* menge TYPE dfkkinvdoc_i-menge,
* betrw TYPE dfkkinvdoc_i-betrw,
--------------------------------------------------------------------
Select statement
SELECT a~budat
b~bukrs
b~waers
COUNT(*)
SUM( b~menge ) AS menge
SUM( b~betrw ) AS betrw
INTO CORRESPONDING FIELDS OF TABLE lt_data
FROM dfkkinvdoc_h AS a
INNER JOIN dfkkinvdoc_i AS b
ON a~invdocno = b~invdocno
WHERE a~invdocno IN s_invno
AND a~inv_process IN r_proce
AND a~inv_type IN r_type
AND a~inv_category IN r_cate
AND a~budat IN r_crdate
AND b~itemtype = 'ZXXXXX' GROUP BY b~bukrs a~budat b~waers.
but the count field in internal table is not getting filled, except that i got every thing is fine. could you please let me know you thoughts on the below.
Thanks,
Raghu.
Edited by: Raghu on Dec 13, 2011 7:14 AM
12-13-2011 4:20 AM
Hi,
For This You Need to Maintain Particular Field For Count Function Then Only You Will Get The Count Value
i.e,The Syntax Of Count() is,
SELECT COUNT(*) FROM table_name.
For Your Issue You need to maintain Count(*) and Then Provide Table Name.
I Think This will Give Some Idea To you.
Warm Regards,
PavanKumar.G
12-13-2011 4:21 AM
Hi Raghu,
To count internal table entries use this statement
data : count type i.
Describe table internaltablename lines count.
The above statement counts the internal table contents and place it in the count variable.
Note : Here count is a variable you need to declare .
Regards,
G.Aditya
12-13-2011 4:41 AM
12-13-2011 4:52 AM
what i have observed that many times aggregate function( count,sum,min,max) does not able to identify the corresponding fields of internal table.
instead of using into correspinding fields try into table itab.
try:
select a
b
count( * )
from ztable into itab where..... group by a b. keep internal table structure same as in select statement.
i m not sure whether this works but give it atleast a single try!
12-13-2011 5:51 AM
Hi,
please have a look at this sample:
REPORT zsmarcbabl .
TYPES: BEGIN OF x_mara,
matnr TYPE matnr,
count TYPE sytfill,
werks TYPE werks_d,
END OF x_mara.
DATA: xs_mara TYPE x_mara.
DATA: xt_mara TYPE TABLE OF x_mara.
SELECT-OPTIONS: xp_matnr FOR xs_mara-matnr.
START-OF-SELECTION.
SELECT a~matnr AS matnr
COUNT( * ) AS count
MAX( c~werks ) AS werks FROM mara AS a
INNER JOIN marc AS c
ON c~matnr = a~matnr
INTO CORRESPONDING FIELDS
OF TABLE xt_mara
WHERE a~matnr IN xp_matnr
GROUP BY a~matnr.
loop at xt_mara
into xs_mara.
write: /1 xs_mara-matnr,
xs_mara-count,
xs_mara-werks.
endloop. "xt_mara
Regards,
Klaus
12-13-2011 3:54 PM
Hi All,
Its been solved by using select and endselect, earlier i thougt of avioding this loop.
Anyway thanks for all your promot responses.
Thanks,
Raghu.
12-15-2011 8:42 AM
Hi,
For This You Need to Maintain Particular Field For Count Function Then Only You Will Get The Count Value
i.e,The Syntax Of Count() is,
SELECT COUNT(*) FROM table_name.
For Your Issue You need to maintain Count(*) and Then Provide Table Name.
I Think This will Give Some Idea To you.
Warm Regards,
PavanKumar.G