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
832

how to write a logic least marks and higest marks from internal table.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
816

Hope it will help you.

<REMOVED BY MODERATOR>

Highest Marks:-

sort internal table by field ascending.

read internal table index 1.

Lowest Marks:-

sort internal table by field descending

read internal table index 1.

Edited by: Alvaro Tejada Galindo on Feb 25, 2008 5:03 PM

8 REPLIES 8
Read only

matt
Active Contributor
0 Likes
816

Sort the internal table by the marks. Read the first and last record of the table.

matt

Read only

Former Member
0 Likes
817

Hope it will help you.

<REMOVED BY MODERATOR>

Highest Marks:-

sort internal table by field ascending.

read internal table index 1.

Lowest Marks:-

sort internal table by field descending

read internal table index 1.

Edited by: Alvaro Tejada Galindo on Feb 25, 2008 5:03 PM

Read only

Former Member
0 Likes
816

sort itab by field descending.

read table i_sort index 1.

move i_sort-field to gv_field.

gv_field is the max value.

sort itab by field ascending.

read table i_sort index 1.

move i_sort-field to lv_field.

lv_field is the leas value.

Regards,

Ajay

Read only

Former Member
0 Likes
816

Hi Krishna,

Say your internal table has MARKS field which holds marks.

data: low_marks type i,

high_marks type i,

v_lines type sy-tabix.

sort itab by marks.

*-- First record holds least marks

read table itab index 1.

if sy-subrc = 0.

low_marks = itab-marks.

endif.

*-- your last record holds highest marks

describe table itab lines v_lines.

read table itab index v_lines.

if sy-subrc = 0.

high_marks = itab-marks.

endif.

At this point low_marks holds least marks and high_marks holds highest marks

Read only

Former Member
0 Likes
816

sort itab by field descending.

read table itab index 1.

move i_sort-field to gv_field.

**************************gv_field is the max value.

sort itab by field ascending.

read table itab index 1.

move i_sort-field to lv_field.

****************************lv_field is the leas value.

Regards,

Ajay

Read only

Former Member
0 Likes
816

hi ,

if you sort the tabel by the marks field then first and last fields will be the lowest and highest values .

regards,

venkat.

Read only

Former Member
0 Likes
816

By using min and max functions we can get the values.

or

By using sorting the internal table by using ascending or descending

or

If you want to write some logic then by using sorting techniques you can find

Read only

Former Member
0 Likes
816

Hi,

You can do as below :


Sort itab by marks acsending.

read the table using index." First row will contain the lower value.

Again sort the itab by descending.

Sort itab by marks descending.
read the table using index." First row will contain the higher value.

Thanks,

Sriram Ponna.