10-17-2007 10:03 AM
Hi Friends,
I have an internal table with two fields.
1.date
2.char field which contain value 'Y' or 'N'.
After appending the internal table i want to read the row with earliest date of all the records with [the char field value Y or
the char field value N].
Can anyone help me to resolve this issue.
Best regards,
Ramineni
10-17-2007 10:06 AM
Hi
sort the itab by DATE and CHAR field
read table itab index 1.
this will be the ealiest date for Y or N
Regards
Anji
10-17-2007 10:06 AM
Hi,
after u get the data in internal table..try like this..
sort itab by date descending..
the first record in itab is the latest record.
Reward if helpful.
Regards,
Nagaraj
10-17-2007 10:06 AM
10-17-2007 10:11 AM
hello....
what is the case if i have more than 2 values in the char field.....
I wanna retrieve
the latest date with char field = 'Y'
the latest date with char field = 'N'
the latest date with char field = 'O'
10-17-2007 10:17 AM
sort itab by date descending.
itab1[] = itab[].
delete itab1 where charfield ne 'Y'.
read table itab1 index 1.
if sy-subrc = 0.
*--latest record with charfield = 'Y'
endif.
clear itab1[].
itab1 = itab[].
delete itab1 where charfield ne 'N'.
read table itab1 index 1.
if sy-subrc = 0.
*--latest record with charfield = 'N'
endif.
clear itab1[].
itab1 = itab[].
delete itab1 where charfield ne 'O'.
read table itab1 index 1.
if sy-subrc = 0.
*--latest record with charfield = 'O'
endif.
10-17-2007 10:18 AM
SORT ITAB BY DATE.
READ TABLE ITAB WITH KEY CHAR_FIELD = 'Y'.
WRITE: / ITAB-DATE, ITAB-CHAR_FIELD.
READ TABLE ITAB WITH KEY CHAR_FIELD = 'N'.
WRITE: / ITAB-DATE, ITAB-CHAR_FIELD.
READ TABLE ITAB WITH KEY CHAR_FIELD = 'O'.
WRITE: / ITAB-DATE, ITAB-CHAR_FIELD.
10-17-2007 10:20 AM
Hi,
try like this
LOOP AT ITAB.
CASE CHAR.
WHEN 'Y'.
sort itab by date char.
WHEN 'N'.
sort itab by date char.
WHEN 'O'.
sort itab by date char.
endcase
endloop.
Regards,
Nagaraj
10-17-2007 10:22 AM
Hi,
Go through below code,
sort itab by date.
read table itab index 1.
temp_date = itab-date.
loop at itab where date = temp_date.
<ur logic>
endloop.
thanks!
Brunda
'Reward if useful'.