02-14-2008 1:55 PM
Hi,
I am having internal table with some values..I
Ex :
No Name age lines
1 arun 12 1
1 arun 12 2
2 ram 13 1
2 ram 13 2
2 ram 13 3
3 manu 14 1
4 kam 17 1
5 chin 16 1
If i want to select the minimum of lines field for Ram..
02-14-2008 2:03 PM
Try this -
SORT itabt BY NAME LINES.
Read table itab with key Name = ' Ram'.
This will give the firat fiedl with RAM and Lines value minimum as table is sorted in ascending order.
Regards,
Amit
02-14-2008 2:00 PM
02-14-2008 2:03 PM
Try this -
SORT itabt BY NAME LINES.
Read table itab with key Name = ' Ram'.
This will give the firat fiedl with RAM and Lines value minimum as table is sorted in ascending order.
Regards,
Amit
02-14-2008 2:03 PM
Hi Mahesh,
can u please explain it clearly,
regards,
ravi shankar reddy
02-14-2008 2:06 PM
Hi,
You can achieve that that by using following steps on the internal table...
1) delete table int_tabl where name <> 'ram'
2) short int_tabl by lines ascending
3) read table int_table index 1.
you will get minium lines for ram.
hope this helps.
Rajesh
02-14-2008 2:08 PM
Hi,
You can try like this:
data : wa like line of itab,
c.
clear c.
loop at itab where Name = 'Ram'.
if sy-tabix = 0.
move corresponding itab to wa.
c = itab-lines.
else.
if itab-lines < c .
move corresponding itab to wa.
c = itab-lines.
endif.
endif.
endloop.
regards,
Himanshu
02-14-2008 2:14 PM
Hello,
Do like this.
DATA: BEGIN OF ITAB OCCURS 0,
NO(3),
NAME(10),
AGE(3),
LINE(3),
END OF ITAB.
ITAB-NO = 1.
ITAB-NAME = 'arun'.
ITAB-AGE = 12.
ITAB-LINE = 1.
APPEND ITAB.
ITAB-NO = 1.
ITAB-NAME = 'arun'.
ITAB-AGE = 12.
ITAB-LINE = 2.
APPEND ITAB.
ITAB-NO = 2.
ITAB-NAME = 'ram'.
ITAB-AGE = 13.
ITAB-LINE = 1.
APPEND ITAB.
ITAB-NO = 2.
ITAB-NAME = 'ram'.
ITAB-AGE = 13.
ITAB-LINE = 2.
APPEND ITAB.
ITAB-NO = 2.
ITAB-NAME = 'ram'.
ITAB-AGE = 13.
ITAB-LINE = 3.
APPEND ITAB.
ITAB-NO = 3.
ITAB-NAME = 'manu'.
ITAB-AGE = 14.
ITAB-LINE = 1.
APPEND ITAB.
SORT ITAB." BY LINE." DESCENDING.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING NO.
LOOP AT ITAB.
WRITE:/ ITAB-NO,ITAB-NAME,ITAB-AGE,ITAB-LINE.
ENDLOOP.
Vasanth
02-19-2008 1:59 PM