‎2006 Aug 30 6:17 PM
hi friends,
Could u please send me the details
DATA: STRDAT LIKE SY-DATUM,
ENDDAT LIKE SY-DATUM,
g_NO_MONTHS type i.
STRDAT = S_IDATU-LOW.
ENDDAT = S_IDATU-HIGH,.
SELECT-OPTIONS:g_IDATU FOR LINV-IDATU.
at-selection-screen
CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = STRDAT
I_DATUM_VON = ENDDAT
I_KZ_INCL_BIS = ' '
IMPORTING
E_MONATE = g_NO_MONTHS
.
IF g_no_months not BETWEEN 1 AND 12.
MESSAGE i001(00) WITH 'ENTERED DATE IS WITHIN RANGE'.
endif.
g_timbin_peryr = 12 / g_NO_MONTHS.
the above code purpose is when i enter the dates in seletion option range if the diffrence between the two dates more than the 12 months i need to display the error message.
but here my problem is if the month is in between the 1 and 12 it displaying the Error Message.
Could u please suggest me how to do this
Regards
Siri
‎2006 Aug 30 6:24 PM
Small correction in ur code.
DATA: STRDAT LIKE SY-DATUM,
ENDDAT LIKE SY-DATUM,
g_NO_MONTHS type i.
STRDAT = S_IDATU-LOW.
ENDDAT = S_IDATU-HIGH,.
SELECT-OPTIONS:g_IDATU FOR LINV-IDATU.
at-selection-screen
CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = STRDAT
I_DATUM_VON = ENDDAT
I_KZ_INCL_BIS = ' '
IMPORTING
E_MONATE = g_NO_MONTHS
.
<b>if not g_no_months is initial and g_no_months GT 12.
MESSAGE e001(00) WITH 'ENTERED DATE IS WITHIN RANGE'.
endif.</b>
g_timbin_peryr = 12 / g_NO_MONTHS.
‎2006 Aug 30 6:21 PM
‎2006 Aug 30 6:23 PM
Oh, I guess the reall problem is that you have your parameters reversed in the function call. You are getting a negative value in the g_no_months. Swap the parameters.
call function 'MONTHS_BETWEEN_TWO_DATES'
exporting
<b>i_datum_bis = enddat
i_datum_von = strdat</b>
* I_KZ_INCL_BIS = ' '
importing
e_monate = g_no_months
.
Then it should work.
Regards,
Rich Heilman
‎2006 Aug 30 6:24 PM
Small correction in ur code.
DATA: STRDAT LIKE SY-DATUM,
ENDDAT LIKE SY-DATUM,
g_NO_MONTHS type i.
STRDAT = S_IDATU-LOW.
ENDDAT = S_IDATU-HIGH,.
SELECT-OPTIONS:g_IDATU FOR LINV-IDATU.
at-selection-screen
CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = STRDAT
I_DATUM_VON = ENDDAT
I_KZ_INCL_BIS = ' '
IMPORTING
E_MONATE = g_NO_MONTHS
.
<b>if not g_no_months is initial and g_no_months GT 12.
MESSAGE e001(00) WITH 'ENTERED DATE IS WITHIN RANGE'.
endif.</b>
g_timbin_peryr = 12 / g_NO_MONTHS.
‎2006 Aug 30 6:34 PM
hi Prakash Ramu ,
Thanks for giving the Replay
but when i used than one the months difference is morthan the 12 it wont displaying any error message it displaying the output
I need to display when the months difference is more than 12 error Message, otherwise i need to display output
Plaese suggest me how to do this
Regards
siri
‎2006 Aug 30 6:38 PM
Please see my answers above. This is will work.
You parameters to the function call are backwards, there for the g_no_months is a negative number which is why the error message is not being fired. You need to change the values that you are passing to the function module around.
<b>i_datum_bis = enddat <---- Right here
i_datum_von = strdat <----- Right here</b>
Regards,
Rich Heilman
‎2006 Aug 30 6:40 PM
Hi Sireesha,
Try with this code.
<b>IF NOT g_no_months IS INITIAL AND ( g_no_months < 1 OR
g_no_months > 12 ).</b>
MESSAGE i001(00) WITH 'ENTERED DATE IS WITHIN RANGE'.
<b>endif.</b>
NOTE: Plz mark all helpful answers and close the thread once problem is solved. Dont open threads even they were solved.
Thanks,
Vinay
‎2006 Aug 30 6:44 PM
hi Rich Heilman ,
thanks For given the Reply its working
Regards
siri