‎2007 Mar 21 4:47 AM
Hi Guys!
I have a select-option Date field. I Have to give default values to both High and Low. The Date-high will have current date and Date-low should be one month back from current date. Any idea on hw to do the Validation for this....Do i need a fn module for this in my At-selection screen event?
Thanks & Regards,
San
‎2007 Mar 21 4:57 AM
Hi,
You can do something like this.
data: v_date1 like sy-datum,
v_date2 like sy-datum.
SELECT-OPTIONS: s_date for sy-datum.
INITIALIZATION.
s_date-sign = 'I'.
s_date-option = 'BT'.
s_date-low = sy-datum - 30.
s_date-high = sy-datum.
append s_date.
AT SELECTION SCREEN ON s_date.
IF NOT s_date[] IS INITIAL.
v_date1 = sy-datum - 30.
v_date2 = sy-datum.
IF s_date-low ne v_date1.
message e000 with 'Start date should be a month ago'.
ENDIF.
IF s_date-high ne v_date2.
message e000 WITH 'End date should be today's date'.
ENDIF.
ENDIF.
Regards,
Ferry Lianto
‎2007 Mar 21 4:53 AM
Hi San,
Try this:
data : v_date like sy-datum.
data : v_date1 like sydatum.
intialization.
move sydatum to v_date.
v_date1 = v_date-30.
move v_date to s_date-low.
move v_date1 to s_date-high..
start-of-selection,
-
-
Hope this helps you. Reply for queries
Regards,
kumar,
‎2007 Mar 21 4:54 AM
Hi San,
You do not need to find any function module for this validations you can do manually also.
**in the event AT SELECTION-SCREEN
**get the month from the Date-High and Date-low.
**then
W_DIFF = MONTH_HIGH - MONTH-LOW.
IF NOT W_DIFF = '1'.
**display an appropriate error message
ENDIF.
Regards,
Kunjal
‎2007 Mar 21 4:57 AM
Hi,
You can do something like this.
data: v_date1 like sy-datum,
v_date2 like sy-datum.
SELECT-OPTIONS: s_date for sy-datum.
INITIALIZATION.
s_date-sign = 'I'.
s_date-option = 'BT'.
s_date-low = sy-datum - 30.
s_date-high = sy-datum.
append s_date.
AT SELECTION SCREEN ON s_date.
IF NOT s_date[] IS INITIAL.
v_date1 = sy-datum - 30.
v_date2 = sy-datum.
IF s_date-low ne v_date1.
message e000 with 'Start date should be a month ago'.
ENDIF.
IF s_date-high ne v_date2.
message e000 WITH 'End date should be today's date'.
ENDIF.
ENDIF.
Regards,
Ferry Lianto
‎2007 Mar 21 5:02 AM
write your code to make the deafult values for select option in the "LOAD-OF-PROGRAM" event block.
‎2007 Mar 21 5:04 AM
Hi,
Please check this.
REPORT ZKALTEST1 .
data: date like sy-datum.
data: date1 like sy-datum.
INITIALIZATION.
date = sy-datum.
date1 = sy-datum - 30.
select-options s_date for date.
s_date-low = date1.
s_date-high = date.
append s_date.
top-of-page.
write: 'hello'.
start-of-selection.
*write:/ 'how r u'.
Regds,
kaleem.
Reward help ful answer,
Thanks.
‎2007 Mar 21 5:08 AM
Hi,
Do the defaults in initialisation event.
initialisation.
s_date-high = sy-datum.
s_date-low = sy-datum-30.
append s_date.
hope this helps you,
keerthi
‎2007 Mar 21 5:12 AM
Exec the code .
Write the code in Initialization event.
tables : vbak.
select-options : s_date for vbak-erdat.
data : bkdate like sy-datum.
initialization.
s_date-high = sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = sy-datum
days = 00
months = 01
SIGNUM = '-'
years = 00
IMPORTING
CALC_DATE = bkdate.
s_Date-low = bkdate.
append s_Date.I didnt get why a Validation is required here .
Low and high dates are in place , anything im missing.
Regards,
Vijay
‎2007 Mar 21 5:21 AM
Hi ,
When you say default values then you have do this INITIAILIZATIONevent
for date high values you can use sy-datum .
foir low values you can have a function module RP_CALC_DATE_IN_INTERVAL
to fill the low value.
Please reward if useful.
‎2007 Mar 21 6:05 AM
Hi San
If u use the below code i think no validation is required
data:
w_date like sy-datum.
select-options:
s_date for w_date.
initialization.
s_date-high = sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = s_date-high
DAYS = 0
MONTHS = 1
SIGNUM = '-'
YEARS = 0
IMPORTING
CALC_DATE = w_date .
s_date-low = w_date.
append s_date.
Reward all helpful answers
‎2007 Mar 21 7:12 AM
You can use the following code for checking whether a date is valid or not:
DATA:
LW_D(2) TYPE N,
LW_M(2) TYPE N,
LW_Y(4) TYPE N,
LW_REM TYPE N,
LW_VALID TYPE N VALUE 1,
LW_DATE(8) TYPE C,
LW_FLAG TYPE I.
IF P_OR_DAT CO '0123456789'.
LW_DATE = P_OR_DAT.
LW_D = LW_DATE+6(2).
LW_M = LW_DATE+4(2).
LW_Y = LW_DATE+0(4).
IF LW_Y GT '0000' AND LW_Y LE '9999'.
IF LW_M GT '01' AND LW_M LE '12'.
Check for leap year
Set lw_flag if leap year
LW_REM = LW_Y MOD 100.
IF LW_REM = 0.
LW_REM = LW_Y MOD 400.
IF LW_REM = 0.
LW_FLAG = 1.
ENDIF.
ELSE.
LW_REM = LW_Y MOD 4.
IF LW_REM = 0.
LW_FLAG = 1.
ENDIF.
ENDIF.
Check for valid date
IF LW_M EQ 04 OR
LW_M EQ 06 OR
LW_M EQ 09 OR
LW_M EQ 11.
IF LW_D GT 30 OR
LW_D LT 1.
LW_VALID = 0.
ENDIF.
ELSEIF LW_M EQ 2.
IF LW_FLAG EQ 1.
IF LW_D LT 1 OR
LW_D GT 29.
LW_VALID = 0.
ENDIF.
ELSE.
IF LW_D LT 1 OR
LW_D GT 28.
LW_VALID = 0.
ENDIF.
ENDIF.
ELSE.
IF LW_D LT 1 OR
LW_D GT 31.
LW_VALID = 0.
ENDIF.
ENDIF.
ELSE.
LW_VALID = 0.
ENDIF.
ELSE.
LW_VALID = 0.
ENDIF.
IF LW_VALID = 0.
MESSAGE 'Invalid Date' TYPE 'E'.
ENDIF.
FS_SBOOK-ORDER_DATE = P_OR_DAT.
ELSE.
MESSAGE 'Date can not be characters' TYPE 'E'.
ENDIF.
‎2007 Mar 22 7:03 AM
Thanks guys!
I had forgotton to give append S_date. Thats why it was not working!
I have given points for helpful answers!
Thanx.