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

GETTING LATEST DATE

Former Member
0 Likes
8,362

Hi,

I want to collect the latest date from a table containing a number of dates.

how do i achieve dis???

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,021

Hi,

try this..

select max( date ) into v_date from ztable.

select max( time ) into v_time from ztable.

9 REPLIES 9
Read only

Former Member
0 Likes
4,021

Hi,

Sort the date in descending order and then read the first table entry.

Hope this helps.

Regards,

Richa

Read only

Former Member
0 Likes
4,021

Hi,

<b>For internal table..</b>

SORT ITAB BY DATE DESCENDING.

  • get the latest date

READ TABLE ITAB INTO WA INDEX 1.

<b>For database table</b>

SELECT MAX( DATE) INTO V_DATE FROM ztable WHERE ..

Thanks,

Naren

Read only

gopi_narendra
Active Contributor
0 Likes
4,021

sort it_tab by <date> descending.

read it_tab index 1.

Regards

Gopi

Read only

Former Member
0 Likes
4,021

SORT itab BY date DESCENDING.

Now your first record will have latest date.

Reward points if useful.

Regards,

Atish

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
4,021

Hi

Sort the date in descending order and then read the first table entry

Regards,

Sree

Message was edited by:

sree ram

Read only

Former Member
0 Likes
4,021

DATA : BEGIN OF ITAB OCCURS 0,

VDATE LIKE SY-DATUM,

END OF ITAB.

SELECT MAX( <DATE FIELD> ) INTO TABLE ITAB FROM DBTAB WHERE <CONDITION>.

LOOP AT ITAB.

WRITE : ITAB-VDATE.

ENDLOOP.

REGARDS

SHIBA DUTTA

Read only

Former Member
0 Likes
4,021

Hi

Can you be little more clear with your requirement?

with respect to which module or which table you are asking this?

Regards

Anji

Read only

Former Member
0 Likes
4,022

Hi,

try this..

select max( date ) into v_date from ztable.

select max( time ) into v_time from ztable.

Read only

Former Member
0 Likes
4,021

Hi,

U can get the latest date by sorting ur internal table with key as date descending.

{Also if u coding in HR abap,

use <b>rp_provide_from_last p0001 space pn-begda pn-endda</b>

This wil help u to fetch the latest records for the entered begin date and end date.}

Hope this helps.

****Rewars points if helpful.

All the best