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

Date calculation

Former Member
0 Likes
467

Could you please anyone tell is there any FM available for this date calculation.

The requirement is:

If the SY-DATUM is between 1st and 7th of current month, E1EDK03 / DATUM should be the last business day of previous month.

Thanks in advance.

REgards,

Sankar

3 REPLIES 3
Read only

Former Member
0 Likes
442

Hi Shankar,

You have to put a condition for checking if the sy-datum is between the first date and seveth date of the month. Which you can easily do using IF statement with GT and LT operators.

If your condition is true then do the below mentioned activities.

For getting the last date of the previous month subtract month from the date.Use the below mentioned FM

BKK_ADD_MONTH_TO_DATE

Pass current date and use -1 for getting the similar date on last month.

Here is the function module which you can use to assign it to the field you mentioned.

DATE_GET_MONTH_LASTDAY.

Pass the date you got from previous FM to this FM and you will get the last day of previous month.

Regards,

Mayank

Read only

Former Member
0 Likes
442

Get the last day of the month by using the following FMs.

BKK_GET_MONTH_LASTDAY

Then use the FM RKE_SELECT_FACTDAYS_FOR_PERIOD to get the list of all work days available in that month. Pass the 1st day of the month, last day of the month and the factory calender that will indicate the work days and holiday days also suiting your rqmt. From that get the last working day.

Hope this helps.

Thanks,

Balaji

Read only

Former Member
0 Likes
442

Hi,

I am not clear with your question. But as far i have inderstood that you want to get an output as a date that is the last working day of the previous month. Let me to explain a logic.

data : date1 like sy-datum,

date2 like sy-datum.

date1 = sy-datum.

say for example as per your question the date is in between 1 and 7. So say date1 as 05.3.2008.

date2 = date1 -date1+6(2).

This will give you the date which is one month before for the date1.

then use a function module as RTP_US_API_MAX_DAYS_IN_MONTH. This will give you the maximum days of the month. So you will get the maximum days for the given month. Then use the table as TFACS. It is the table which is for factory calendar. In the record sets of the table '1' stands for working day and '0' stands for holiday.

Hence you can derive the date as well.

Regards,

Sanki.