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

internal table

Former Member
0 Likes
817

How to find Maximum Value in Internal Table

There is one internal table containing 3 columns.

I want to find the maximum value of 2nd column in that internal table . If I use loop at tab, that becomes performance issue, when there are more no. of records.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
804

hi,

sort the table by ascending/descending order on the respective columns.. the first row in itab will give the least/largest value.. For further info type sort and press f1 help.

Regards.

7 REPLIES 7
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
804

Hi,

sort itab by column2 descending.

read itab into wa index 1.

write wa-column2.

This will give the maximum value.Kindly reward points by clicking the star on the left of reply,if it ehlps.

Read only

0 Likes
804

i hope everyone else suggested the same...

Read only

Former Member
0 Likes
804

Hi,

Try to sort the internal table by that column in ascending/descending format.

Then read the 1st or the last entry of the internal table depending on the sorting type ( ascending/descending ).

Best regards,

Prashant

Read only

Former Member
0 Likes
804

Hi, chexk this sample code. you can do a similar one

tables : vbak.

parameters : p_vbeln like vbak-vbeln.

data : itab like table of vbak with header line.

select * from vbak into table itab where vbeln = p_vbeln.

*assume the second column is erdat

sort itab by erdat descending.

read table itab index 1.

write : itab-erdat.

Read only

Former Member
0 Likes
804
sort itab by <field nedded>.
read table itab index 1.

Message was edited by: Deepak K

Read only

Former Member
0 Likes
805

hi,

sort the table by ascending/descending order on the respective columns.. the first row in itab will give the least/largest value.. For further info type sort and press f1 help.

Regards.

Read only

hymavathi_oruganti
Active Contributor
0 Likes
804

THERE IS FN MAX.

IT WORKS ON N, I, P types.

MAX(SNO) gives maximum of SNO