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: 

check the month, if its grearter then 9 months

Former Member
0 Kudos

hi,

i want to validate the month.

the month(july/2006) entered should not be greater then 9 months(april/2007)

or less then 3 months(april/2006).

pls help me.

6 REPLIES 6

Former Member
0 Kudos

You can get the upper and lower limit dates using RE_ADD_MONTH_TO_DATE (Pass 9 and -3 ). Then see if the date is between the two dates.

Regards,

Ravi

Former Member
0 Kudos

Hi,

try this:

data: START_DATUM like sy-datum.

*

CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'

EXPORTING

MONTHS = '09'

OLDDATE = SY-DATUM

IMPORTING

NEWDATE = START_DATUM.

*

write: sy-datum, start_datum.

Regards, Dieter

Former Member
0 Kudos

Hi,

You can use FM: CALCULATE_DATE.

Using a particular reference date e.g. sy-datum , you can pass month paramter as 09 or -03 get a result date so that it can be validated for your required range.

Regds,

Akshay Bhagwat

laxmanakumar_appana
Active Contributor
0 Kudos

Hi,

Check this code :

data : x_date1 like sy-datum.

data : x_date2 like sy-datum.

data : x_date3 like sy-datum.

data : x_month(2) type c,

x_year(4) type c,

x_date(2) type c.

x_month : -


pass entered value

x_year = sy-datum+0(3).

x_date = sy-datum+6(2).

concatenate x_year x_month x_date to x_date3.

CALL FUNCTION 'MONTH_PLUS_DETERMINE'

EXPORTING

months = '9'

olddate = x_date3

IMPORTING

NEWDATE = x_date1

.

CALL FUNCTION 'MONTH_PLUS_DETERMINE'

EXPORTING

months = '-3'

olddate = x_date3

IMPORTING

NEWDATE = x_date2

.

if x_date3 between x_date2 and x_date1.

message i000(xxx) with 'error'.

endif.

Regards

Laxman

0 Kudos

try that:

REPORT zforum95 .

PARAMETERS date2 LIKE sy-datum.
DATA mth LIKE komp-anz_monate.

CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES_NEW'
     EXPORTING
          i_datum_bis       = date2
          i_datum_von       = sy-datum
          i_kz_incl_bis     = ' '
          i_kz_volle_monate = 'X'
     IMPORTING
          e_monate          = mth.


IF mth > 9 OR mth < -3.
  MESSAGE e001(00) WITH 'err' mth.
ENDIF.

A.

Message was edited by: Andreas Mann

former_member188685
Active Contributor
0 Kudos

Hi,

try this way....


REPORT ZTEST MESSAGE-iD ZZ
DATA: CURRDATE TYPE d,DATE3 TYPE d,
      DATE9 TYPE d.
PARAMETERS: P_DATE TYPE SY-DATUM.

AT SELECTION-SCREEN.
 CURRDATE = sy-datum.
  CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
    EXPORTING
      DATE      = CURRDATE
      DAYS      = 0
      MONTHS    = 3
      SIGNUM    = '+'
      YEARS     = 0
    IMPORTING
      CALC_DATE = DATE3.

  CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
    EXPORTING
      DATE      = CURRDATE
      DAYS      = 0
      MONTHS    = 9
      SIGNUM    = '+'
      YEARS     = 0
    IMPORTING
      CALC_DATE = DATE9.

  IF  P_DATE GT DATE9 and  P_DATE LT DATE3.
    MESSAGE E999(ZZ) WITH 'please enter vlaid date'.
  ENDIF.

Regards

vijay