‎2007 Dec 20 7:06 AM
Hi all
I have data like
matnr erdat
10000 12/2/2007
10000 14/2/2007
10001 14/2/2007
I want only the maximum value. If I am using max function i m getting 00.00.0000..
plz help me...
‎2007 Dec 20 7:08 AM
Hi,
sort the internal table..
sort itab by matnr descending..
Now the first record will be the maximum one..in ur case it will be 10001.
Regards,
Nagaraj
‎2007 Dec 20 7:08 AM
Hi,
sort the internal table..
sort itab by matnr descending..
Now the first record will be the maximum one..in ur case it will be 10001.
Regards,
Nagaraj
‎2007 Dec 20 7:09 AM
Sort your table in Desending order on both the fields. and read first line form the same table.
‎2007 Dec 20 7:11 AM
But My Output is like :
matnr erdat
10000 14/2/2007
10000 12/2/2007
‎2007 Dec 20 7:15 AM
Hi Ankitha,
Select Single MAX( ERDAT ) from DBTABLE into <Structure> where....
Regards,
Satish
‎2007 Dec 20 8:31 AM
Hi...
If I am using MAX function it gives me 00.00.0000 value...
‎2007 Dec 20 8:44 AM
Hi Ankita,
Check this code. It's working fine.
SELECT MAX( ERSDA ) FROM MARA INTO ITAB-ERDAT .
here i am selecting max of ersda from mara and put it into the internal table variable.
Regards
Manoj Kumar
‎2007 Dec 20 7:10 AM
Hi,
If you are trying to fetch database table, check the below code
Select erdat into l_f_erdat
from dtab
UP TO 1 ROWS
where condtion ....
order by ERDAT descending.
endselect.
Data will be sorted in descending order and will give u the recent date.
‎2007 Dec 20 7:21 AM
Hi Ankita,
Check this program .
TYPES : BEGIN OF ty_tab,
matnr LIKE mara-matnr,
erdat LIKE mara-ersda,
END OF ty_tab.
DATA : itab TYPE STANDARD TABLE OF ty_tab INITIAL SIZE 0 WITH HEADER LINE.
START-OF-SELECTION.
MOVE '10000' TO itab-matnr.
MOVE '20070212' TO itab-erdat.
APPEND itab.
MOVE '10000' TO itab-matnr.
MOVE '20070214' TO itab-erdat.
APPEND itab.
MOVE '10001' TO itab-matnr.
MOVE '20070214' TO itab-erdat.
APPEND itab.
Sort itab by matnr descending erdat descending.
read TABLE itab index 1.
*Printed the maximum value
WRITE 😕 itab-matnr , itab-erdat.
This might will solve your problem.
Reward points,if useful.
Thanks
Manoj Kumar
‎2007 Dec 20 8:44 AM
Hi,
after fetching data from database uasing select stmt you just apply sort ooperation on that internal table .but
first give erdat and then matnr.
select ...
sort itab by erdat descennding matnr ascending.
or you just try this on your reqt
sort itab by erdat matnr descennding .
Regds
Sivaparvathi
Please reward points if helpful.................
‎2007 Dec 20 8:47 AM
Hi,
Try this code.
tables mara.
data v_ersda type mara-ersda.
select max( ersda ) into v_ersda from mara.
write v_ersda.
‎2007 Dec 20 8:49 AM
Can you try the below query for your requirement.
select single max( DISTINCT matnr ) max( ersda ) into (lv_matnr,lv_erdat)
from mara.