03-12-2007 9:44 AM
hi all
I have a ZTABLE which contains fields as NAME, DATE ,TIME and STATUS. Entries are
Eg: ztest 01.01.2005 12:05:10 1
ztest 12.01.2005 15:05:10 1
ztest1 23.01.2005 12:05:10 1
ztest1 05.04.2005 05:05:10 1
ztest1 15.10.2005 05:05:10 1
ztest1 15.10.2005 15:05:10 1
Now I need to fetch the latest data and latest time. So I need ztest1 15.10.2005 15:05:10 1.
How can we retrieve it. Even If i use SORT ZTABLE BY DATE TIME DESCENDING I am not getting the lastest date and latest time
Kinldy help
Points will be rewarded
Thanksin advance
03-12-2007 9:46 AM
You need to define the table fields for date with types D (LIKE SY-DATUM) and for those with time LIKE SY-UZEIT. Then only sorting will be meaningful. Also ensure that the fields are formatted in DDMMYYYY for date and HHMMSS for time, these are the interal representations for date and time and sorting will then respect them
SORT ZTABLE BY DATE DESCENDING TIME DESCENDING
If ZTABLE is a database table, first fetch the records to a internal table using
SELECT * FROM ZTABLE INTO ITAB WHERE ...
then SORT ITAB BY DATE DESCENDING TIME DESCENDING
03-12-2007 9:47 AM
hai,
try this once.
SORT ZTABLE BY DATE DESCENDING TIME DESCENDING
03-12-2007 9:48 AM
hi,
You need to define the table fields for date with types D (LIKE SY-DATUM) and for those with time LIKE SY-UZEIT
and use SORT ZTABLE DESCENDING BY DATE TIME
03-12-2007 9:48 AM
you cannot sort a ZTABLe
try this..
select max( date ) into v_date from ztable.
select max( time ) into v_time from ztable.
03-12-2007 9:49 AM
Hi Jayasree,
You should use SORT ZTABLE BY DATE DESCENDING TIME DESCENDING. Because for field DATE if the order is not specified, it will be sorted in ASCENDING order which is default sorting order.
Regards,
Vishnu Priya
03-12-2007 9:52 AM
03-12-2007 9:56 AM
SELECT -
FROM ZTABLE INTO ITAB WHERE condition ...
then
SORT ITAB BY <b>DATE DESCENDING TIME DESCENDING</b>
Read itab index 1.
" for the latest hit .
so this will fetch the latest entry on date and time .
You need to do the operation on internal table .
regards,
vijay