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

Finding the Max Number

Former Member
0 Likes
387

Hi All,

I have table from which i have to find out the site and its max number.i fetch all the data in ITAB. now i am not understanding wat to do to find the max number.here is my problem...

Site Number

1001 2

1001 1

1001 5

1001 50

1001 30

1002 1

1002 100

1002 10

now i have all this data in my ITAB and den it is printing in my alv.

now i want data to be like this...

Site Number

1001 50

1002 100

plz tell me wat to do...as i am very new in this area.

Thanx,

Vaneet

Moderator Message: Basic Post. Put some effort of your own first.

Edited by: kishan P on Dec 10, 2010 3:42 PM

Hi All,

I have table from which i have to find out the site and its max number.i fetch all the data in ITAB. now i am not understanding wat to do to find the max number.here is my problem...

Site Number

1001 2

1001 1

1001 5

1001 50

1001 30

1002 1

1002 100

1002 10

now i have all this data in my ITAB and den it is printing in my alv.

now i want data to be like this...

Site Number

1001 50

1002 100

plz tell me wat to do...as i am very new in this area.

Thanx,

Vaneet

Moderator Message: Basic Post. Put some effort of your own first.

Edited by: kishan P on Dec 10, 2010 3:42 PM

1 REPLY 1
Read only

PedroGuarita
Active Contributor
0 Likes
354

Pretty straigth forward.

Just sort the internal table by site number descending. That way you know you always have the highest number in the first record for the site.


sort itab by site number descending.

loop at itab.
  at new site.
     itab2-site = itab-site.
     itab2-number = itab-number.
     append itab.
  endat.
  continue.
endloop.