‎2009 Jan 28 8:03 AM
hii,
how to find the maximum value from the internal table field for each personel number?
for ex.
field
1
2
3
i want 3 as output.
thanks
‎2009 Jan 28 8:05 AM
Try sorting(desc)your internal table and pick the first record..
hope it helps.
‎2009 Jan 28 8:31 AM
data: begin of it occurs 3,
val type i,
end of it.
it-val = 100.
append it sorted by val.
it-val = 400.
append it sorted by val.
it-val = 200.
append it sorted by val.
read table it index 1.
write: / it-val.
Regards
Jayapriya
‎2009 Jan 28 8:33 AM
hi,
do you want to identify which cloumn has maximum value
Edited by: guest on Jan 28, 2009 9:33 AM
‎2009 Jan 28 8:36 AM
‎2009 Jan 28 8:37 AM
Hi,
Try using
select MAX(field) from table.
Hope this helps.
Regards,
Deepthi.
‎2009 Jan 28 8:38 AM
Hi,
U can use SORT statement to achieve this.
SORT <internaltable> BY fieldname DESCENDING .
Then take the first value of this internaltable.
This will be the max value.
Hope this helps u,.
Thanks.
‎2009 Jan 28 8:45 AM
Hi
data: itab type table of ystudent with header line.
select * from ystudent into table itab.
sort itab descending by id descending.
read table itab index 1.
write itab-id.
Hope this helps
Regards,
Jayanthi.K
‎2009 Jan 28 8:48 AM
SORT TABLE ITAB BY PERNR DESCENDING.
READ TABLE ITAB INTO WA INDEX 1.
WA-PERNR is the max number
‎2009 Jan 28 9:28 AM
my code:
read table itab into wa with key pernr = was-pernr.
now where to write index 1.
thanks.
‎2009 Jan 28 9:33 AM
‎2009 Jan 28 9:41 AM
ok i got it how to use index 1.
thanks
but output showing all 3 values in field , i want only one dats max
‎2009 Jan 28 9:44 AM
Hi,
Sort the table by pernr and the field.
sort itab descending by pernr field1.
read table itab into wa with key pernr = was-pernr.
Now after this read statement, you can read the maximum value record.
‎2009 Jan 28 9:53 AM
Hi,
After reading ur internal table using index.
u can move the value to another internal table know.
For ex:
SORT it_sum BY amount1 DESCENDING.
READ TABLE it_sum INTO wa_sum INDEX 1.
if sy-subrc eq 0.
move: wa_sum-date to wa_res-date,
wa_sum-amount1 to wa_res-amount1,
wa_sum-amount2 to wa_res-amount2.
append wa_res to it_res.
endif.
Here the it_res table has the maximum value only.
Hope this helps u.
Thanks.
‎2009 Jan 28 9:34 AM
Hello
try this
Select Max from Per into Lt_pers
After that you have only the biggest values
regards
Chris
‎2009 Jan 28 9:37 AM
but we can use (select max) with standard tables n not with internal table.
‎2009 Jan 28 11:40 AM
‎2009 Jan 29 1:20 PM
Hi Aks,
If your field for which you want to get the maximun value is a integer field than just sort the internal table descending and read the first record as also told by others, like:
Sort itab by char descending.
Read table itab into wa index 1.but is its not a integer field say its a character field with lenght more than 1, than its always better to change it to a interger field than get the maximun value otherwise it can give a incorrect value to you, as for character fields it will compare with the first character, like if the field value are '12' and '5', it will take '5' as greater as the first character in the second case is 5 and its greater than the first character of the first case which is 1.
With luck,
Pritam.
‎2009 Jan 29 3:51 PM
Hi,
Just sort your internal table in descending order and read the first row.
SORT ITAB BY PERNR DESCENDING.
READ TABLE ITAB INDEX 1.
ITAB-PERNR will be the biggest in the internal table ITAB.
Mubeen
Edited by: Mubeen Ahmed on Jan 29, 2009 4:52 PM