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

problem in select single statement : its urgent

Former Member
0 Likes
860

Dear ,

i written one select single stmt i.e

tables : ser03 .

SELECT SINGLE * FROM ser03

WHERE obknr = objk-obknr

AND bwart = '101'

AND shkzg = 'S'.

based on this select stmt their are 5 records in database table satisfying the select stmt where clause and this select stmt is picking the fourth record . why this record is picking forth record only even this 4th record is not most recently created record and nor old record this record is middle one if any one plz tell me . points must be given . to access most recently recreated record how to write select stmt. plz tell me .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
832

I donßt know the table SER03, but you are talking ybout "most recent". This indicates the existence of a column containg some sort of time information. So you have to


SELECT ... ORDER BY [time column] DESCENDING

Dear ,

i written one select single stmt i.e

tables : ser03 .

SELECT SINGLE * FROM ser03

WHERE obknr = objk-obknr

AND bwart = '101'

AND shkzg = 'S'.

based on this select stmt their are 5 records in database table satisfying the select stmt where clause and this select stmt is picking the fourth record . why this record is picking forth record only even this 4th record is not most recently created record and nor old record this record is middle one if any one plz tell me . points must be given . to access most recently recreated record how to write select stmt. plz tell me .

6 REPLIES 6
Read only

Former Member
0 Likes
833

I donßt know the table SER03, but you are talking ybout "most recent". This indicates the existence of a column containg some sort of time information. So you have to


SELECT ... ORDER BY [time column] DESCENDING

Read only

Former Member
0 Likes
832

Hi,

OBKNR is the only key field for table SER03, so I can't understand how your where clause can match 5 entries.

Anyway, if you select first into an internal table, then sort this table by your date field you can read the most recent entry.

Regards,

Nick

Read only

0 Likes
832

Dear ,

sorry this is select stmt

SELECT SINGLE * FROM objk

WHERE sernr = i_zequip-sernr

AND matnr = i_zequip-matnr.

Read only

0 Likes
832

Hi,

The you need to do as either Mike or I suggested, sort your set of values by the required date field then take the first (or last) record.

Regards,

Nick

Read only

Former Member
0 Likes
832

Hi,

hope this code will help you.

just added the mandt in the where condition.


SELECT SINGLE * FROM ser03
WHERE mandt = sy-mandt
AND obknr = objk-obknr
AND bwart = '101'
AND shkzg = 'S'.

reward if helpful,

teja.

Read only

mahaboob_pathan
Contributor
0 Likes
832

hi,

sort ser03 by obknr.

SELECT SINGLE * FROM ser03

WHERE obknr = objk-obknr

AND bwart = '101'

AND shkzg = 'S'.