2008 Aug 08 9:11 AM
I need to validate a date field
for eg:
SELECT-OPTIONS : dat FOR ekko-aedat.
When user enter month less than 1 or greater than 12 an
error message must be shown.
Please help me with this
Thanks
Pradeep Alex
2008 Aug 08 9:13 AM
Hi
use AT SELECTION-SCREEN event to validate the fields on the selection-screen.
Regards
Pavan
I need to validate a date field
for eg:
SELECT-OPTIONS : dat FOR ekko-aedat.
When user enter month less than 1 or greater than 12 an
error message must be shown.
Please help me with this
Thanks
Pradeep Alex
2008 Aug 08 9:13 AM
Hi
use AT SELECTION-SCREEN event to validate the fields on the selection-screen.
Regards
Pavan
2008 Aug 08 9:15 AM
Hi
AT SELECTION-SCREEN ON S_DATE.
SELECT date FROM vbrk
WHERE DATE IN S_DATE and (month >=1 || month <=12).
IF sy-subrc NE 0.
MESSAGE i000(z_msg).
ENDIF.
2008 Aug 08 9:17 AM
hi Pradeep Alex,
welcome to SDN
you are on the right track already! you created the select option refering to a standard date field. it means, the check will happen automatically, no need for more coding! Just give it a try!
hoep this helps
ec
2008 Aug 08 10:35 AM
Is that possible to use offset for this validation,If so how it can be done.
2008 Aug 08 10:41 AM
Hello,
Try this,
AT SELECTION-SCREEN ON S_DAT.
IF S_DAT-LOW+4(2) < 1 OR S_DAT-LOW+4(2) > 12.
<ERROR MESSAGE>.
ENDIF.
I beleive this is irrelevant as SAP will automatically perform this check & throw an error message.
BR,
Suhas
Edited by: Suhas Saha on Aug 8, 2008 11:42 AM
2008 Aug 08 9:17 AM
Pradeep,
AT SELECTION-SCREEN ON dat.
check here.
message.
When user enter month less than 1 or greater than 12 an
error message must be shown.
Please help me with this
am not sure from which date you want to compare month?as i believe there should be always two date for any kind of comparision.
is it with sy-datum?
Amit.
2008 Aug 08 9:19 AM
Hi Pradeep,
There is no need to validate the date field. as it refers to the standard date format field, the date validation is performed automatically.
Regards,
Chandra Sekhar
2008 Aug 08 9:21 AM
Hi pradeep,
your field ekko-aedat has datatype DATS, i.e. dictionary standard type for date.
You do not need to give any validation.
Regards,
Anirban
2008 Aug 08 9:57 AM
HI,
ekko-aedat is of type dats.
so system will automatically take care of your requirement.
No need of using at selection-screen and all theese things..
2008 Aug 08 10:01 AM
SELECT-OPTIONS : dat FOR ekko-aedat.
AT SELECTION-SCREEN.
loop at dat.
if dat-low4(2) <1 and dat-low4(2) >12.
MESSAGE e000(ZRAM) with 'Enter Correct Date'.
endif.
endloop.
here ZRAM is message class you can here ur own class name.
rgds
rajesh
2008 Aug 08 10:24 AM
Hi Pradeep,
As I understand your question is " How to validate and give error if the date range entered is for more than12 months or less than 1 month?"
As many of the repliers have suggested you can validate it in
At SELECTION-SCREEN ON dat. "dat is your select-option
Use FM HR_HK_DIFF_BT_2_DATES to get months between dat-low and dat-high.
If the months come out to be less than 1 or greater than 12 give appropriate error message.
Hope this solves your problem.
Thanks,
Hitesh
2008 Aug 08 10:52 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |