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

Validate Month

Former Member
0 Likes
832

Hi Gurus,

can i know how to validate a particular month ,

what i want t say is, when i compare my input date with sy-datum if the given date belong to same month it should execute

if the given input date does not belong to that month it should show error.

please help me to resolve it.

thanks & Regards.

Ron.

Moderator message : Not enough re-search before posting, discussion locked.

Message was edited by: Vinod Kumar

2 REPLIES 2
Read only

Former Member
0 Likes
624

Hello Ron.

Good morning.

There can be many ways of doing the same, one way is :

lets say ur input is : p_date     with value 16.02.2012 (ddmmyyyy) and sy-datum has the value 16032012.

U can write your logic as :

data : v_input_mnth    type c,

          v_current_mnth type c.

  v_input_mnth     = p_date+2(2).         " after execution v_input_mnth will have 02

  v_current_mnth = sy-datum+2(2).      " after execution v_current_mnth will have 03

if  v_input_mnth = v_current_mnth

   perform ur_logic

else

perform show_error.                         " error if months are not same

endif.

Hope this will be usefull for you.

Thanks,

Gejo john

Read only

former_member213851
Active Contributor
0 Likes
624

Hi Rohan,

You just need to take current month using SY-DATUM in a variable as follows:

gv_temp = sy-datum+2(2).

Now consider P_AEDAT ha input date.

GV_IDATE =  P_AEDAT+2(2).

so to perform certain add condition:

IF gv_temp  EQ  GV_IDATE.

           "Your logic.

ELSE.

           " Dispaly message 'Current month is not equal to Entered Date's month '.

ENDIF.