02-13-2010 4:37 AM
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 ?
02-13-2010 4:47 AM
<li>Use SELECT-ENDSELECT query with the same WHERE condition. Thanks Venkat.O
02-13-2010 5:31 AM
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
02-13-2010 6:22 AM
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
02-13-2010 12:13 PM
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.
02-13-2010 5:03 AM
Hi,
You can also use this with select statement
ORDER BY PRIMARY KEY DESCENDING
Regards
Ahsan
02-13-2010 7:37 AM
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
02-13-2010 2:16 PM
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
02-20-2010 8:58 AM