2007 Apr 02 11:02 AM
i have a select option in my report which ask the user to enter date as mm.yyyy low to mm.yyyy high.Now the point is how should i validate the format and check that s_high is >s_low...?
rewards points assured
2007 Apr 02 11:33 AM
take two date field.
data : fromdate like sy-datum,
todate like sy-datum.
concatenate sp_mon-low '01' into fromdate.
concatenate sp_mon-high '01' into todate.
if todate lt fromdate.
message 'Pls give to value higher thatn lower' type 'E'.
endif.
regards
shiba dutta
May be there will be some standard module but try this
Data: dat1 type sy-datum,
dat2 type sy-datum.
concatenate s_high+4(4), s_high(2), '01' into dat1.
concatenate s_low+4(4), s_low(2), '01' into dat2.
if dat1 > dat2.
"higher
elseif dat1<dat2.
"lower
endif.
Hope this will help you.
Jogdand M B
Reward if helpful.
2007 Apr 02 11:07 AM
try the following fms
DATE_CHECK_PLAUSIBILITY.
DATA: v_char(6).
v_char = '121706'.
DATA: v_date TYPE sydatum.
v_date+4(2) = v_char(2).
v_date6(2) = v_char2(2).
CONCATENATE '20' v_char+4(2) INTO v_date(4).
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = v_date
EXCEPTIONS
plausibility_check_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: / 'INvalid date'.
ELSE.
WRITE: / 'Correct date'.
ENDIF.
<u><i><b>the below code can be of ur help</b></i></u>
======================================================================
Description : This program has two macros and a sample code which is showing how to use that,.
Macro 1. > Val_date
Macro 2. > Valdate
It return SY-Subrc value if it 0 then the entered date
is valid else either the date is invalid or the specified format is invalid
*----
PROGRAM ZDATE_VALIDATE .
Validation of Date
DEFINE VAL_DATE.
CLEAR: %_DATE1,
%_DATE2.
%_DATE1(4) = &1. "Year
%_DATE1+4(2) = &2. "Month
%_DATE1+6(2) = &3. "Date
%_DATE2 = %_DATE1 - 1.
%_DATE2 = %_DATE2 + 1.
IF %_DATE1 <> %_DATE2.
SY-SUBRC = 1.
ELSE.
SY-SUBRC = 0.
ENDIF.
END-OF-DEFINITION.
DEFINE VALDATE.
***************************************************
Passing Parameters: &1 - Date
&2 - Date Format
*
Date Format:
DDMMYYYY MMDDYYYY YYYYMMDD YYYYDDMM
*
SY-SUBRC Return Value:
1 invalid date
0 Valid Date
2 Invalid Format
***************************************************
DATA: %_DATE1 LIKE SY-DATUM ,
%_DATE2 LIKE SY-DATUM ,
%_DATE3(8).
case &2.
when 'DDMMYYYY'.
val_date &14(4) &12(2) &1+0(2).
when 'MMDDYYYY'.
val_date &14(4) &10(2) &1+2(2).
when 'YYYYMMDD'.
val_date &10(4) &14(2) &1+6(2).
when 'MMYYYYDD'.
val_date &12(4) &10(2) &1+6(2).
when others.
sy-subrc = 2.
endcase.
END-OF-DEFINITION.
***********************************************
SAMPLE USE of above MACRO *
***********************************************
DATA: V_DATE(8).
V_DATE = '30022002'.
*=>
VALDATE V_DATE 'DDMMYYYY'.
*=>
IF SY-SUBRC = 0.
WRITE:/ 'Valid Date'.
ELSEIF SY-SUBRC = 1.
WRITE:/ 'Invalid Date'.
ELSEIF SY-SUBRC = 2.
WRITE:/ 'Invalid Format'.
ENDIF.
*********************************************************************
*-- End of Program
Hope you use this .....
T
Thanks,
navjot
reward accprdingly
Message was edited by:
navjot sharma
2007 Apr 02 11:11 AM
May be there will be some standard module but try this
Data: dat1 type sy-datum,
dat2 type sy-datum.
concatenate s_high+4(4), s_high(2), '01' into dat1.
concatenate s_low+4(4), s_low(2), '01' into dat2.
if dat1 > dat2.
"higher
elseif dat1<dat2.
"lower
endif.
Hope this will help you.
Jogdand M B
Reward if helpful.
2007 Apr 02 11:11 AM
Hi Nabheet,
Concatenate the month and year along with the day 01 into two dummay variables and compare
concatenate '01.' p_mon1 p_yy1 into p_date1.
concatenate '01.' p_mon2 p_yy2 into p_date2.
if date2 > date1.
raise error.
endif.
2007 Apr 02 11:17 AM
HI..
take s_date as type char (7).
data:
w_d1 type d,
w_d2 type d.
split s_date-low at '.' into w_d14(2) w_d10(4).
split s_date-high at '.' into w_d24(2) w_d20(4).
at selection-screen.
if w_d2 < w_d1.
error message.
endif.
2007 Apr 02 11:33 AM
take two date field.
data : fromdate like sy-datum,
todate like sy-datum.
concatenate sp_mon-low '01' into fromdate.
concatenate sp_mon-high '01' into todate.
if todate lt fromdate.
message 'Pls give to value higher thatn lower' type 'E'.
endif.
regards
shiba dutta
2007 Apr 02 12:30 PM
hI,
Just decalare months as follows:
Declare it with refrerence to a db field.Validations will automatically be done
tables:spmon.
data:spmon for so31-spmon.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |