01-28-2009 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
01-28-2009 8:05 AM
Try sorting(desc)your internal table and pick the first record..
hope it helps.
01-28-2009 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
01-28-2009 8:33 AM
hi,
do you want to identify which cloumn has maximum value
Edited by: guest on Jan 28, 2009 9:33 AM
01-28-2009 8:36 AM
01-28-2009 8:37 AM
Hi,
Try using
select MAX(field) from table.
Hope this helps.
Regards,
Deepthi.
01-28-2009 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.
01-28-2009 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
01-28-2009 8:48 AM
SORT TABLE ITAB BY PERNR DESCENDING.
READ TABLE ITAB INTO WA INDEX 1.
WA-PERNR is the max number
01-28-2009 9:28 AM
my code:
read table itab into wa with key pernr = was-pernr.
now where to write index 1.
thanks.
01-28-2009 9:33 AM
01-28-2009 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
01-28-2009 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.
01-28-2009 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.
01-28-2009 9:34 AM
Hello
try this
Select Max from Per into Lt_pers
After that you have only the biggest values
regards
Chris
01-28-2009 9:37 AM
but we can use (select max) with standard tables n not with internal table.
01-28-2009 11:40 AM
01-29-2009 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.
01-29-2009 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