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: 

Month Difference - Function Module needed

aasim_khan
Participant
0 Kudos
1,476

Hi Experts,

In my report, I am using mcs0-spmon as select options; one of my inputs where the user will enter month and year in the selection screen . e.g. 04.2008 to 07.2008

I want to calculate the month difference and it should not exceed 3 months. If it does, an error will be shown.

My question is -

Is there any Function Module by which I can proceed. How do I go about it?

Can anyone tell me a solution?

Thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos
193

Hi,

concatenate '200804' '01' into dur_begda.

concatenate '200807' '01' into dur_endda.

call function 'HR_PT_GET_MONTHS'

exporting

first_date = dur_begda

second_date = dur_endda

modify_interval = space

importing

duration = duration-months

exceptions

invalid_seq_dates = 1.

Thanks,

Durai.V

Edited by: Durai V on Aug 12, 2008 6:33 AM

5 REPLIES 5

Former Member
0 Kudos
193

Hi,

Here is the piece of code....

what u can do is just supply the date from u which u want to subtract and value for subtraction u give 3 then u check the new date if it is equal to the date u have second its ok u can proceed else u give error message...

i hope u will get ur solution...

data: new_date type d.

CALL FUNCTION 'MONTH_PLUS_DETERMINE'

EXPORTING

months = - 3 " Negative to subtract from old date, positive to add

olddate = sy-datum

IMPORTING

NEWDATE = new_date.

write: / new_date.

0 Kudos
193

Hey I already know about this FM. I am using select-options. I know it's a bit weird, but after all it's a client requirement. He want From-To option in the selection-screen

Former Member
0 Kudos
194

Hi,

concatenate '200804' '01' into dur_begda.

concatenate '200807' '01' into dur_endda.

call function 'HR_PT_GET_MONTHS'

exporting

first_date = dur_begda

second_date = dur_endda

modify_interval = space

importing

duration = duration-months

exceptions

invalid_seq_dates = 1.

Thanks,

Durai.V

Edited by: Durai V on Aug 12, 2008 6:33 AM

0 Kudos
193

Hi Durai,

Thanks for your help. I really appreciate it!

Former Member
0 Kudos
193

Hi..

here is similar question...

regards

vivek