08-28-2013 5:02 AM
hello everyone,
I have a table like bellow.
KALNR | KADKY | POSNR | MATNR | WERTN |
100200250 | 01.04.2013 | 9 | 6001220 | 0.02 |
100200250 | 01.05.2013 | 9 | 6001220 | 0.02 |
100200250 | 01.06.2013 | 9 | 6001220 | 0.02 |
100200250 | 01.07.2013 | 9 | 6001220 | 0.02 |
100200250 | 01.04.2013 | 10 | 6000920 | 0.02 |
100200250 | 01.05.2013 | 10 | 6000920 | 0.02 |
100200250 | 01.06.2013 | 10 | 6000920 | 0.02 |
100200250 | 01.07.2013 | 10 | 6000920 | 0.02 |
So I need to get the maximum date value in this table (01.07.2013) . So how can I get this value using a SELECT command in ABAP.
08-28-2013 5:54 AM
Hello Anuradha.
Use MAX function.
select max( COLUMN ) from TABLE into dt.
Refer ABAPDOCU tcode.
Regards.
08-28-2013 6:02 AM
08-28-2013 6:12 AM
DATA d type d.
select max( KADKY ) from TABLE into d.
in this situation DAta store in kadky table as yyyymmdd
so its pick up maximum on base of amount.
08-28-2013 6:14 AM
Hi,
A simple example..
Replace xxx by ur structure name & 'YYY' table name.
DATA : d type s_date.
TYPES: BEGIN OF ty_xxx,
KADKY TYPE S_DATE,
END OF ty_xxx.
DATA: t_xxx TYPE TABLE OF ty_xxx,
x_xxx TYPE ty_xxx.
SELECT KADKY from YYY INTO TABLE t_xxx.
IF d is INITIAL.
LOOP AT t_sflight INTO x_sflight.
d = x_xxx-KADKY.
ENDLOOP.
ELSE.
LOOP AT t_xxx INTO x_xxx.
IF d > x_xxx-KADKY .
d = x_xxx-KADKY
.
ENDIF.
ENDLOOP.
ENDIF.
WRITE d.
Regards,
Farid.
08-28-2013 6:15 AM
Hi anuradha,
Use Max Function to get the maximum value of column in table.
I have tried this,
select MAX( MATCH_DATE -->( Column) )
FROM zapt_header_tb---> (Table)
into date.
if sy-subrc EQ 0.
WRITE date.
ENDIF.
This will give the maximum date .
Regards,
Sivaganesh
08-28-2013 6:23 AM
Hi,
Either try as praveen suggested or
select the data required into an internal table.
Sort the internal table by KADKY descending.
Read the first line from the internal table.
Thanks.
08-28-2013 6:27 AM
Hi,
select kalnr max(kadky) posnr matnr wertn
from some_table
into some_other_table
where some_condition.
08-28-2013 6:38 AM
Hi,
First declare a variable of type sy-datum.
DATA : v_date TYPE sy-datum.
Then use the below select query to fetch the maximum date from the table.
While writng the select query please take care of the spaces between the parentheses.
SELECT MAX( ADKY ) FROM <table_name> INTO v_date.
WRITE : v_date.
Regards,
Riju Thomas.
08-28-2013 7:10 AM
Hi,
I guess you need to get max date value from your internal table. If this is the case then simply follow it,
SORT itab by kadky DESCENDING.
READ TABLE itab INDEX 1.
WRITE :/ itab-kadky.
by this you will get the max field value from your internal table.
08-28-2013 7:45 AM
Hi , Please check the code below,,
TYPES: BEGIN OF TY_001,
KALNR TYPE TABLE-KALNR,
KADKY TYPE TABLE-KADKY,
POSNR TYPE TABLE-POSNR,
MATNR TYPE TABLE-MATNR,
WERTN TYPE TABLE-WERTN,
TYPES:END OF TY_001.,
DATA LS_TABLINE TYPE TY_001.
SELECT KALNR MAX(KADKY) POSNR MATNR WERTN
INTO LS_TABLINE "--->LOCAL STRUCTURE .
FROM <TABLE>
WHRER <ANY CONDITIONS>
POINTS PLEASE.....
08-28-2013 9:49 AM
Hi,
If you have data in data base table use Francy 001 reply, suppose you have data in internal table use ABAP 2 reply.
Regards,
John.
09-24-2013 11:55 AM
Hi,
To fetch only date value
SELECT KADKY FROM <dbtable> INTO LV_KADKY WHERE <field> = cond1 ORDER BY KADKY DESCENDING.
ENDSELECT.
to fetch a single record.
SELECT KALNR KADKY POSNR MATNR WERTN FROM <dbtable> INTO WA_1 WHERE <field> = cond1 ORDER BY KADKY DESCENDING.
ENDSELECT.
Regards,
Lokesh
09-24-2013 12:02 PM
Did you read Abap online documentation like http://help.sap.com/abapdocu_731/en/abapselect_aggregate.htm or transaction ABAPDOCU or F1 on source editor.
Regards,
Raymond
09-24-2013 12:12 PM
Hi Anuradha,
Try this query...
select max(field name) from table name into wa-fieldname
where condition......
sure this will solve...
01-22-2016 4:44 AM