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

at selection-screen

Former Member
0 Likes
795

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
754

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.

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
754

I think you want to change like this.



<b>if g_no_months > 12.</b>
MESSAGE i001(00) WITH 'ENTERED DATE IS WITHIN RANGE'.
endif.

Regards,

Rich HEilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
754

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

Read only

Former Member
0 Likes
755

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.

Read only

0 Likes
754

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

Read only

0 Likes
754

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

Read only

0 Likes
754

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

Read only

0 Likes
754

hi Rich Heilman ,

thanks For given the Reply its working

Regards

siri