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

Require a function module for date to get previous months as output

Former Member
0 Likes
1,035

Hi ,

Can anyone please suggest me whether we have any standard function module to calculate a date in following format:

example:

If I enter date 26/08/11(format for entering date can be any)

It should return me 08/11, 07/11, 06/11

i.e on entering date i should get in return previous two months along with current month as output.

I have searched with std date function module but none of them was matching my reqiurement.

Please help.

Thanks & Regards,

Shweta

Moderator Message: Basic date related questions are not allowed. Please search before posting.

Edited by: Suhas Saha on Aug 29, 2011 12:57 PM

Hi ,

Can anyone please suggest me whether we have any standard function module to calculate a date in following format:

example:

If I enter date 26/08/11(format for entering date can be any)

It should return me 08/11, 07/11, 06/11

i.e on entering date i should get in return previous two months along with current month as output.

I have searched with std date function module but none of them was matching my reqiurement.

Please help.

Thanks & Regards,

Shweta

Moderator Message: Basic date related questions are not allowed. Please search before posting.

Edited by: Suhas Saha on Aug 29, 2011 12:57 PM

4 REPLIES 4
Read only

Former Member
0 Likes
692

I don't think there is a standard FM meeting your requirement

Read only

GauthamV
Active Contributor
0 Likes
692

You can create a simple custom function module and achieve this requirement.

Read only

Former Member
0 Likes
692

Hi,

This is a very simple requirement. You can just do like below.

va_month = sy-datum+2(2). "Month

va_year = sy-datum+4(4). "Year

if va_month > 2.

va_prev_first_month = va_month - 1.

va_prev_sec_month = va_month - 2.

concatenate va_month va_year seperated by '/' into va_curr_month.

concatenate va_prev_first_month va_year seperated by '/' into va_prev_1.

concatenate va_prev_sec_month va_year seperated by '/' into va_prev_2.

else.

case va_month.

when 1.

va_prev_first_month = 12.

va_prev_sec_month = 11.

concatenate va_month va_year seperated by '/' into va_curr_month.

va_year = va_year - 1.

concatenate va_prev_first_month va_year seperated by '/' into va_prev_1.

concatenate va_prev_sec_month va_year seperated by '/' into va_prev_2.

when 2.

va_prev_first_month = 1.

va_prev_sec_month = 12.

concatenate va_month va_year seperated by '/' into va_curr_month.

concatenate va_prev_first_month va_year seperated by '/' into va_prev_1.

va_year = va_year - 1.

concatenate va_prev_sec_month va_year seperated by '/' into va_prev_2.

endif.

Read only

deepak_dhamat
Active Contributor
0 Likes
692

Hi ,

By using this function module CCM_GO_BACK_MONTHS

you can create your own .

regards

Deepak.