Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

select statement

Aiolos
Active Participant
0 Likes
1,118

dear all,

i want to select a record,but i don't know how to do it, can you help me ?

for example

budat matnr

20081027 1

20081027 2

20081028 2

20081029 3

20081029 2

what i want to select is that,the element budat,the day 20081028 there is only one record.

if there are several records with the same budat,there records are not what i want.

could you tell me how to write this kind of select statement.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,099

use select count <fld> .............

and check if count = 1 then append it into another internal table.

11 REPLIES 11
Read only

Former Member
0 Likes
1,099

Hi,

Make use of DISTINCT key word in the select statement.

Thanks,

Sriram Ponna.

Read only

former_member585060
Active Contributor
0 Likes
1,099

Hi,

SELECT SINGLE * FROM <table> WHERE budat = p_budat

AND matnr = p_matnr.

Regards

Bala Krishna

Read only

Former Member
0 Likes
1,099

Hi,

First u can get all the entries in an internal table and use DELETE ADJACENT DUPLICATES FROM ITAB COMPARING BUDAT statement to delete the multiple records.

Read only

0 Likes
1,099

HI,

Please ignore my previous reply. Delete adjacent duplicates wil not fulfill ur requirement. It will have the other entries also.

Read only

Former Member
0 Likes
1,099

Hello,

First get all the records then loop the internal table and check the budat and filter the according to u r requirements.

or Use the delete adjucent dublicate records comparing budat matnr

Edited by: Santosh Marupally on Oct 30, 2008 9:33 AM

Read only

Former Member
0 Likes
1,099

Hi,

To select a single record with a given selection criteria use the following .

tables: mara.
select single * into mara
  where matnr = '123456'.
write: / mara-matnr.

To select multiple records use the following

tables: mara.
data: gt_mara type table of mara.
select * into table gt_mara
  from mara
    where mtart = 'ABC'.
loop at gt_mara into mara.
write: / mara-matnr.
endloop.

Darren

Read only

Former Member
0 Likes
1,100

use select count <fld> .............

and check if count = 1 then append it into another internal table.

Read only

Aiolos
Active Participant
0 Likes
1,099

hi all, i am sorry that i have not explained my question clearly.

before i use select, i dont know the data in the table.

what i want to get is the date which is only one record in the table.

and i think i should use key word count,but i dont know how to use it.

and there is not condition in my select statement,the only conditon is which date there is only one record in the table.

Read only

Former Member
0 Likes
1,099

press f1 on count you will know

Read only

Former Member
0 Likes
1,099

Hi,

tables: mara.

data:lt_mara like mara occurs o with header line.

select * from mara into lt_mara

where budat = pa_budat.

loop at lt_mara.

write: / lt_mara-matnr,lt_mara-budat.

endloop.

Read only

Former Member
0 Likes
1,099

Use AT NEW sytax inside the loop.