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

Function Module for separating a date range into days

Former Member
0 Likes
1,375

Hi all,

Does anyone know if there is a function module which gives back the list of days when we give a date range as input parameter to the function module. For example, we enter the range 10.07.2006 - 13.07.2006 and the function module gives back a table in form 10.07.2006, 11.07.2006, 12.07.2006, 13.07.2006.

Thanks,

Sükrü

5 REPLIES 5
Read only

Former Member
0 Likes
988
Read only

Former Member
0 Likes
988

Hai Suekrue

Check the following Code

data: begin_date type sy-datum value '20060110',

end_date type sy-datum value '20060125'.

data: idatum type table of sy-datum with header line.

idatum = begin_date.

append idatum.

do.

if idatum = end_date.

exit.

endif.

idatum = idatum + 1.

append idatum.

enddo.

loop at idatum.

write:/ idatum.

endloop.

Regards

Sreeni

Read only

naimesh_patel
Active Contributor
0 Likes
988

Hello,

You can do as per below:

select-options : s_datum for sy-datum.

data: l_date type d.

l_date = w_datum-low.

itab-date = l_date.

append itab.

Do.

if l_Date = s_Datum-high.

exit.

endif.

l_date = l_date + 1.

itab-date = l_date.

append itab.

clear itab.

enddo.

Regards,

Naimesh

Read only

0 Likes
988

Thanks Sreen. and Naimesh,

Your answers help a lot to solve the problem.

Regards,

Sükrü

Read only

Former Member
0 Likes
988

Hi suekrue,

1. Exactly for this purpose,

i have written an

INDEPENDENT FORM (subroutine)

wherein we pass

a) fromdate

b) todate

c) ITAB

2. and it gives all the dates in the internal table.

3. just copy paste

4.

data : itab type table of sy-datum with header line.

parameters : fromdate type sy-datum default '20060701'.

parameters : todate type sy-datum default sy-datum.

perform getdays tables itab using fromdate todate.

break-point.

*----


  • FORM

*----


form getdays

tables itab

using fromdate todate.

data : curdate type sy-datum.

curdate = fromdate.

do.

if curdate > todate.

exit.

endif.

itab = curdate.

append itab.

curdate = curdate + 1.

enddo.

endform. "getdays

regards,

amit m.