Application Development 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: 

table record query

former_member630092
Participant
0 Kudos

Hi,

A data base Table contains 10 reords that match my selcet query. But the report is picking the first matched record.

Can i pick the last matched recodr. (10th record ). If possible how ?

8 REPLIES 8

venkat_o
Active Contributor
0 Kudos

<li>Use SELECT-ENDSELECT query with the same WHERE condition. Thanks Venkat.O

0 Kudos

Hi,

i have to pick the last record updated in table ,

select kbetr kpein knumh kopos from konp into CORRESPONDING FIELDS OF table itab_konp

for all entries in itab_a515

where

KNUMH = itab_a515-knumh and

kschl = itab_a515-kschl.

where m i wrong ?

Thanks

Former Member
0 Kudos

hi Ravi,

Try this

Hi,


select kbetr kpein knumh kopos from konp into CORRESPONDING FIELDS OF table itab_konp
for all entries in itab_a515
where
KNUMH = itab_a515-knumh and
kschl = itab_a515-kschl
order by knumh kschl descending.


Delete adjacent Duplicates from itab_konp
comparing knumh kschl.

Regards,

Komal

Edited by: Komal Lakhwani on Feb 13, 2010 11:53 AM

0 Kudos

Hi,

We don't have the change log details in KONP.

So what you need to do is, after getting the data from KONP, you need to read the change documents from tables CDHDR and CDPOS. Sort this data set in DESCENDING ORDER by change date and time. Now read the first entry (INDEX 1). This is the only way you can get the last changed record.

But in your case what do you mean by last updated record? Hope you mean to say, for a given document and condition type, which item has been changed recently. If so, above logic will work.

Thanks,

Vinod.

Former Member
0 Kudos

Hi,

You can also use this with select statement

ORDER BY PRIMARY KEY DESCENDING

Regards

Ahsan

kesavadas_thekkillath
Active Contributor
0 Kudos

YOu can try

select * from mara up to 10 rows where mtart = 'HALB' order by matnr descending.

if sy-tabix > 2.

exit.

endif.

write mara.

endselect.

also read the documentation of 'up to' statement.

or pick it into internal table sort it descending and read index 1

former_member183990
Active Contributor
0 Kudos

hello Ravi

if you have time field in your table

you can make use of aggregate statements to achieve your requirements

like select max..

try putting

F1 help on this

and hope it will be usefull

cheers

S.Janagar

former_member630092
Participant
0 Kudos

SOLVED