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 Calculations

Former Member
0 Likes
1,860

Hello,

I am working on a new function module where on the selection screen i have the period type ( allowed values are 'D','W','M' for day,week and month).

And have one more input for date_period(it will allow integer upto 999).

My requirement is to calculate a date based on the period_type and date_period.

For example, if the period_type is 'M' (monthly) and date_period is 10, then the date should be current date + 10 months.

if the period_type is 'W' (weekly) and date_period is 10, then the date should be current date + 10 weeks.

And the same with 'D'.

Please note that i am working in APO environment. There is a FM module in ECC 'RP_CALC_DATE_IN_INTERVAL' which mostly matches my requirement but its not available in APO.

Any help would be appriciated.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,701

Found the FM - SEPA_MANDATE_ADD_MONTH_TO_DATE which works for month.

But still need a solution for weeks.

6 REPLIES 6
Read only

Sougata
Active Contributor
0 Likes
1,701

Hi,

If you have Class CL_RECA_DATE available in your APO system, you could work with its static methods especially ADD_TO_DATE looks promising in regards to your requirement.

Cheers,

Sougata.

Read only

Former Member
0 Likes
1,701

Unfortunatley, i do not see that class available in our APO system.

Read only

eduardo_hinojosa
Active Contributor
0 Likes
1,701

Hi

For adding months, you can try with the FM 'MONTH_PLUS_DETERMINE'.

For weeks I don't know any standard FM. Think that each 7 or 8 years there is a year of 53 weeks. You can create your own FM, if for instance you want to add 10 weeks, obtain days (ie: 10 * 7 = 70 days), add these days to the original date and with the FM 'DATE_GET_WEEK' get the weeks for the first day and the calculated day.

I hope this helps you

Regards

Eduardo

Read only

0 Likes
1,701

'MONTH_PLUS_DETERMINE' looks like an ECC Function module.

My requirment is in APO.

Read only

Former Member
0 Likes
1,702

Found the FM - SEPA_MANDATE_ADD_MONTH_TO_DATE which works for month.

But still need a solution for weeks.

Read only

0 Likes
1,701

Can you not code your own logic for weeks? 

End date = Start date + (7 * number of weeks).

Regards,

Nick