‎2008 Aug 27 5:34 AM
Hi experts,
I am having 6 records in itab.
how to select 3rd height value.
1 100
2 130
3 90
4 90
5 100
6 120.
Please give me code.
I think first sort and next delete adjacent duplicate records next?
‎2008 Aug 27 6:04 AM
Delete adjacent duplicates wont work here because the combination of two fields is unique. If you want to read exactly the third record then go for READ with INDEX 3.
If you mean you want to select the record with third highest value, then please specify if you are looking for the value in field1 or field 2.
‎2008 Aug 27 5:37 AM
‎2008 Aug 27 5:38 AM
hi praven
sort itab by descending.
delete adjacent duplicates of itab comapring <field>
read table itab index 3.
regards
deva
‎2008 Aug 27 5:38 AM
Hi Dude,
first U delete adjacent duplicates from itab,
Then U sort the itab by Descending .
Then U read itab with sy-tabix = 3.
Hope this helps U.
‎2008 Aug 27 6:04 AM
Delete adjacent duplicates wont work here because the combination of two fields is unique. If you want to read exactly the third record then go for READ with INDEX 3.
If you mean you want to select the record with third highest value, then please specify if you are looking for the value in field1 or field 2.
‎2008 Aug 27 6:10 AM
‎2008 Aug 27 6:24 AM
Then just sort the internal table in the descending order based on F2, and read the index at 3.
SORT itab DESCENDING by F2.
READ table ITAB index 3 INTO wa_itab.
WRITE wa_itab-f2.
this will give you the required value
‎2008 Aug 27 6:26 AM
Hi,
There wont be much changes needed even if you want to read teh third record based on field2.
You need to sort the internal table based on second field and follow the same process suggested by others.
sort itab by field2 descending
delete adjacent duplicates conparing field2
read itab with index 3
Hope this will help.
Regards,
Swarna Munukoti.
Edited by: Swarna Munukoti on Aug 27, 2008 7:27 AM
‎2008 Aug 27 6:04 AM
Hi,
plz try this way :
DATA: BEGIN OF TYPE_ITAB,
COL1 TYPE I,
COL2 TYPE I,
END OF TYPE_ITAB.
DATA: ITAB LIKE SORTED TABLE OF TYPE_ITAB WITH UNIQUE KEY COL1.
FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
READ TABLE ITAB ASSIGNING <FS> INDEX 3.
....
<FS> will have 3 and 90 values i.e. 3rd record.
hope this helps.
thanx,
dhanashri.