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

table record query

former_member630092
Participant
0 Likes
797

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
Read only

venkat_o
Active Contributor
0 Likes
762

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

Read only

0 Likes
762

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

Read only

Former Member
0 Likes
762

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

Read only

0 Likes
762

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.

Read only

Former Member
0 Likes
762

Hi,

You can also use this with select statement

ORDER BY PRIMARY KEY DESCENDING

Regards

Ahsan

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
762

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

Read only

Former Member
0 Likes
762

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

Read only

former_member630092
Participant
0 Likes
762

SOLVED