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

Function Module

Former Member
0 Likes
834

Hi all,

I have a Z table with a field with numeric values.

I need to get the highest value from that field.

I feel it'll be a performance issue to select all records & search the highest value by looping.

So, does anyone know any function module which does the same..?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
805

You can select all the records into an internal table and then sort the internal table on the numeric field descending.

Regards

Mohamed Mansoor

7 REPLIES 7
Read only

Former Member
0 Likes
806

You can select all the records into an internal table and then sort the internal table on the numeric field descending.

Regards

Mohamed Mansoor

Read only

Former Member
0 Likes
805

1. SELECT using ORDER BY clause into Table directly and read the first entry

2. SELECT into a SORTED Table directly and read the first entry

3. SELECT into a table, SORT manually using SORT command and then read the first entry.

SORT has to happen by the field you are looking for.

Regards,

Ravi

Note - Please mark all the helpful answers

Read only

amit_khare
Active Contributor
0 Likes
805

Hi,

you may use Select with MAX.

SELECT MATNR MAX(mblnr) into table itab

from mseg

group by matnr

where matnr in s_matnr.

Regards,

Amit

Read only

Former Member
0 Likes
805

Hi,

Select MAX( <col> ) INTO lv_max

FROM ztable.

DATA: lv_max TYPE ztable-<col>.

Regards,

Goutham

Read only

Former Member
0 Likes
805

hi,

Select all entries of Z table to an internal table.

Sort itab in the descending fashion wrt the field you are looking for highest value

Then you can read the itab with index 1 and that is the highest value of that particular field

Read only

h_senden2
Active Contributor
0 Likes
805

Just use a select statement like :

select max( seatsmax ) into l_max from sflight.

Read only

Former Member
0 Likes
805

use aggregate function while selecting....