‎2009 Jan 22 5:09 AM
Hi,
I have following data into internal tab as
item1 item2 item3 value
A a a1 10
A a a1 20
A a a1 30
B b b1 50
B b b1 60
B b b1 50.
C c c1 6.
C c c1 7.
Now i want output as max values only.
item1 item2 item2 value
A a a1 30
B b b1 60
C c c1 7.
i can do it during select query and then save into internal table.but requirement is after pulling data into internal tab,then trying to find max value.
Thanks..
‎2009 Jan 22 5:16 AM
Hi,
try this.
declare an another internal table itab1.
SORT itab by item1 value descending.
loop at itab.
read table itab1 with key item1 = itab-item1 item2 = itab-item2 item3 = itab-item3.
if sy-subrc eq 4.
move records to itab1.
endif.
Edited by: Sathish Reddy on Jan 22, 2009 10:53 AM
‎2009 Jan 22 5:12 AM
Hi,
First sort internal table in desending order and take first reord of the each block record Use controlling commads.
Regards
Md.MahaboobKhan
‎2009 Jan 22 5:14 AM
This is just a suggetsion. i have not tried my code yet. Have two internal tables. In one, copy all the values.The second internal table needs to have an additional field to calculate the sum. In the second, loop through the first internal table and keep adding when the item ID is same into the additional field.
Hope this helps.
Thanks,
Saipriya
‎2009 Jan 22 5:15 AM
Hi anwar,
1. Sort your table like this
SORT TABLE itab BY item1 item2 item3 value
2. Loop at your table to retrieve the highest value like this
DATA: end3 TYPE c.
LOOP AT itab INTO wa.
AT END OF item3.
MOVE 'X' TO end3.
ENDAT.
IF item3 EQ 'X'.
WRITE: item1, item2, item3, value.
CLEAR item3.
ENDIF.
ENDLOOP.
regards,
Peter
‎2009 Jan 22 5:16 AM
Hi,
Sort the internal table in desending order and Check first record from each block of recordsUse At commad in taht if condition.
Regards
Md.MahaboobKhan
‎2009 Jan 22 5:16 AM
Hi,
try this.
declare an another internal table itab1.
SORT itab by item1 value descending.
loop at itab.
read table itab1 with key item1 = itab-item1 item2 = itab-item2 item3 = itab-item3.
if sy-subrc eq 4.
move records to itab1.
endif.
Edited by: Sathish Reddy on Jan 22, 2009 10:53 AM
‎2009 Jan 22 5:33 AM
Hi
Sort the ITAB by item1 item2 item3 ascending value descending
then use delete adjacent duplicates from ITAB comparing item1 item2 item3 value.
This will have only max value record based on value.
Regards
Shiva
‎2009 Jan 22 5:43 AM