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: 

To find maximum number

Former Member
0 Kudos

Hi All,

Is there any function to find the maximum number .For instance I have 10 numbers.Can I find the maximum number out of it using any function ( Not function module ).

Regards,

Vishu.

5 REPLIES 5

naimesh_patel
Active Contributor
0 Kudos

If they are in internal table you can use the SORT DESCENDING ..

Like:


SORT ITAB BY NUMBER DESCENDING.
READ ITAB INDEX 1.
WRITE : ITAB-NUMBER. " << HIGHEST NUMBER

Regards,

Naimesh Patel

ferry_lianto
Active Contributor
0 Kudos

Hi,

Where is the data stored? Is it in database table?

If it is you can use SELECT statement with aggregate (MAX) or SELECT statement with sort key (ORDER BY).

If it is stored in internal table then you can sort the internal table with descending order then read the first record.

Regards,

Ferry Lianto

0 Kudos

No it is not in the database table.I just have 10 numbers in my program.I want the highest number of it without passing them into an internal table and sorting them out.

Former Member
0 Kudos

Vishwanath,

sort and then display the last number. Small example.

REPORT zforum140 .

data : begin of itab OCCURS 0,
  data1 type c.
data: end of itab.
data: n type i.

do 5 TIMES.
  n = n + 1.
  itab-data1 = n.
  append itab.
  enddo.

  sort itab by data1.
  n = itab-data1.
  write:/ n.

Regards

Aneesh.

ferry_lianto
Active Contributor
0 Kudos

Hi Vishu,

Can you show your codes to build those 10 numbers?

Regards,

Ferry Lianto