Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Internal Table Value comparison

rahul2000
Contributor
0 Likes
783

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
760

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.

6 REPLIES 6
Read only

Former Member
0 Likes
761

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.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
760

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

Read only

Former Member
0 Likes
760

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.

Read only

Former Member
0 Likes
760

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

Read only

Former Member
0 Likes
760

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.

Read only

Former Member
0 Likes
760

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.