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: 

Choosing the biggest value of the given value..

Former Member
0 Kudos

Hi

Suppose, I have say following values in my internal table:-

1

8

90

60

40

50

70

And I want to pick the largest of the given numbers in only one command.

How can I do that?

Thank You

7 REPLIES 7

Former Member
0 Kudos

U can do that using two statement.

SORT itab by F1 DESCENDING.

READ TABLE itab index 1.

The value of itab-F1 will give you the max value.

gopi_narendra
Active Contributor
0 Kudos

Hi

var is the highest number.

Sort the internal table,

describe int table lines Fill.

read itab index fill.

if sy-subrc = 0.

var = itab-field.

endif.

Regards

Gopi

Former Member
0 Kudos

Hi,

use below logic

sort itab by val descending.

read table itab index 1.

Regards

amole

anversha_s
Active Contributor
0 Kudos

hi,

chk this.

SORT ITAB BY VAL DESCENDING.

READ TABLE ITAB INDEX 1.

WRITE ITAB-VAL.

rgds

anver

pls mark all hlpful answers

0 Kudos

Thank you

but can I achieve the same result by writting a single command only instead of sorting and then selectiong?

Thank You

0 Kudos

Hi

U can use

select max(fieldname) from itab

where fieldname = your coulmn name

Regards

Pulkit Agrawal

former_member223537
Active Contributor
0 Kudos

Hi,

Well if you have data in internal table and then want to get the max. value then its not possible in single line.

If you are selecting data from a table, then its possible :

Select max ( amount )

from ZTABLE

into l_amount.

Best regards,

Prashant