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

get next available dat

Former Member
0 Likes
568

hi,

i want to retreive the next available date from one internal table based on input from another internal table.

itab1

02/02/2001

itab2

02/04/2006

02/03/2002

02/05/2002

now for the value in itab1(02/02/2001) i must look up itab2 and get the date closest to the date in itab1, which in this case is 02/03/2002.

has anyone worked on such calculations before.

1 ACCEPTED SOLUTION
Read only

former_member196280
Active Contributor
0 Likes
538

Loop at itab1.

loop at itab2 where date GT itab1-date.

itab3-date = itab2.date.

append itab3.

endloop.

endloop.

Sort itab3.

read itab3 index 1.

Reward points to all useful answers.

Regards,

SaiRam

Loop at itab1.

loop at itab2 where date GT itab1-date.

itab3-date = itab2.date.

append itab3.

endloop.

endloop.

Sort itab3.

read itab3 index 1.

Reward points to all useful answers.

Regards,

SaiRam

3 REPLIES 3
Read only

former_member196280
Active Contributor
0 Likes
539

Loop at itab1.

loop at itab2 where date GT itab1-date.

itab3-date = itab2.date.

append itab3.

endloop.

endloop.

Sort itab3.

read itab3 index 1.

Reward points to all useful answers.

Regards,

SaiRam

Read only

Former Member
0 Likes
538

sort itab2 by date ascending

loop at itab1 into wa1

loop at itab2 into wa2 where wa2-date > wa1-date.

write wa2-date " this date is the closet date.

break .

endloop.

endloop.

Read only

Former Member
0 Likes
538

hi

you can try to implement the below mentioned logic.

loop at itab1.

loop at itab2.

call function /SDF/CMO_DATETIME_DIFFERENCE.

this function can calculate the difference between two dates and than you can store that difference between the datesand ITAB2-date in local variables.When you will be looping again in itab2.compare the difference with earlier result and than if the old one is less than hold the first dateand difference in the local variables else can replace the values of with the second date and difference in the local variable.

Reward if helpful

Thanks

Mohit