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: 

Dates calculation

Former Member
0 Kudos

Hi,

I needed some help in calculating dates in between 15th working day of the current month to 5th working day of the next month

That means : suppose i have date as 25th march 2007

then i need to check if it lies between 15th working day of March to 5th working day of April and offcourse 25th march should also be a working day. if not i have to throw an error

This is a kind of validation i have to put in the program

Thanks in advance,

Bhupal

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

To calculate nth working day of a month, use FM BKK_ADD_WORKINGDAY.

For example, to know the date of 15th working day of March 2007 :

call function 'BKK_ADD_WORKINGDAY'

EXPORTING

i_date = 20070301

i_days = 15

i_calendar1 = country code

IMPORTING

e_date = date.

do the same thing to calculate 5th working day of April and check your intial date (25th March) is between these two dates (which will be 20070322 and 20070406 with FR calendar).

then check your date is a working day with FM DATE_CHECK_WORKINGDAY :

call function 'DATE_CHECK_WORKINGDAY'

EXPORTING

date = 20070325

factory_calendar_id = country code

message_type = 'I'

EXCEPTIONS

date_no_working_day = 8.

if sy-subrc = 8.

message....

endif.

Please reward if helpful.

Regards,

Nicolas.

6 REPLIES 6

Former Member
0 Kudos

You can use function module DATE_CONVERT_TO_FACTORYDATE in a loop and count the days for example.

Former Member
0 Kudos

Hi,

This link may help u..

http://help.sap.com/saphelp_nw2004s/helpdata/en/c0/98038ce58611d194cc00a0c94260a5/content.htm

<b>Rewards if useful.</b>

Regards,

Swati garg

Former Member
0 Kudos

Hi,

Please visit the link for function modules on date and time:

http://www.geocities.com/victorav15/sapr3/abapfun.html#date

Thanks,

Sandeep.

Former Member
0 Kudos

Hi,

To calculate nth working day of a month, use FM BKK_ADD_WORKINGDAY.

For example, to know the date of 15th working day of March 2007 :

call function 'BKK_ADD_WORKINGDAY'

EXPORTING

i_date = 20070301

i_days = 15

i_calendar1 = country code

IMPORTING

e_date = date.

do the same thing to calculate 5th working day of April and check your intial date (25th March) is between these two dates (which will be 20070322 and 20070406 with FR calendar).

then check your date is a working day with FM DATE_CHECK_WORKINGDAY :

call function 'DATE_CHECK_WORKINGDAY'

EXPORTING

date = 20070325

factory_calendar_id = country code

message_type = 'I'

EXCEPTIONS

date_no_working_day = 8.

if sy-subrc = 8.

message....

endif.

Please reward if helpful.

Regards,

Nicolas.

Former Member
0 Kudos

Hi,

try this:

data: date1 like sy-datum value '20070615'.

data: date2 like sy-datum value '20070705'.

data: days type i.

*

WHILE date1 < date2.

*

date1 = date1 + 1.

*

CALL FUNCTION 'DATE_CHECK_WORKINGDAY'

EXPORTING

DATE = date1

FACTORY_CALENDAR_ID = 'ZO'

MESSAGE_TYPE = 'I'

EXCEPTIONS

DATE_NO_WORKINGDAY = 4.

*

IF SY-SUBRC <> 4.

days = days + 1.

ENDIF.

*

ENDWHILE.

*

write: date1, date2, days.

*

regards, Dieter

Former Member
0 Kudos

Hi Bhupal..

check with the below given code...

<b>

DATA: date1 TYPE dats,

date2 TYPE dats,

month(2) TYPE c,

year(4) TYPE c.

PARAMETERS: p_date TYPE dats DEFAULT sy-datum.

START-OF-SELECTION.

month = p_date+4(2).

year = p_date+0(4).

date1+0(4) = year.

date1+4(2) = month.

date1+6(2) = '15'.

IF month NE '12'.

month = month + 1.

date2+0(4) = year.

date2+4(2) = month.

date2+6(2) = '05'.

ELSE.

year = year + 1.

date2+0(4) = year.

date2+4(2) = '01'.

date2+6(2) = '05'.

ENDIF.

if p_date between date1 and date2.

message 'Between' type 'S'.

else.

message ' Not in between ' type 'E'.

endif.</b>

reward if useful...

Regards

Prax..