10-10-2007 6:58 PM
Hi , I have to count the number of entries in the mara table which have the material number '10006877' . I do not want to select it to an internal table and count it .
Is there a direct count statement that can be added to the usual select to get this.
A code will be useful
10-10-2007 7:02 PM
Hi,
You can use SELECT COUNT statement.
TABLES MARA.
DATA COUNT TYPE I.
SELECT COUNT( * )
INTO COUNT
FROM MARA
WHERE <condition>.
WRITE: / COUNT.
Regards,
Ferry Lianto
10-10-2007 7:02 PM
Hi,
You can use SELECT COUNT statement.
TABLES MARA.
DATA COUNT TYPE I.
SELECT COUNT( * )
INTO COUNT
FROM MARA
WHERE <condition>.
WRITE: / COUNT.
Regards,
Ferry Lianto
10-10-2007 7:04 PM
Material number is the primary key in MARA. so there will always be only one record with the material 10006877
10-10-2007 7:07 PM
once you select the data from MARA Table then use SY-DBCNT System variable,it will show number of entries
Thanks
Seshu
10-10-2007 7:05 PM
SELECT COUNT ( * ) INTO w_COUNT FROM MARA.
will give you the number of entries in mara table.
Cheers
VJ
10-10-2007 7:07 PM
10-10-2007 7:10 PM
Since MATNR is the key, there will be 0 or 1 entry with that value. It will be quick to:
SELECT SINGLE matnr FROM MARA
WHERE matnr = '10006877'.
IF sy-subrc = 0.
* One record
ELSE.
* No records
ENDIF.
You may have to run the material number through a conversion exit before doing the SELECT.
Rob