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: 

how to find all the dates btween period

Former Member
0 Kudos

hallow

i had to find how much month and year i have btween dates

in month and i have to append it to my table.

i give ex.

if begda = 01.01.2005

end endda = 01.06.2007

i wont to append to period_tbl

01012007

01022007

01032007

.....

until 01.06.2007

i try with that and it working when dats less then one year but i have problem when i choose dates that more then one year like in example.

<b>i reward kindly</b>

Regards

CALL FUNCTION 'HR_AUPBS_MONTH_DAY'

EXPORTING

beg_da = p_begda

end_da = p_endda

IMPORTING

no_day = l_day

no_month = l_month

no_year = l_year.

period_tbl-period = p_begda(6).

APPEND period_tbl.

MOVE p_begda(6) TO month_tmp.

DO l_month TIMES.

period_tbl-period = month_tmp + sy-index.

APPEND period_tbl.

ENDDO.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

data : lv_sdate type sy-datum,

lv_edate type sy-datum.

data begin of itab occurs 0,

period(8),

end of itab.

while lv_sdate <= lv_edate.

itab-period+0(2) = '01'.

itab-period2(2) = lv_sdate4(2).

itab-period4(4) = lv_sdate0(4).

append itab.

lv_sdate4(2) = lv_sdate4(2) + 1.

endwhile.

5 REPLIES 5

Former Member
0 Kudos

data : lv_sdate type sy-datum,

lv_edate type sy-datum.

data begin of itab occurs 0,

period(8),

end of itab.

while lv_sdate <= lv_edate.

itab-period+0(2) = '01'.

itab-period2(2) = lv_sdate4(2).

itab-period4(4) = lv_sdate0(4).

append itab.

lv_sdate4(2) = lv_sdate4(2) + 1.

endwhile.

0 Kudos

hi manesh

thankes for your answer.

maybe u can explain your code

Best regards

0 Kudos

data : lv_sdate type sy-datum,

lv_edate type sy-datum.

data begin of itab occurs 0,

period(8),

end of itab.

lv_sdate = '20050101'. " Start date

lv_edate = '20070101'. "Enddate

while lv_sdate <= lv_edate. " while start date is less than equal to end date

itab-period+0(2) = '01'. " day is 01

itab-period2(2) = lv_sdate4(2). " month is the month value which is 5th and 6th character in the date

itab-period4(4) = lv_sdate0(4). " year is the frist 4 charactterd of the field.

append itab.

lv_sdate4(2) = lv_sdate4(2) + 1. increase the month by one...

endwhile.

Hope this helps..

0 Kudos

thankes men

i try it

Best regards

former_member194669
Active Contributor
0 Kudos

Hi,

Use fm HR_SGPBS_YRS_MTHS_DAYS

aRs