Application Development 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: 
SAP Community Downtime Scheduled for This Weekend

date comparison

Former Member
0 Kudos
124

Hi all,

I have say 3 dates .how will find the latest date.

bcoz of i think the logic then it is going very big.is there any simple way....

1 ACCEPTED SOLUTION

Former Member
0 Kudos
74

Hi,

Put all the dates in an internal table <ITAB>

Then SORT ITAB by DATE DESCENDING.

U will get Latest date in first record.

Regards,

4 REPLIES 4

Former Member
0 Kudos
74

hi,

put the 3 dates in an internal table.

sort that internal table.

read the first index.

u will get the latest date.

Rgds

Reshma

Former Member
0 Kudos
75

Hi,

Put all the dates in an internal table <ITAB>

Then SORT ITAB by DATE DESCENDING.

U will get Latest date in first record.

Regards,

Former Member
0 Kudos
74

Hi,

1) You can do a number of things, one you can get all of the relevant records and sort the internal table by date and time in decending order, then simply read the first record of the internal table.

2) It depends on the key of the table. Say for example, you have a table like so.

MANDT

KEYFIELD

DATE

TIME

If the key alreays exists, you can use the modify statement to update the record, if it dosn't exists, you need to use the INSERT statement to insert the records.

data: xtab type ztable.

xtab-keyfield = 'ABC'.

xtab-date = '20070207'. " or sy-datum

xtab-time = '221600'. " or sy-uzeit.

insert ztable from xtab.

Make sure to use internal fomat for DATE and TIME

<b>Reward points</b>

Regards

Former Member
0 Kudos
74

Hi,

take refernce from the foll. code:

data : begin of itab occurs 0,

date like sy-datum,

end of itab.

data : lv_date like sy-datum.

lv_date = sy-datum - 70.

move lv_date to itab-date.

append itab.

lv_date = sy-datum - 120.

move lv_date to itab-date.

append itab.

lv_date = sy-datum - 90.

move lv_date to itab-date.

append itab.

loop at itab.

write : / itab-date.

endloop.

sort itab descending.

read table itab index 1.

write : / itab-date.

Regards,

Himanshu