‎2008 Apr 11 9:50 AM
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 9:57 AM
‎2008 Apr 11 9:59 AM
use FM
HR_HK_DIFF_BT_2_DATES and pass your dates ..
and enter 05 in OUTPUT_FORMAT ... of FM
‎2008 Apr 11 9:59 AM
there are a lot of function modules around in which you can add month, weeks, days to a given date.
Look for something like (addmonths* or adddate* / dateadd*) in SE37. This way you can add 6 months to the current date (date low let's say). Next you check if date low > or > date high.
No SAP System available else I would have given you the exact name.
‎2008 Apr 11 10:09 AM
Hi,
Use the below logic.
parameters: p_past type sy-datum,
p_curr type sy-datum default sy-datum.
data: v_date type sy-datum.
at selection-screen.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = p_curr
DAYS = 0
MONTHS = '06'
SIGNUM = '-'
YEARS = 0
IMPORTING
CALC_DATE = v_date.
if p_past lt v_date.
message
'difference between current date & past date should not be more than six
months' type 'E'.
endif.
‎2008 Apr 11 10:13 AM
Hi
Either use that FM, it will work
or simply ise sy-datum0(4) - curr_date0(4) > 6
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 11, 2008 5:26 PM
‎2008 Apr 11 11:13 AM
Hi,
Check the following code:
DATA: EDAYS LIKE VTBBEWE-ATAGE,
EMONTHS LIKE VTBBEWE-ATAGE,
EYEARS LIKE VTBBEWE-ATAGE.
PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
exporting
i_date_from = FROMDATE
i_date_to = TODATE
I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = EDAYS
E_MONTHS = EMONTHS
E_YEARS = EYEARS.
if emonths > 6.
write:/ 'Months exceeds 6'.
endif.
Regards,
Bhaskar
‎2008 Apr 11 11:16 AM
Hi,
Please refer the below code:
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.
Thanks,
Sriram Ponna.
‎2008 Apr 11 11:35 AM