2008 Apr 11 9:34 AM
1) My requirment is to validate
current date of system(sy-datum) and past date in selection screen.
If difference between these
two dates more than six months than one error must display.
for example assume
current date = 02/21/2008 &
past date =
2008 Apr 11 9:48 AM
Hi,
Use the below code.
parameters: p_date type sy-datum.
data: v_date type sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = sy-datum
DAYS = 0
MONTHS = '06'
SIGNUM = '-'
YEARS = 0
IMPORTING
CALC_DATE = v_date.
if p_date lt v_date.
write:/ 'Invalid date'.
else.
write:/ 'Valid date'.
endif.
2008 Apr 11 9:36 AM
2008 Apr 11 9:43 AM
Hi,
You can make use of Function module 'HR_AUPBS_MONTH_DAY' to get the number of months b/w the current date and the end date.
<REMOVED BY MODERATOR>
Thanks,
Asha
Edited by: Alvaro Tejada Galindo on Apr 11, 2008 5:34 PM
2008 Apr 11 10:06 AM
hi asha,
thanks for your replay.Kindly once read below query and send reply.
regards,
saritha.
1) My requirement is to validate
current date of system(sy-datum) and past date in selection screen.
If difference between these
two dates more than six months than one error must display.
for example assume
current date = 21/02/2008 &
past date = 19/08/2007 ,
difference between these two dates is 6 month 3 days.
Then error must display
" difference between current date & past date should not be more than six months"
2)Please explain me how to validate these two dates?
2008 Apr 11 10:09 AM
Hi,
try this:
PARAMETERS: P_DATE LIKE SY-DATUM.
*
DATA CH_DATE LIKE SY-DATUM.
*
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
MONTHS = '-6'
START_DATE = SY-DATUM
IMPORTING
RESULT_DATE = CH_DATE.
*
IF P_DATE < CH_DATE.
WRITE: 'ERROR', P_DATE.
ELSE.
WRITE: 'OK', P_DATE.
ENDIF.
Regards, Dieter
2008 Apr 11 9:48 AM
Hi,
Use the below code.
parameters: p_date type sy-datum.
data: v_date type sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = sy-datum
DAYS = 0
MONTHS = '06'
SIGNUM = '-'
YEARS = 0
IMPORTING
CALC_DATE = v_date.
if p_date lt v_date.
write:/ 'Invalid date'.
else.
write:/ 'Valid date'.
endif.
2008 Apr 11 9:51 AM
THIS IS VIGNESh CODE...BUT FOR VALIDATION PURPOSES U NEED TO use at selection-screen .
Use the below code.
select-options: p_date type sy-datum.
*at selection-screen .*
data: v_date type sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = sy-datum
DAYS = 0
MONTHS = '06'
SIGNUM = '-'
YEARS = 0
IMPORTING
CALC_DATE = v_date.
if p_date lt v_date.
write:/ 'Invalid date'.
else.
write:/ 'Valid date'.
endif.Edited by: saslove sap on Apr 11, 2008 10:52 AM
2008 Apr 11 10:13 AM
HI,
Use the FM:
MONTH_PLUS_DETERMINE add or subtract month from a date
Hope this helps.
<REMOVED BY MODERATOR>
Regards,
Sipra
Edited by: Alvaro Tejada Galindo on Apr 11, 2008 5:35 PM
2008 Apr 11 10:22 AM
Hi,
Now, in your case the current date = 02/21/2008 ( mm/dd/yyyy)
and Past date = 08/19/2007.
1. Use the FM ' HR_AUPBS_MONTH_DAY' to get the number of months b/w these two dates.
2. You will get the no. of months in the parameter NO_MONTH.
3. Take it into a variable V_MONTH and then check if V_MONTH GE '6'.
4. If so, give the error message otherwise sucessfully carry out the your rest processing.
Please reward points if useful.
If you have any query revert back to me.
thanks,
Asha
2008 Apr 11 11:11 AM
Hi,
Please refer the code below :
tables : bsis.
data : month like VTBBEWE-ATAGE.
parameters : sp_date like sy-datum.
at selection-screen.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
i_date_from = sp_date
* I_KEY_DAY_FROM = I_KEY_DAY_FROM
i_date_to = sy-datum
* I_KEY_DAY_TO = I_KEY_DAY_TO
* I_FLG_SEPARATE = ' '
IMPORTING
* E_DAYS = E_DAYS
E_MONTHS = month
* E_YEARS = E_YEARS
.
if month GT '6'.
message 'Invalid date' type 'E'.
endif.
OR
Try using FM MONTHS_BETWEEN_TWO_DATES.
Thanks,
Sriram Ponna.