‎2006 Nov 06 10:00 AM
hi!
I have an abap program where I should build a check on the following
parameters: p_date type dats.
How can I check if p_date is at least one year ago compared to today? If not, an error message should be printed to screen, and the rest of the program should not be executed.
also, if possible, default value for the p_data parameter should be the date one year ago compared to today
simple question from a beginning abap programmer
thanks !
Message was edited by: Joris Hens
‎2006 Nov 06 10:06 AM
Hello Joris,
parameters: p_date type dats.
at selection-screen on p_date.
data: l_date type dats.
l_date = sy-datum.
l_date0(4) = sy-datum0(4) - 1.
if p_date > l_date.
message e308(00) with 'Enter date one year ago'.
endif.
Regards,
Naimesh
‎2006 Nov 06 10:06 AM
Hello Joris,
parameters: p_date type dats.
at selection-screen on p_date.
data: l_date type dats.
l_date = sy-datum.
l_date0(4) = sy-datum0(4) - 1.
if p_date > l_date.
message e308(00) with 'Enter date one year ago'.
endif.
Regards,
Naimesh
‎2006 Nov 06 10:09 AM
Hi,
DATA : v_i type i.
v_i = sy-datum - p_date.
IF v_i LE 365.
MESSAGE to show "p_date is at least one year ago compared to today"
ENDIF.
*This will solve your query
*Reward all helpful answers
‎2006 Nov 06 10:09 AM
Hi Joris,
There is an event called "AT SELECTION-SCREEN" where you can check the input given by the user is a valid one or not. Justt check out and see
Bye
Murthy
‎2006 Nov 06 10:09 AM
you can use AT SELECTION SCREEN ON field
Have a look at below link. It will give you details abt this processing block.
http://help.sap.com/saphelp_nw04/helpdata/en/79/34a237d9b511d1950e0000e8353423/content.htm
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers
‎2006 Nov 06 10:09 AM
HI,
check this logic.
<b>
parameters: p_date type dats.
data: a type datum.
a = sy-datum.
a(4) = sy-datum(4) - 1.
if p_date(4) > a.
MESSAGE E000(su) WITH 'date is not valid'.
endif.
write:/ a.</b>
REgards,
‎2006 Nov 06 10:09 AM
Hi Joris,
U can validate any selection screen fields in the event
at-selection screen.
1. To validate date,
the internal format for the date storage is : DDMMYYYY.
take a variable say w_year.
w_year = sy-datum+4(4).
The above statement will store the date.
take another variable which contains the previous years date (use offset as of above). Compare and generate am error message.
2. U can default values in the selection screen using the event initialization.
Regards,
Santosh.
‎2006 Nov 06 10:19 AM
thanks everyone, learned something again today
points have been rewarded