Application Development 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: 

maximum value

Former Member
0 Kudos

hii,

how to find the maximum value from the internal table field for each personel number?

for ex.

field

1

2

3

i want 3 as output.

thanks

18 REPLIES 18

Former Member
0 Kudos

Try sorting(desc)your internal table and pick the first record..

hope it helps.

Former Member
0 Kudos

data: begin of it occurs 3,

val type i,

end of it.

it-val = 100.

append it sorted by val.

it-val = 400.

append it sorted by val.

it-val = 200.

append it sorted by val.

read table it index 1.

write: / it-val.

Regards

Jayapriya

Former Member
0 Kudos

hi,

do you want to identify which cloumn has maximum value

Edited by: guest on Jan 28, 2009 9:33 AM

Former Member
0 Kudos

HI,

SORT ITAB BY <FIELD> DESCENDING.
READ ITAB INDEX 1.

Former Member
0 Kudos

Hi,

Try using

select MAX(field) from table.

Hope this helps.

Regards,

Deepthi.

Former Member
0 Kudos

Hi,

U can use SORT statement to achieve this.

SORT <internaltable> BY fieldname DESCENDING .

Then take the first value of this internaltable.

This will be the max value.

Hope this helps u,.

Thanks.

Former Member
0 Kudos

Hi

data: itab type table of ystudent with header line.

select * from ystudent into table itab.

sort itab descending by id descending.

read table itab index 1.

write itab-id.

Hope this helps

Regards,

Jayanthi.K

Former Member
0 Kudos

SORT TABLE ITAB BY PERNR DESCENDING.

READ TABLE ITAB INTO WA INDEX 1.

WA-PERNR is the max number

Former Member
0 Kudos

my code:

read table itab into wa with key pernr = was-pernr.

now where to write index 1.

thanks.

0 Kudos

Hi

Please be clear in asking questions

0 Kudos

ok i got it how to use index 1.

thanks

but output showing all 3 values in field , i want only one dats max

0 Kudos

Hi,

Sort the table by pernr and the field.

sort itab descending by pernr field1.

read table itab into wa with key pernr = was-pernr.

Now after this read statement, you can read the maximum value record.

0 Kudos

Hi,

After reading ur internal table using index.

u can move the value to another internal table know.

For ex:


SORT it_sum BY amount1 DESCENDING.

READ TABLE it_sum INTO wa_sum INDEX 1.
if sy-subrc eq 0.
  move: wa_sum-date to wa_res-date,
        wa_sum-amount1 to wa_res-amount1,
        wa_sum-amount2 to wa_res-amount2.
  append wa_res to it_res.
 endif.

Here the it_res table has the maximum value only.

Hope this helps u.

Thanks.

Former Member
0 Kudos

Hello

try this

Select Max from Per into Lt_pers

After that you have only the biggest values

regards

Chris

0 Kudos

but we can use (select max) with standard tables n not with internal table.

Former Member
0 Kudos

thanks all of u.

0 Kudos

Hi Aks,

If your field for which you want to get the maximun value is a integer field than just sort the internal table descending and read the first record as also told by others, like:

Sort itab by char descending.

Read table itab into wa index 1.

but is its not a integer field say its a character field with lenght more than 1, than its always better to change it to a interger field than get the maximun value otherwise it can give a incorrect value to you, as for character fields it will compare with the first character, like if the field value are '12' and '5', it will take '5' as greater as the first character in the second case is 5 and its greater than the first character of the first case which is 1.

With luck,

Pritam.

Former Member
0 Kudos

Hi,

Just sort your internal table in descending order and read the first row.

SORT ITAB BY PERNR DESCENDING.

READ TABLE ITAB INDEX 1.

ITAB-PERNR will be the biggest in the internal table ITAB.

Mubeen

Edited by: Mubeen Ahmed on Jan 29, 2009 4:52 PM