‎2008 Jan 04 8:11 AM
Dear all,
how to compare values in an internal table.The situsation is such that i have sorted my internal table based on material.Now that material has multiple rates based on customer.I want to display only the highest
rate of the material.Currently it is displaying all.
plz help
‎2008 Jan 04 8:17 AM
hi,
if u have the rates in that table sort it by marerial and rate.
now the highest rate comes at the end (of a material)
now use at end of <rate field>.
write..........
endat.
‎2008 Jan 04 8:17 AM
hi,
if u have the rates in that table sort it by marerial and rate.
now the highest rate comes at the end (of a material)
now use at end of <rate field>.
write..........
endat.
‎2008 Jan 04 8:17 AM
sort itab by matnr rate descending.
data:wk_tabix type sy-tabix.
loop at itab.
wk_tabix = sy-tabix.
at new matnr.
read table itab index wk_tabix.
if sy-subrc = 0.
move corresponding itab to itab2.
append itab2.
endif.
endat.
endloop
at last the itab2 will contain the records u preferred
‎2008 Jan 04 8:18 AM
Hi,
You can display with the help of control break statements.
Apart from sorting table by material, sort by rates as well but in descending order.
if the fields are matnr rate customer
sort by matnr
rate descending.
loop at itab.
lv_tabix = sy-tabix.
at new matnr.
read table itab index lv_tabix.
write : itab-matnr, itab-rate.
end at.
endloop.
Regards
Sailaja.
‎2008 Jan 04 8:22 AM
Hi Rahul,
Sort Ur Internal Table based on Material and Rate Descending order.
Loop at itab.
At New Material.
Display itab-values...
endat.
endloop.
Try that.
awrd points if useful
Bhupal
‎2008 Jan 04 8:25 AM
Hi Rahul,
Use the following psuedo code.
Loop at itab into wa_itab.
at new matnr.
clear : highest_rate.
endat.
if wa_itab-rate > highest_rate.
highest_rate = wa_itab-rate.
endif.
at end of matnr.
write : wa_itab-matnr, wa_itab-customer, highest_rate.
endat.
endloop.
Check out this code I wrote similar code one. It is simple try it out.
All the very best.
- Vamsi Krishna.
‎2008 Jan 04 8:25 AM
hi rahul
use max(field name) in the select statement.
So that you will get only highest value.
the statement will be like this:
select max(netwr) from ekpo where matnr = p_matnr.
If this is useful dont forget to award poins.